GithubHelp home page GithubHelp logo

bytedance / xgplayer Goto Github PK

View Code? Open in Web Editor NEW
7.8K 120.0 828.0 455.9 MB

A HTML5 video player with a parser that saves traffic

Home Page: https://h5player.bytedance.com/

License: MIT License

JavaScript 93.74% HTML 2.08% SCSS 4.18%
mp4 mp4box fmp4 hls-player flv-parser dash video-player hls flv video

xgplayer's Introduction

Introduction

xgplayer is a web video player library. It has designed a separate, detachable UI component based on the principle that everything is componentized. More importantly, it is not only flexible in the UI layer, but also bold in its functionality: it gets rid of video loading, buffering, and format support for video dependence. Especially on mp4 it can be staged loading for that does not support streaming mp4. This means seamless switching with clarity, load control, and video savings. It also integrates on-demand and live support for FLV, HLS, and dash. Document

Start

  1. Install

    $ npm install xgplayer
  2. Usage

    Step 1:

    <div id="vs"></div>

    Step 2:

    import Player from 'xgplayer';
    
    const player = new Player({
        id: 'vs',
        url: 'http://s2.pstatp.com/cdn/expire-1-M/byted-player-videos/1.0.0/xgplayer-demo.mp4'
    })

    This is the easiest way to configure the player, then it runs with video. For more advanced content, see the plug-in section or documentation. more config

Plugins

xgplayer provides more plugins and supports custom plugins, for more content viewing plugins. There are many built-in plugins in the player, if you need to close specific plugins, you can disable them by ignores configuration

Dev

In order to debug by developers, we provide demos code in the fixtures directory of the repo. The player uses yarn for package management, and it only takes a few simple steps to start debugging in the repo

$ cd xgplayer
$ yarn
$ yarn dev:xgplayer

To debug other plugins, please refer to the scripts command provided in package.json in the root directory of the repo, such as:

$ yarn dev:hls
$ yarn dev:flv
$ yarn dev:mp4

License

Welcome to use xgplayer! Please read the following terms carefully. Using xgplayer means that you accept and agree to the terms.

  1. Xgplayer is licensed under the MIT License. You comply with its obligations by default.
  2. By default, you authorize us to place your logo in xgplayer website, which using xgplayer. If you have any problem, please let us know.

xgplayer's People

Contributors

bethe-light avatar cucygh avatar divawth avatar gemxx avatar hongqiongxing-b avatar hongqx avatar jiuyuetianjiuyuetian avatar l0rem1psum avatar leeight avatar leonardofu avatar lihz6 avatar lison16 avatar llftt avatar luokavin avatar lwyj123 avatar m1heng avatar magic-akari avatar maysjtu avatar meowtec avatar mowatermelon avatar shanyutongxue avatar wangsyi avatar xiaoyuhen avatar xinghui-lc avatar xiyuyizhi avatar yiwen03 avatar yqjiang avatar zhangxin92 avatar ziwei3749 avatar zoukanghua avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

xgplayer's Issues

[bug]xgplayer-flv切换清晰度后拖动进度条无限转菊花

插件:xgplayer-flv
用chrome模拟弱网(3G)的情况下,切换清晰度,然后立即拖动进度条,这个时候播放器就会无线转菊花。分析浏览器求情,应该是切换清晰度后,新视频源的元数据信息没有回来,使用的老的关键帧数据计算range造成的。麻烦帮忙看看

how to resolve the problem that Chrome 66 turning off autoplay released in April 2018

when i new a xgplayer instance that has a config autoplay: true, but it not auto at chrome.
so i switch the browsers to use firefox. it works.
how to resolve this problem
after i use the play method referencing api documents
player.play()
then chrome has a error:
Uncaught (in promise) DOMException: play() failed because the user didn't interact with the document first

play blob content

1、是否可以支持播放blob对象或者arraybuffer对象?
2、是否可以播放过程中动态添加视频源?

[feature request] Support keyboard shortcuts

Hey, our team are using xgplayer now, and we believe xgplayer is awesome.
Do you have any play to add keyboard shortcuts, like

  1. → to forward by 10 seconds
  2. ← to backward by 10 seconds
  3. space to pause or resume
  4. ↑ to increase volume
  5. ↓ to decrease volume

更多可供用户配置的一些优化项

在使用插件的过程中,发现几个我需要改动的地方没法用配置项的方式去修改插件默认的配置。比如视频不自动播放时:中间位置上的播放,暂停,重播按钮,我想替换成新的样子,就没法直接改配置去替换。如果下个版本能支持这个简单配置的话,对我来说那就很棒了

关于手机端 控制条问题。请大佬进来看看

