This repository was archived by the owner on Jun 22, 2021. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -54,6 +54,8 @@ class MultiSource extends Meister.ParserPlugin {
5454 }
5555
5656 process ( item ) {
57+ this . currentItem = item ;
58+
5759 return new Promise ( ( resolve , reject ) => {
5860 const hasDRM = typeof item . drmConfig === 'object' ;
5961 item . sources = this . restructureItems ( item . sources , hasDRM ) ; // eslint-disable-line
@@ -66,11 +68,30 @@ class MultiSource extends Meister.ParserPlugin {
6668 newItem . metadata = item . metadata ; // eslint-disable-line
6769 }
6870
71+ this . on ( 'playerError' , this . onPlayerError . bind ( this ) ) ;
72+
6973 resolve ( newItem ) ;
7074 }
7175 } ) ;
7276 } ) ;
7377 }
78+
79+ onPlayerError ( ) {
80+ // Unload our previous item.
81+ super . unload ( ) ;
82+
83+ // We can remove the first item in our sources since it's not able to play.
84+ const removedItem = this . currentItem . sources . shift ( ) ;
85+
86+ // Make sure we do have sources to play.
87+ if ( ! this . currentItem . sources . length ) return ;
88+
89+ console . warn ( `${ MultiSource . pluginName } : Item '${ removedItem . type } ' ran into an error while playing. Switching items for optimal experience.` ) ;
90+
91+ // Now retry the whole flow.
92+ this . meister . setItem ( this . currentItem ) ;
93+ this . meister . load ( ) ;
94+ }
7495}
7596
7697Meister . registerPlugin ( MultiSource . pluginName , MultiSource ) ;
You can’t perform that action at this time.
0 commit comments