How to use the xgplayer.sniffer function in xgplayer

To help you get started, we’ve selected a few xgplayer examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github bytedance / xgplayer / packages / xgplayer-shaka / src / index.js View on Github external
constructor (options) {
    super(options)
    let self = this
    this.shakaOpts = options.shakaOpts || {}
    this.util = Player.util
    this.player = this
    this.url = this.player.config.url
    this.sniffer = Player.sniffer
    this.player_ = null
    this.content = []

    Shaka.polyfill.installAll()

    if (Shaka.Player.isBrowserSupported()) {
      this.video_ = this.player.video
      this.video_.autoplay = false
      this.player_ = new Shaka.Player(this.video_)

      this.player_.addEventListener('error', function (event) {
        console.error('Error code', event.detail.code, 'object', event.detail) // eslint-disable-line no-console
      })

      if (this.shakaOpts) {
        this.player_.configure(this.shakaOpts)
github bytedance / xgplayer / packages / xgplayer-mp4 / src / index.js View on Github external
let mp4player = function () {
  let player = this; let sniffer = Player.sniffer; let util = Player.util
  let Errors = Player.Errors; let mainURL; let backupURL
  let preloadTime = player.config.preloadTime || 15
  let waiterTimer
  let url = player.config.url
  let rule = player.config.pluginRule || function () { return true }
  if (!url) {
    player.emit('error', new Errors('other', player.config.vid))
    return
  }
  if (util.typeOf(url) === 'String') {
    mainURL = url
  } else if (util.typeOf(url) === 'Array' && url.length) {
    mainURL = url[0].src
    backupURL = url[1].src
  }
  player.config._mainURL = mainURL
github bytedance / xgplayer / packages / xgplayer-m4a / src / index.js View on Github external
let m4aplayer = function () {
  let player = this; let sniffer = Player.sniffer; let util = Player.util
  let Errors = Player.Errors; let mainURL; let backupURL
  let preloadTime = player.config.preloadTime || 15
  let waiterTimer
  Player.m4a = true
  player.hasEnded = false
  let list = util.typeOf(player.config.url) === 'Array' ? player.config.url : [{
    src: player.config.url,
    name: player.config.name,
    vid: player.config.vid,
    poster: player.config.poster
  }]
  let url = list[0].src
  let name = list[0].name
  let vid = list[0].vid
  let poster = list[0].poster
  let rule = player.config.pluginRule || function () { return true }
github bytedance / xgplayer / packages / xgplayer-hls / src / index.js View on Github external
const hlsplayer = function () {
  let player = this

  let sniffer = Player.sniffer

  let util = Player.util
  const preloadTime = player.config.preloadTime || 15
  if (['chrome', 'firfox', 'safari'].some(item => item === sniffer.browser) && MSE.isSupported('video/mp4; codecs="avc1.64001E, mp4a.40.5"')) {
    const _start = player.start
    let hls
    Object.defineProperty(player, 'src', {
      get () {
        return player.currentSrc
      },
      set (url) {
        player.config.url = url
        if (!player.paused) {
          player.pause()
          player.once('pause', () => {
            player.start(url)
github bytedance / xgplayer / packages / xgplayer-dash / src / index.js View on Github external
constructor (options) {
    super(options)

    let player = this
    let sniffer = Player.sniffer
    let definations = []

    const preloadTime = player.config.preloadTime || 15
    if (['chrome', 'firfox', 'safari'].some(item => item === sniffer.browser) && MSE.isSupported('video/mp4; codecs="avc1.64001E, mp4a.40.5"')) {
      const _start = player.start
      let dash
      Object.defineProperty(player, 'src', {
        get () {
          return player.currentSrc
        },
        set (url) {
          player.config.url = url
          if (!player.paused) {
            player.pause()
            player.once('pause', () => {
              player.start(url)
github bytedance / xgplayer / packages / xgplayer-hls.js / src / index.js View on Github external
constructor (options) {
    super(options)
    this.hlsOpts = options.hlsOpts || {}
    let util = Player.util
    let player = this
    this.browser = utils.getBrowserVersion()
    if(player.config.useHls === undefined) {
      if ((Player.sniffer.device === 'mobile' && navigator.platform !== 'MacIntel' && navigator.platform !== 'Win32') || this.browser.indexOf('Safari') > -1) {
        return
      }
    } else if(!player.config.useHls) {
      return
    }

    let hls
    hls = new Hls(this.hlsOpts)
    this.hls = hls

    Object.defineProperty(player, 'src', {
      get () {
        return player.currentSrc
      },
      set (url) {
        util.removeClass(player.root, 'xgplayer-is-live')

xgplayer

video player

MIT
Latest version published 4 months ago

Package Health Score

80 / 100
Full package analysis