@@ -799,18 +799,8 @@ impl Player {
799799
800800 let mut draw_row = |stream_type : Type | {
801801 let text = match stream_type {
802- Type :: Audio => format ! (
803- "{} {}/{}" ,
804- sound_icon,
805- * self . audio_stream_info. current_stream,
806- self . audio_stream_info. total_streams
807- ) ,
808- Type :: Subtitle => format ! (
809- "{} {}/{}" ,
810- subtitle_icon,
811- * self . subtitle_stream_info. current_stream,
812- self . subtitle_stream_info. total_streams
813- ) ,
802+ Type :: Audio => format ! ( "{} {}" , sound_icon, self . audio_stream_info) ,
803+ Type :: Subtitle => format ! ( "{} {}" , subtitle_icon, self . subtitle_stream_info) ,
814804 _ => unreachable ! ( ) ,
815805 } ;
816806
@@ -1207,6 +1197,7 @@ fn get_decoder_from_stream_index(
12071197}
12081198
12091199#[ derive( PartialEq , Clone , Copy ) ]
1200+ /// The index of the stream.
12101201pub struct StreamIndex ( usize ) ;
12111202
12121203impl From < usize > for StreamIndex {
@@ -1224,14 +1215,16 @@ impl Deref for StreamIndex {
12241215
12251216#[ derive( PartialEq , Clone , Copy ) ]
12261217struct StreamInfo {
1227- current_stream : StreamIndex ,
1218+ // Not the actual `StreamIndex` of the stream. This is a user-facing number that starts
1219+ // at `1` and is incrememted when cycling between streams.
1220+ current_stream : usize ,
12281221 total_streams : usize ,
12291222}
12301223
12311224impl StreamInfo {
12321225 fn new ( ) -> Self {
12331226 Self {
1234- current_stream : StreamIndex :: from ( 0 ) ,
1227+ current_stream : 1 ,
12351228 total_streams : 0 ,
12361229 }
12371230 }
@@ -1241,14 +1234,19 @@ impl StreamInfo {
12411234 slf
12421235 }
12431236 fn cycle ( & mut self ) {
1244- self . current_stream =
1245- StreamIndex :: from ( ( ( * self . current_stream + 1 ) % ( self . total_streams + 1 ) ) . max ( 1 ) ) ;
1237+ self . current_stream = ( ( self . current_stream + 1 ) % ( self . total_streams + 1 ) ) . max ( 1 ) ;
12461238 }
12471239 fn is_cyclable ( & self ) -> bool {
12481240 self . total_streams > 1
12491241 }
12501242}
12511243
1244+ impl std:: fmt:: Display for StreamInfo {
1245+ fn fmt ( & self , f : & mut std:: fmt:: Formatter < ' _ > ) -> std:: fmt:: Result {
1246+ write ! ( f, "{}/{}" , self . current_stream, self . total_streams)
1247+ }
1248+ }
1249+
12521250/// Streams data.
12531251pub trait Streamer : Send {
12541252 /// The associated type of frame used for the stream.
0 commit comments