This repository was archived by the owner on Jun 22, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -83,3 +83,21 @@ meisterPlayer.setItem({
8383
8484meisterPlayer .load ();
8585```
86+
87+ ### switchItemOnError * [ Boolean] * (default: true) ###
88+
89+ Goes to the next item in the 'sources' array when the current item has thrown an error. (NOT_FOUND, CODEC_ERRORS, etc)
90+ This can be usefull for codecs that cannot be determined if it can play on the current device.
91+ Multisource will switch out the item with a new item so playback can continue.
92+
93+ Example:
94+
95+ ``` JavaScript
96+ meisterPlayer .setItem ({
97+ sources: [ ... ],
98+ type: ' multi-source' ,
99+ switchItemOnError: false , // Will stop playback after an fatal error occured.
100+ });
101+ ```
102+
103+
Original file line number Diff line number Diff line change @@ -56,6 +56,11 @@ class MultiSource extends Meister.ParserPlugin {
5656 process ( item ) {
5757 this . currentItem = item ;
5858
59+ // Set default config
60+ if ( typeof this . currentItem . switchItemOnError === 'undefined' ) {
61+ this . currentItem . switchItemOnError = true ;
62+ }
63+
5964 return new Promise ( ( resolve , reject ) => {
6065 const hasDRM = typeof item . drmConfig === 'object' ;
6166 item . sources = this . restructureItems ( item . sources , hasDRM ) ; // eslint-disable-line
@@ -68,7 +73,9 @@ class MultiSource extends Meister.ParserPlugin {
6873 newItem . metadata = item . metadata ; // eslint-disable-line
6974 }
7075
71- this . on ( 'playerError' , this . onPlayerError . bind ( this ) ) ;
76+ if ( this . currentItem . switchItemOnError ) {
77+ this . on ( 'playerError' , this . onPlayerError . bind ( this ) ) ;
78+ }
7279
7380 resolve ( newItem ) ;
7481 }
You can’t perform that action at this time.
0 commit comments