whitelist: [/iPhone/gi,/Android/gi],
我是这样配置的白名单。
在微信中,原生controls 和播放器 controls 会两个同时存在。
是否我这个白名单配置有问题呢?好困惑。
还是这个有待修复?

Suggest adding some apis to get status of the controls

Hi,
now we inspect DOM to see the status of controls, it is not so convenient
can your guys add some apis to get status of controls ?
for example:
get the status of fullscreen and whether the bullet is enabled and so on via player instance directly

希望能添加一些可以获取控件状态的api, 比如弹幕是否开启、全屏是否开启
现在的方式是用js查看DOM的状态,有点不方便

Thanks : )

关于MP3歌词问题

Uploading T$V0{SMX7L}Y12()9TVE0.png…
一进来MP3播放器,会报 Failed to execute 'get' on 'IDBobjectStore' NO key or key
当点播放会报 Reduce of empty array with no initial value
这是我的配置:
id: 'mses',
url: res,
volume: 0.8,
height: 50,
ignores: ['cover', 'next', 'prev', 'mp4player'],
keyShortcut: 'on',
offline: false,
preloadNext: false,
麻烦大佬看看是什么原因呢

[bug] playbackRate.js

let ul = util.createDom('xg-playback', '<p class="name"><span>1x</span></p>', {}, 'xgplayer-playback'), root = player.controls;
let tips = util.createDom('xg-tips', tipsSpeed, {}, 'xgplayer-tips')

There is no options in ul

还有一个问题

就是在win10 自带浏览器中,关闭键盘快捷键功能会失效。

无法实例化video

按照文档里写法,在vue搭建的项目中,created()钩子里拿到数据后实例化播放器,打断点看到执行了const player = new Player({}),但是未挂载到DOM中,请教一下可能的原因?十分感谢

How to solve the problem that xgplayer cannot work with custom DOM and UI in Android Mobile browsers?

In Android Mobile browsers(Chrome, UC...), when users touch the start button of xgplayer, the browser console will report error "DOMException: play() can only be initiated by a user gesture" and xgplayer will not continue the work. In order to avoid this, xgplayer provides the whitelist for the mobile browsers. If the mobile device and browser info is not in the whitelist, xgplayer will work with native video DOM and UI.

hls.js问题

我们需要用到定制的hls.js,请问能否在用内置的hls.js之前先判断下windows有没有挂载,如果有优先用。

how to switch the video url

env:
vue
when i use api destory:

this.player.destroy()

then

this.player = new Player({
id: 'mse',
url: data,
volume: 0.6,
autoplay: true,
poster: require('assets/images/demand/video_poster.png'),
height: window.innerHeight*0.95,
width: window.innerWidth,
preloadTime: 10,
controls: true,
controlsList: ['nodownload'],
playbackRate: [0.5, 0.75, 1, 1.5, 2],
lang:'gs-px',
});
this.player dont have a case new Player()

i think xgplayer should have a api this.player.update({url: new url})

i Solve the problem by createElement('div') then new Player() finally..

ERROR TypeError: xgplayer_1.default is not a constructor

我在 Typescript 文件中这样使用:

import Player from 'xgplayer';
const player = new Player({
    id: 'vs',
    url: 'http://s2.pstatp.com/cdn/expire-1-M/byted-player-videos/1.0.0/xgplayer-demo.mp4'
})

但是在控制台报错:

ERROR TypeError: xgplayer_1.default is not a constructor

打印出来 Player 是 undefined,不知道哪里使用的不对,请指教!

关于实现自动清晰度切换

诸如油管一般效果的自动清晰度切换,如何用这个xgplayer实现呢?使用以下代码貌似并不行,文档上也没有特别说明

let player=new Player({
            id:'vs',
            url: [{src:'./xgtest-240.mp4',type:"video/mp4"},{src:'./xgtest-480.mp4',type:'video/mp4'},{src:'./xgtest-720.mp4',type:'video/mp4'}],
            poster:'./poster.png',
            playbackRate: [0.5, 0.75, 1, 1.5, 2],
            thumbnail: {
                pic_num: 44,
                width: 160,
                height: 90,
                col: 10,
                row: 10,
                urls: ['./xgplayer-demo-thumbnail.jpg'],
            },
        })
        player.emit('resourceReady', [{name: '标清', url: './xgtest-240.mp4',cname:'标清'},{name: '高清', url: './xgtest-480.mp4',cname:'高清'}, {name: '超清', url: './xgtest-720.mp4',cname:'超清'}])
        player.on('error', function (err) {
            console.log(JSON.stringify(err));
        });

window 7 64bit demo启动问题

win7 64bit执行babel-node app.js, 会报missing message.js错误。
npm i -save-dev @babel/core 和 npm i -save-dev @babel/node后,问题解决。难道头条的前端全部配mac吗。。。

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.