@@ -190,6 +190,7 @@ impl<E: Env + 'static> UpdateWithCtx<E> for Player {
190190 & mut self . subtitles ,
191191 & self . selected ,
192192 & self . video_params ,
193+ self . stream . as_ref ( ) ,
193194 & ctx. profile . addons ,
194195 ) ;
195196 let next_video_effects = next_video_update (
@@ -376,6 +377,7 @@ impl<E: Env + 'static> UpdateWithCtx<E> for Player {
376377 & mut self . subtitles ,
377378 & self . selected ,
378379 & self . video_params ,
380+ self . stream . as_ref ( ) ,
379381 & ctx. profile . addons ,
380382 ) ;
381383 let skip_gaps_effects = skip_gaps_update :: < E > (
@@ -1233,33 +1235,64 @@ fn subtitles_update<E: Env + 'static>(
12331235 subtitles : & mut Vec < ResourceLoadable < Vec < Subtitles > > > ,
12341236 selected : & Option < Selected > ,
12351237 video_params : & Option < VideoParams > ,
1238+ stream : Option < & Loadable < ( StreamUrls , Stream < ConvertedStreamSource > ) , EnvError > > ,
12361239 addons : & [ Descriptor ] ,
12371240) -> Effects {
1238- match ( selected, video_params ) {
1241+ match ( selected, stream ) {
12391242 (
12401243 Some ( Selected {
12411244 subtitles_path : Some ( subtitles_path) ,
12421245 ..
12431246 } ) ,
1244- Some ( video_params) ,
1245- ) => resources_update_with_vector_content :: < E , _ > (
1246- subtitles,
1247- ResourcesAction :: force_request (
1248- & AggrRequest :: AllOfResource ( ResourcePath {
1249- extra : subtitles_path
1250- . extra
1251- . to_owned ( )
1252- . extend_one ( & VIDEO_HASH_EXTRA_PROP , video_params. hash . to_owned ( ) )
1253- . extend_one (
1254- & VIDEO_SIZE_EXTRA_PROP ,
1255- video_params. size . as_ref ( ) . map ( |size| size. to_string ( ) ) ,
1256- )
1257- . extend_one ( & VIDEO_FILENAME_EXTRA_PROP , video_params. filename . to_owned ( ) ) ,
1258- ..subtitles_path. to_owned ( )
1259- } ) ,
1260- addons,
1261- ) ,
1262- ) ,
1247+ Some ( Loadable :: Ready ( ( _stream_urls, converted_stream) ) ) ,
1248+ ) => {
1249+ resources_update_with_vector_content :: < E , _ > (
1250+ subtitles,
1251+ ResourcesAction :: force_request (
1252+ & AggrRequest :: AllOfResource ( ResourcePath {
1253+ extra : {
1254+ // Always prefer the Stream field if such is set by the addon
1255+ // otherwise we can use the VideoParams as a fallback.
1256+ subtitles_path
1257+ . extra
1258+ . to_owned ( )
1259+ . extend_one (
1260+ & VIDEO_HASH_EXTRA_PROP ,
1261+ converted_stream. behavior_hints . video_hash . clone ( ) . or (
1262+ video_params
1263+ . as_ref ( )
1264+ . and_then ( |video_params| video_params. hash . to_owned ( ) )
1265+ . to_owned ( ) ,
1266+ ) ,
1267+ )
1268+ . extend_one (
1269+ & VIDEO_SIZE_EXTRA_PROP ,
1270+ converted_stream
1271+ . behavior_hints
1272+ . video_size
1273+ . or ( video_params
1274+ . as_ref ( )
1275+ . and_then ( |video_params| video_params. size ) )
1276+ . map ( |size| size. to_string ( ) ) ,
1277+ )
1278+ . extend_one (
1279+ & VIDEO_FILENAME_EXTRA_PROP ,
1280+ converted_stream
1281+ . behavior_hints
1282+ . filename
1283+ . to_owned ( )
1284+ . or ( video_params
1285+ . as_ref ( )
1286+ . and_then ( |video_params| video_params. filename . clone ( ) ) )
1287+ . to_owned ( ) ,
1288+ )
1289+ } ,
1290+ ..subtitles_path. to_owned ( )
1291+ } ) ,
1292+ addons,
1293+ ) ,
1294+ )
1295+ }
12631296 _ => eq_update ( subtitles, vec ! [ ] ) ,
12641297 }
12651298}
0 commit comments