dash-shaka-playback
Advanced tools
Comparing version 2.0.1-beta to 2.0.1
71
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,3 +40,3 @@ options.autoPlay && this.play() | ||
if (!this.isReady) { | ||
this.once(Events.PLAYBACK_READY, this.play) | ||
this.once(SHAKA_READY, this.play) | ||
return | ||
@@ -51,8 +51,10 @@ } | ||
// 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 by the video tag', event, this.el.error)} | ||
error(event) { | ||
Log.error('an error was raised by the video tag', event, this.el.error) | ||
} | ||
@@ -63,3 +65,2 @@ isHighDefinitionInUse() { return !!this.highDefinition } | ||
clearInterval(this.sendStatsId) | ||
this.trigger(Events.PLAYBACK_STOP, this.name) | ||
this._sendStats() | ||
@@ -69,4 +70,5 @@ | ||
then(() => { | ||
super.stop() | ||
this._player = null | ||
this.isReadyState = false | ||
this._isShakaReadyState = false | ||
}). | ||
@@ -76,6 +78,6 @@ catch(() => { Log.error('shaka could not be unloaded') }) | ||
get textTracks() {return this._player.getTracks().filter((t) => t.type === "text")} | ||
get audioTracks() {return this._player.getTracks().filter((t) => t.type === "audio")} | ||
get videoTracks() {return this._player.getTracks().filter((t) => t.type === "video")} | ||
getPlaybackType() {return this._player.isLive()?'live':'vod'} | ||
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') || ''} | ||
@@ -90,8 +92,12 @@ selectTrack(track) { | ||
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') | ||
}) | ||
} | ||
} | ||
@@ -101,6 +107,7 @@ | ||
_setup() { | ||
this._isShakaReadyState = false | ||
this._player = this._createPlayer() | ||
this.options.shakaConfiguration && this._player.configure(this.options.shakaConfiguration) | ||
this._options.shakaConfiguration && this._player.configure(this._options.shakaConfiguration) | ||
var playerLoaded = this._player.load(this.options.src) | ||
var playerLoaded = this._player.load(this._options.src) | ||
playerLoaded.then(() => this._loaded()) | ||
@@ -114,7 +121,15 @@ .catch((e) => this._setupError(e)) | ||
player.addEventListener('adaptation', () => this._onAdaptation()) | ||
player.addEventListener('buffering', (e) => this._onBuffering(e)) | ||
return player | ||
} | ||
_onBuffering(e) { | ||
var event = e.buffering ? Events.PLAYBACK_BUFFERING : Events.PLAYBACK_BUFFERFULL | ||
this.trigger(event) | ||
} | ||
_loaded() { | ||
this._ready() | ||
this._isShakaReadyState = true | ||
this.trigger(SHAKA_READY) | ||
this._shakaReady() | ||
this._startToSendStats() | ||
@@ -140,2 +155,3 @@ this._fillLevels() | ||
_error(type, shakaError) { | ||
Log.error('an error was raised support=', DashShakaPlayback.support) | ||
Log.error('an error was raised by shaka player', shakaError.detail) | ||
@@ -163,8 +179,8 @@ this.trigger(Events.PLAYBACK_ERROR, shakaError.detail, this.name) | ||
super.destroy() | ||
this.isReadyState = false | ||
this._isShakaReadyState = false | ||
Log.debug('shaka was destroyed') | ||
} | ||
_ready() { | ||
super.ready() | ||
_shakaReady() { | ||
super._ready() | ||
} | ||
@@ -175,11 +191,6 @@ } | ||
shaka.polyfill.installAll() | ||
var browserSupported = shaka.Player.isBrowserSupported() | ||
// shaka.Player.support().then((support) => { Log.debug(`TODO: Clappr is sync -> #{support.supported}`) }) | ||
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.1-beta", | ||
"version": "2.0.1", | ||
"description": "clappr dash playback based on shaka player", | ||
@@ -18,4 +18,4 @@ "main": "index.js", | ||
"dependencies": { | ||
"shaka-player": "v2.0.0-beta", | ||
"clappr": "latest" | ||
"shaka-player": "v2.0.0", | ||
"clappr": "0.2.61" | ||
}, | ||
@@ -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) | ||
# For the older versions [check](https://github.com/clappr/dash-shaka-playback/tree/releases) | ||
@@ -6,0 +6,0 @@ # dash-shaka-playback |
Sorry, the diff of this file is too big to display
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
291331
11
695
2
+ Addedclappr@0.2.61(transitive)
- Removedclappr@0.3.13(transitive)
Updatedclappr@0.2.61
Updatedshaka-player@v2.0.0