Only select timed metadata tracks
This commit is contained in:
parent
0a12f7389e
commit
46701448e7
@ -571,11 +571,7 @@ public class ReactVideoView extends ScalableVideoView implements
|
||||
});
|
||||
}
|
||||
|
||||
// Select track (so we can use it to listen to timed meta data updates)
|
||||
try{
|
||||
mp.selectTrack(0);
|
||||
}catch (Throwable t){
|
||||
}
|
||||
selectTimedMetadataTrack(mp);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -610,12 +606,7 @@ public class ReactVideoView extends ScalableVideoView implements
|
||||
|
||||
@Override
|
||||
public void onBufferingUpdate(MediaPlayer mp, int percent) {
|
||||
// Select track (so we can use it to listen to timed meta data updates)
|
||||
try{
|
||||
mp.selectTrack(0);
|
||||
}catch (Throwable t){
|
||||
}
|
||||
|
||||
selectTimedMetadataTrack(mp);
|
||||
mVideoBufferedDuration = (int) Math.round((double) (mVideoDuration * percent) / 100.0);
|
||||
}
|
||||
|
||||
@ -768,4 +759,20 @@ public class ReactVideoView extends ScalableVideoView implements
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
// Select track (so we can use it to listen to timed meta data updates)
|
||||
private void selectTimedMetadataTrack(MediaPlayer mp) {
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
MediaPlayer.TrackInfo[] trackInfo = mp.getTrackInfo();
|
||||
for (int i = 0; i < trackInfo.length; ++i) {
|
||||
if (trackInfo[i].getTrackType() == MediaPlayer.TrackInfo.MEDIA_TRACK_TYPE_TIMEDTEXT) {
|
||||
mp.selectTrack(i);
|
||||
break;
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user