dash-shaka-playback
Advanced tools
Comparing version 2.0.5-beta to 2.0.5
57
index.js
@@ -6,2 +6,3 @@ import {HTML5Video, Log, Events} from 'clappr' | ||
const AUTO = -1 | ||
const SHAKA_READY = 'shaka:ready' | ||
@@ -30,3 +31,2 @@ export default class DashShakaPlayback extends HTML5Video { | ||
super(options) | ||
this.isReadyState = false | ||
this._levels = [] | ||
@@ -40,5 +40,7 @@ options.autoPlay && this.play() | ||
if (!this.isReady) { | ||
this.once(Events.PLAYBACK_READY, this.play) | ||
this.once(SHAKA_READY, this.play) | ||
return | ||
} | ||
this._src = this.el.src; | ||
super.play() | ||
@@ -51,9 +53,8 @@ } | ||
// skipping ready event on video tag in favor of ready on shaka | ||
ready() {} | ||
_ready() {} | ||
get isReady() {return this.isReadyState} | ||
get isReady() {return this._isShakaReadyState} | ||
// skipping error handling on video tag in favor of error on shaka | ||
error(event) { | ||
Log.error('an error was raised support=', DashShakaPlayback.support) | ||
Log.error('an error was raised by the video tag', event, this.el.error) | ||
@@ -66,3 +67,2 @@ } | ||
clearInterval(this.sendStatsId) | ||
this.trigger(Events.PLAYBACK_STOP, this.name) | ||
this._sendStats() | ||
@@ -72,4 +72,5 @@ | ||
then(() => { | ||
super.stop() | ||
this._player = null | ||
this.isReadyState = false | ||
this._isShakaReadyState = false | ||
}). | ||
@@ -79,5 +80,5 @@ catch(() => { Log.error('shaka could not be unloaded') }) | ||
get textTracks() {return this._player && this._player.getTracks().filter((t) => t.type === "text")} | ||
get audioTracks() {return this._player && this._player.getTracks().filter((t) => t.type === "audio")} | ||
get videoTracks() {return this._player && this._player.getTracks().filter((t) => t.type === "video")} | ||
get textTracks() {return this._player && this._player.getTracks().filter((t) => t.type === 'text')} | ||
get audioTracks() {return this._player && this._player.getTracks().filter((t) => t.type === 'audio')} | ||
get videoTracks() {return this._player && this._player.getTracks().filter((t) => t.type === 'video')} | ||
getPlaybackType() {return (this._player && this._player.isLive()?'live':'vod') || ''} | ||
@@ -93,8 +94,12 @@ | ||
this._player.destroy(). | ||
then(() => this._destroy()). | ||
catch(() => { | ||
this._destroy() | ||
Log.error('shaka could not be destroyed') | ||
}) | ||
if (this._player) { | ||
this._destroy() | ||
} else { | ||
this._player.destroy(). | ||
then(() => this._destroy()). | ||
catch(() => { | ||
this._destroy() | ||
Log.error('shaka could not be destroyed') | ||
}) | ||
} | ||
} | ||
@@ -104,4 +109,6 @@ | ||
_setup() { | ||
this._isShakaReadyState = false | ||
this._player = this._createPlayer() | ||
this._options.shakaConfiguration && this._player.configure(this._options.shakaConfiguration) | ||
this._options.shakaOnBeforeLoad && this._options.shakaOnBeforeLoad(this._player) | ||
@@ -127,3 +134,5 @@ var playerLoaded = this._player.load(this._options.src) | ||
_loaded() { | ||
this._ready() | ||
this._isShakaReadyState = true | ||
this.trigger(SHAKA_READY) | ||
this._shakaReady() | ||
this._startToSendStats() | ||
@@ -172,7 +181,7 @@ this._fillLevels() | ||
super.destroy() | ||
this.isReadyState = false | ||
this._isShakaReadyState = false | ||
Log.debug('shaka was destroyed') | ||
} | ||
_ready() { | ||
_shakaReady() { | ||
super._ready() | ||
@@ -184,12 +193,6 @@ } | ||
shaka.polyfill.installAll() | ||
var browserSupported = shaka.Player.isBrowserSupported() | ||
shaka.Player.support().then((support) => { DashShakaPlayback.support = support}) | ||
var basic = !!window.Promise && !!window.Uint8Array && !!Array.prototype.forEach; | ||
var mediaSource = (window.MediaSource && window.MediaSource.isTypeSupported('video/mp4; codecs="avc1.42E01E,mp4a.40.2"')) | ||
var basicAndMediaSource = basic && mediaSource | ||
var resourceParts = resource.split('?')[0].match(/.*\.(.*)$/) || [] | ||
return basicAndMediaSource && (('mpd' === resourceParts[1]) || mimeType.indexOf('application/dash+xml') > -1) | ||
return browserSupported && (('mpd' === resourceParts[1]) || mimeType.indexOf('application/dash+xml') > -1) | ||
} | ||
{ | ||
"name": "dash-shaka-playback", | ||
"version": "2.0.5-beta", | ||
"version": "2.0.5", | ||
"description": "clappr dash playback based on shaka player", | ||
@@ -18,4 +18,4 @@ "main": "index.js", | ||
"dependencies": { | ||
"shaka-player": "v2.0.0-beta2", | ||
"clappr": "0.2.54" | ||
"shaka-player": "v2.0.8", | ||
"clappr": "0.2.64" | ||
}, | ||
@@ -22,0 +22,0 @@ "devDependencies": { |
[](https://badge.fury.io/js/dash-shaka-playback) | ||
[](https://img.shields.io/badge/license-BSD--3--Clause-blue.svg) | ||
# For the latest stable version [check](https://github.com/clappr/dash-shaka-playback/tree/1.0.12) | ||
# dash-shaka-playback | ||
@@ -10,8 +8,12 @@ | ||
> CDN: https://cdn.jsdelivr.net/clappr.dash-shaka-playback/latest/dash-shaka-playback.js | ||
> | ||
> CDNJS: https://cdnjs.cloudflare.com/ajax/libs/dash-shaka-playback/2.0.4/dash-shaka-playback.js | ||
> | ||
> (for some reason jsdelivr is not working) CDN JSDELIVR: https://cdn.jsdelivr.net/clappr.dash-shaka-playback/latest/dash-shaka-playback.js | ||
> | ||
> NPM: https://www.npmjs.com/package/dash-shaka-playback/ | ||
[](https://jsfiddle.net/m8ndduLo/16/) | ||
# Demo | ||
[](https://jsfiddle.net/leandromoreira/m8ndduLo/29/) | ||
# Usage | ||
@@ -23,3 +25,3 @@ | ||
<script src="https://cdn.jsdelivr.net/clappr/latest/clappr.min.js"></script> | ||
<script src="https://cdn.jsdelivr.net/clappr.dash-shaka-playback/latest/dash-shaka-playback.js"></script> | ||
<script src="https://cdnjs.cloudflare.com/ajax/libs/dash-shaka-playback/2.0.4/dash-shaka-playback.js"></script> | ||
</head> | ||
@@ -39,3 +41,6 @@ | ||
} | ||
} | ||
}, | ||
shakaOnBeforeLoad: function(shaka_player) { | ||
// shaka_player.getNetworkingEngine().registerRequestFilter() ... | ||
}, | ||
parentId: '#player' | ||
@@ -52,2 +57,6 @@ }); | ||
# License Wrapping | ||
If need to wrap DRM license requests or responses you use `shakaOnBeforeLoad` following [shaka License Wrapping](http://shaka-player-demo.appspot.com/docs/api/tutorial-license-wrapping.html) guide. | ||
# Development | ||
@@ -78,1 +87,2 @@ | ||
# For the older versions [check](https://github.com/clappr/dash-shaka-playback/tree/releases) |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
299890
697
2
84
0
+ Addedclappr@0.2.64(transitive)
- Removedclappr@0.2.54(transitive)
Updatedclappr@0.2.64
Updatedshaka-player@v2.0.8