<commit_before>import $ from '../utils/dom';
import utils, { is } from '../utils/util';
import Event from '../utils/events';
import Log from '../utils/logger';;
import { setupStorage, updateStorage } from './storage';
import { buildControls } from './controls';
import { defaultConfig as defaults } from '../config';

class Player {
  constructor(media, config) {
    const browser = utils.browerSniff();
    this.TAG = 'Player';
    this._player = {
      media, browser
    };
    this._config = config;
    this._timers = {};
    this._storage = {};
    this._media = media;
    this._fullscreen = $.fullscreen();
    this.__init__ = false;
    this.__original = media.cloneNode(true);
  }
  setup() {
    const config = this._config;
    const player = this._player;
    const storage = this._storage;

    const { media } = player;
    let api = {};
    if (this.__init__) {
      return null;
    }
    if (!is.htmlElement(media)) {
      Log.w(this.TAG, 'media must be a video');
      return;
    }
    setupStorage(config, storage);
    const tagName = media.tagName.toLowerCase();
    player.type = tagName;
    config.crossorigin = (media.getAttribute('crossorigin') !== null);
    config.autoplay = (config.autoplay || (media.getAttribute('autoplay') !== null));
    config.loop = (config.loop || (media.getAttribute('loop') !== null));
    player.supported = utils.supported(player.type);
    if (!player.supported.basic) {
      return;
    }
    player.container = $.wrap(media, document.createElement('div'));
    player.container.setAttribute('tabindex', 0);
    this._toggleStyleHook();

    Log.i(this.TAG, '' + player.browser.name + ' ' + player.browser.version);
    this._setupMedia();
    if (utils.inArray(config.types.html5, player.type)) {
      // Setup UI
      this._setupInterface();

      this._ready();
    }
    this.__init__ = true;
    api = {
      getType: player.type,
      getDuration: this._getDuration.bind(this),
      play: this._play.bind(this),
      pause: this._pause.bind(this),
      stop: () => { this._pause().bind(this); this._seek().bind(this); },
      seek: this._seek.bind(this),
      setVolume: this._setVolume.bind(this),
      togglePlay: this._togglePlay.bind(this),
      toggleMute: this._toggleMute.bind(this),
      toggleFullscreen: this._toggleFullscreen.bind(this),
      toggleControls: this._toggleControls.bind(this),
      isFullscreen: function () { return player.isFullscreen || false; },
      getContainer: function () { return player.container },
      getMedia: function () { return player.media; },
      getCurrentTime: function () { return player.media.currentTime; },
      getVolume: function () { return player.media.volume; },
      isMuted: function () { return player.media.muted; },
      isReady: function () { return $.hasClass(player.container, config.classes.ready); },
      isLoading: function () { return $.hasClass(player.container, config.classes.loading); },
      isPaused: function () { return player.media.paused; },
      on: function (event, callback) { Event.onEvent(player.container, event, callback); return this; },<commit_msg>[add] h5 to play flv<commit_after>import $ from '../utils/dom';
import utils, { is } from '../utils/util';
import Event from '../utils/events';
import Log from '../utils/logger';;
import { setupStorage, updateStorage } from './storage';
import { buildControls } from './controls';
import { defaultConfig as defaults } from '../config';

class Player {
  constructor(media, config) {
    const browser = utils.browerSniff();
    this.TAG = 'Player';
    this._player = {
      media, browser
    };
    this._config = config;
    this._timers = {};
    this._storage = {};
    this._media = media;
    this._fullscreen = $.fullscreen();
    this.__init__ = false;
    this.__original = media.cloneNode(true);
  }
  setup() {
    const config = this._config;
    const player = this._player;
    const storage = this._storage;

    const { media } = player;
    let api = {};
    if (this.__init__) {
      return null;
    }
    if (!is.htmlElement(media)) {
      Log.w(this.TAG, 'media must be a video');
      return;
    }
    setupStorage(config, storage);
    const tagName = media.tagName.toLowerCase();
    player.type = tagName;
    config.crossorigin = (media.getAttribute('crossorigin') !== null);
    config.autoplay = (config.autoplay || (media.getAttribute('autoplay') !== null));
    config.loop = (config.loop || (media.getAttribute('loop') !== null));
    player.supported = utils.supported(player.type);
    if (!player.supported.basic) {
      return;
    }
    player.container = $.wrap(media, document.createElement('div'));
    player.container.setAttribute('tabindex', 0);
    this._toggleStyleHook();

    Log.i(this.TAG, '' + player.browser.name + ' ' + player.browser.version);
    this._setupMedia();
    if (utils.inArray(config.types.html5, player.type)) {
      this._setupInterface();

      this._ready();
    }
    this.__init__ = true;
    api = {
      getType: player.type,
      getDuration: this._getDuration.bind(this),
      play: this._play.bind(this),
      pause: this._pause.bind(this),
      stop: () => { this._pause().bind(this); this._seek().bind(this); },
      seek: this._seek.bind(this),
      setVolume: this._setVolume.bind(this),
      togglePlay: this._togglePlay.bind(this),
      toggleMute: this._toggleMute.bind(this),
      toggleFullscreen: this._toggleFullscreen.bind(this),
      toggleControls: this._toggleControls.bind(this),
      isFullscreen: function () { return player.isFullscreen || false; },
      getContainer: function () { return player.container },
      getMedia: function () { return player.media; },
      getCurrentTime: function () { return player.media.currentTime; },
      getVolume: function () { return player.media.volume; },
      isMuted: function () { return player.media.muted; },
      isReady: function () { return $.hasClass(player.container, config.classes.ready); },
      isLoading: function () { return $.hasClass(player.container, config.classes.loading); },
      isPaused: function () { return player.media.paused; },
      on: function (event, callback) { Event.onEvent(player.container, event, callback); return this; },
{'fraction_non_alphanumeric': 0.1565245168503434, 'fraction_numerical': 0.0007985944737262418, 'mean_word_length': 3.163563829787234, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5489529', 'n_tokens_mistral': 1830, 'n_tokens_neox': 1832, 'n_words': 396}