Giter Site home page Giter Site logo

neuron-digital / wjplayer Goto Github PK

View Code? Open in Web Editor NEW
56.0 6.0 11.0 18.4 MB

Video.js bundle that supports HLS, VAST/VMAP, 360-degree videos, and more.

Home Page: https://neuron-digital.github.io/wjplayer/

License: MIT License

JavaScript 68.77% SCSS 31.23%
videojs video audio player hls

wjplayer's Introduction

This package has been deprecated

Package no longer supported. Use at your own risk. Use pure video.js instead.

wjplayer

Video.js bundle that supports HLS, VAST/VMAP/VPAID ads, 360-degree videos, and more.

Build Status bundlephobia npm npm David David

What's included

Video.js 5

Video.js plugins

HLS plugins

Other plugins

Plugins dependencies

Testing

npm install
npm start

index.html with the list of examples will be opened in your browser.

Usage

<link href="path/to/wjplayer/dist/wjplayer.css" rel="stylesheet">

<!-- If you need ads in your videos, include ima sdk first -->
<script src="//imasdk.googleapis.com/js/sdkloader/ima3.js"></script>


<!-- HLS support using videojs-contrib-hls -->
<script src="path/to/wjplayer/dist/wjplayer.js"></script>

<!-- OR  -->

<!-- HLS support using hls.js  -->
<script src="path/to/wjplayer/dist/wjplayer-hls-js.js"></script>

To enable 360-degree video support add these includes:

<link rel="stylesheet" href="/path/to/wjplayer/dist/wjplayer-360.css">
<script src="path/to/wjplayer/dist/wjplayer-360.js"></script>

Place a container in your html:

<div id="player-container"></div>

and pass its id and the list of sources to wjplayer.

Examples

Create a player instance

var player = wjplayer({
  containerId: 'player-container',
  sources: [{
    src: '//vjs.zencdn.net/v/oceans.mp4',
    type: 'video/mp4'
  }, {
    src: '//vjs.zencdn.net/v/oceans.ogv',
    type: 'video/ogg'
  }]
);

HLS

var player = wjplayer({
  containerId: 'player-container',
  sources: [{
    src: 'path-to-video.m3u8',
    type: 'application/x-mpegURL'
  }]
});
player.reloadSourceOnError(); // init `reloadSourceOnError` plugin (part of videjs-contrib-hls)

Specify resolution and label of each source

var player = wjplayer({
  containerId: 'player-container',
  defaultQuality: 'high',
  // sourcesWithRes array will be passed to videojs-resolution-switcher
  sourcesWithRes: [
  {
    src: 'path-to-video-low-quality.m3u8',
    type: 'application/x-mpegURL',
    res: 360,
    label: 'SD'
  },
  {
    src: 'path-to-video-high-quality.m3u8',
    type: 'application/x-mpegURL',
    res: 720,
    label: 'HD'
  }]
});

Create an audio player

var audioPlayer = wjplayer({
  containerId: 'player-container',
  playerType: 'audio',
  sources: [{
    src: '//vjs.zencdn.net/v/oceans.mp3',
    type: 'video/mp3'
  }]
});

Insert ads

var player = wjplayer({
  containerId: 'player-container',
  sources: [{
    src: '//vjs.zencdn.net/v/oceans.mp4',
    type: 'video/mp4'
  }],
  ads: {
    adTagUrl: '//example.com/vmap.xml'
  }
});

Send player events to Google Analytics

var player = wjplayer({
  containerId: 'player-container',
  sources: [{
    src: '//vjs.zencdn.net/v/oceans.mp4',
    type: 'video/mp4'
  }]
);
player.ga({
  percentsPlayedInterval: 10,
  secondsPlayedMoments: [10, 30, 60, 3 * 60, 5 * 60],
  percentsPlayedInterval: 25,
  sendGaEventDirectly: true
});

360° video

var player = wjplayer({
  containerId: 'player-container',
  sources: [{
    src: '//vjs.zencdn.net/v/oceans.mp4',
    type: 'video/mp4'
  }],
  panorama: {
    clickAndDrag: true,
    clickToToggle: true,
    autoMobileOrientation: true
  }
});

Custom skin

var player = wjplayer({
  containerId: 'player-container',
  // Skin name.
  // In this case 'vjs-custom-skin' class will be assigned to player.
  // 'vjs-default-skin' is used by default.
  skin: 'custom',
  sources: [{
    src: '//vjs.zencdn.net/v/oceans.mp4',
    type: 'video/mp4'
  }]
});

CSS class 'vjs-custom-skin' will be assigned to player, so your can include your CSS file

<link href="path/to/skins/custom.css" rel="stylesheet">

and customize the player appearence using .vjs-custom-skin class.

Your can find links to some Video.js skins in video.js wiki.


API Reference

wjplayer()

Creates a new player and places it to container with the specified id.

Parameters

options: Object, Configuration options.

  • options.containerId: String, REQUIRED id of the container where player shoud be inserted (appendChild() will be used)

  • options.sources: Array, REQUIRED IF sourcesWithRes IS NOT PROVIDED Array of sources to pass to player.src()

  • options.sourcesWithRes: Array, REQUIRED IF sources IS NOT PROVIDED Array of sources to pass to player.updateSrc()

  • options.playerId: String, id to assign to the player element. Defaults to "player"

  • options.playerType: String, "video" or "audio" Defaults to "video"

  • options.defaultQuality: String | Number, "low", "high" or Number

  • options.pathToSwf: String, Path to flash player file (will be passed to videojs as videojs.options.flash.swf)

  • options.locale: String, If specified, will be set as player and ads locale. This may be any ISO 639-1 (two-letter) code.

  • options.autoplay: Boolean, Defaults to false

  • options.controls: Boolean, Defaults to true

  • options.loop: Boolean, The loop attribute causes the video to start over as soon as it ends. Defaults to false

  • options.preload: String, Defaults to "metadata"

  • options.poster: String, The width attribute sets the display width of the video (in pixels). This will take effect only if options.classes param is set (vjs-fill class, used by defaults, sets player width and height to 100%).

  • options.width: Number, The height attribute sets the display height of the video (in pixels).

  • options.height: Number, Player height

  • options.videojs: Object, Any additilnal ptions to pass to videojs.

  • options.muted: Boolean, Indicates whether the player should be muted by default. Defaults to false

  • options.playsinline: Boolean, Indicated whether the video should be allowed to play inline, and will not automatically enter fullscreen mode when playback begins. @see https://webkit.org/blog/6784/new-video-policies-for-ios/ Defaults to false.

  • options.skin: String, Skin name. Defaults to "default"

  • options.classes: Array, CSS classnames to assign to the player in addition to video-js. By default, the following classes are used: ['vjs-default-skin', 'vjs-fill', 'vjs-big-play-centered']

  • options.stretch: Boolean, Indicates whether video should stretch to fit the container. Defaults to false

  • options.playOnClick If true, click/touch event on player will start/stop the playback even if controls are disabled. Defaults to false

  • options.downloadButton: Boolean | Object, Indicates whether a download button should be shown in control bar.

  • options.downloadButton.text: String, Button title. Defaults to "Download"

  • options.volumeStyle: String, "horizontal" or "vertical". Defaults to "vertical"

  • options.panorama: Boolean | Object, Used for pamoramic (360-degree) videos. Pass true or options object for videojs-panorama plugin

  • options.crossorigin: String, Used with videojs-panorama plugin. Pass "anonymous" to avoid cross domain issue (will work on Chrome and Firefox, not Safari)

  • options.ads: Object, Settings for videojs-ima plugin.

  • options.ads.adTagUrl: String, Tag url. The only requried setting here.

  • options.ads.adLabel: String, Replaces the "Advertisement" text in the ad label.

  • options.ads.showControlsForJSAds: Boolean, Defaults to false

  • options.share: Object, Will be passed to videojs-share plugin.

  • options.share.socials: Array, List of social networks. See vanilla-sharing for details.

  • options.share.url: String, This is the URL that points to your custom web page which has your video and the meta tags for sharing. Defaults to the current page url.

  • options.share.embedCode: String, Iframe embed code for sharing the video. Defaults to iframe with the current page url specified as src.

  • options.share.title: String, Title to share.

  • options.share.description: String, Description to share.

  • options.share.image: String, Image to share. Defaults to options.poster.

  • options.share.fbAppId: String, Required for share to Facebook.

  • options.share.redirectUri: String, Defaults to ${url}#close_window.

  • options.enableHlsSupport: Boolean, Set to false in order to disable any workarounds etc. that are required to make HLS support a reality. (e.g. stops forcing flash on IE11 and brings back videoJsResolutionSwitcher + ads) Defaults to true

Returns: Object, the videojs player instance object.


Compatible

Browser IE Edge Firefox Chrome Safari Opera iOS Safari Opera Mini Android Browser Chrome for Android Phone Chrome for Android Tablet
Live x n/a o о o o o o o о o
with ads o n/a o оo o oo r1 x oo о o
HLS master x n/a x x o x o x x o o
HLS by resolution x n/a o о o о o x oo o o
MP4 o n/a o оo o oo o x oo o o
HLS and MP4 x n/a x x o x o x oo о o
Stretch o n/a o о o o p1 x x x v1
MP3 o n/a o o o о o x oo o o
360° MP4 x n/a x o o o x x oo x o

Notes:

  • о - playing with no issues.
  • oo - pereodical freezes are happening.
  • x - video is not playing.
  • r1 - postroll & midroll are not working
  • p1 - play button is only available in landscape orientation
  • v1 - video goes beyond screen border
  • n/a - test environment is not available

Contributing

wjplayer is a free and open source library, and we appreciate any help you're willing to give. Check out the contributing guide.

License

wjplayer is licensed under the MIT License. View the license file

Similar projects

wjplayer's People

Contributors

avdeev avatar hettiger avatar mkhazov avatar renovate[bot] avatar skoshmanov 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

wjplayer's Issues

videojs 6 support

Hey!
@mkhazov Mikhail, I saw your last commits to video.js@6 branch.

Is there any problems with video.js@6 support, or you fixed all of them?

Dependency Dashboard

This issue lists Renovate updates and detected dependencies. Read the Dependency Dashboard docs to learn more.

Rate-Limited

These updates are currently rate-limited. Click on a checkbox below to force their creation now.

  • chore(deps): replace dependency babel-eslint with @babel/eslint-parser
  • chore(deps): update dependency gulp-sass to v4.1.1
  • chore(deps): update dependency eslint to v7.32.0
  • chore(deps): update dependency three to v0.164.1
  • chore(deps): update actions/checkout action to v4
  • chore(deps): update actions/setup-node action to v4
  • chore(deps): update dependency babel-eslint to v10
  • chore(deps): update dependency babel-loader to v9
  • chore(deps): update dependency browser-sync to v3
  • chore(deps): update dependency del to v7
  • chore(deps): update dependency eslint to v9
  • chore(deps): update dependency expose-loader to v5
  • chore(deps): update dependency fancy-log to v2
  • chore(deps): update dependency gulp to v5
  • chore(deps): update dependency gulp-autoprefixer to v9
  • chore(deps): update dependency gulp-sass to v5
  • chore(deps): update dependency hls.js to v1
  • chore(deps): update dependency video.js to v8
  • chore(deps): update dependency videojs-contrib-ads to v7
  • chore(deps): update dependency webpack-cli to v5
  • 🔐 Create all rate-limited PRs at once 🔐

Edited/Blocked

These updates have been manually edited so Renovate will no longer make changes. To discard all commits and start over, click on a checkbox.

Open

These updates have all been created already. Click a checkbox below to force a retry/rebase of any.

Detected dependencies

github-actions
.github/workflows/nodejs.yml
  • actions/checkout v2
  • actions/setup-node v1
npm
package.json
  • babel-cli 6.26.0
  • babel-core 6.26.3
  • babel-eslint 8.2.6
  • babel-loader 7.1.5
  • babel-plugin-add-module-exports 1.0.2
  • babel-preset-es2015 6.24.1
  • browser-sync 2.26.7
  • del 5.1.0
  • eslint 7.4.0
  • expose-loader 0.7.5
  • fancy-log 1.3.3
  • gulp 4.0.2
  • gulp-add-src 1.0.0
  • gulp-autoprefixer 7.0.1
  • gulp-concat 2.6.1
  • gulp-sass 4.1.0
  • hls.js 0.6.21
  • three 0.89.0
  • video.js 5.19.2
  • videojs-contrib-ads 3.1.3
  • videojs-contrib-hls 5.8.2
  • videojs-ga 2ff4015
  • videojs-ima f86659a
  • videojs-panorama 9a20b1d0b201ba20a89ab491a7d5f247e133b9ee
  • videojs-quality-picker 0.0.3
  • videojs-replay 1.1.0
  • videojs-resolution-switcher bdc5455
  • videojs-share 1.1.0
  • webpack 4.43.0
  • webpack-cli 3.3.11

  • Check this box to trigger a request for Renovate to run again on this repository

Need a list of ads-events

Hi superguys!
I used your wjplayer with ads. I need to catch the ads pause event, to create a big "Play" button over the top advertising layer.

I am sure that this is a very simple task, but I can't find the correct event to listen.

Is there a list of ads event? Or if it hasn't, may be you cood help me with some advise, how can I make it without change the core file?

My code is simple:

var player = wjplayer({
        containerId: 'spb_player',
        autoplay: true,
        debug: true,
        sources: [{
            src: '<?=$hls_url?>',
            type: 'application/x-mpegURL'
        }],
        ads: {
            debug: true,
            adLabel: 'Реклама',
            contribAdsSettings: {
                prerollTimeout: 500
            },
            adTagUrl: adsPrerollUrl
        }
    });

It'll be great if wjplayer has something like this:

    ads: {
            debug: true,
            adLabel: 'Реклама',
            contribAdsSettings: {
                prerollTimeout: 500
            },
            adTagUrl: adsPrerollUrl,
            onAdPaused: function() {
                // here I will generate my custom "Play" button and showing it over the Ads.
            },
            onAdPlayed: function() {
                // here I will removed or hidded my custom "Play" button.
            },
        }

Скомпелированные дистурбутивы

Привет, наткнулся на ваш плеер. К сожалению как я понял получить готовые дистурбутивы можно только через npm. Можете в релизах уже класть готовые дистры, не все к сожалению могут работать с npm.
Заранее спасибо!

Example page's broken urls

Hi,
Your example pages have broken links. Dist directory is not on there,

Example,
https://neuron-digital.github.io/wjplayer/examples/hls_split.html

hls_split.html:77 durationchange
blob:https://neuron-digital.github.io/187d43f6-c52a-42e1-9573-47214e4a94c5:1 Uncaught ReferenceError: e is not defined
blob:https://neuron-digital.github.io/187d43f6-c52a-42e1-9573-47214e4a94c5:1 Uncaught ReferenceError: e is not defined
blob:https://neuron-digital.github.io/0b9697a2-2d52-431d-8a63-fc95d3c439d9:1 Uncaught ReferenceError: e is not defined
blob:https://neuron-digital.github.io/0b9697a2-2d52-431d-8a63-fc95d3c439d9:1 Uncaught ReferenceError: e is not defined
hls_split.html:1 The SSL certificate used to load resources from https://static.life.ru has been distrusted. See https://g.co/chrome/symantecpkicerts for more information.
.185142e5f273e565511ebe3a8494cf95.jpg:1 Failed to load resource: net::ERR_CERT_SYMANTEC_LEGACY
static.life.ru/posts/2016/09/907639/video/185142e5f273e565511ebe3a8494cf95-4800.ts:1 Failed to load resource: net::ERR_CERT_SYMANTEC_LEGACY
log.js:87 VIDEOJS: WARN: Problem encountered with the current HLS playlist. Trying again since it is the final playlist.
e.logByType @ log.js:87
wjplayer.css:1 Failed to load resource: the server responded with a status of 404 ()
nmd.css:1 Failed to load resource: the server responded with a status of 404 ()

[Question] RequireJS support

Hey! First of all, thank you for the work done here!
I was having issues integrating videojs with hls, and you guys saved my day.

I tried to include the library from requirejs, but then after taking a look at your source, I saw you guys are only supporting webpack. Is that right or am I doing something wrong?

For now, I had to add a script tag on my html file, but i will really appreciate any help to keep having a single request for all the js.

Thanks again.

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.