Skip to content

Commit

Permalink
TimedMetaData works now
Browse files Browse the repository at this point in the history
  • Loading branch information
airman00 authored Sep 17, 2019
1 parent 2978344 commit 4fb0b38
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions android/src/main/java/com/brentvatne/react/ReactVideoView.java
Original file line number Diff line number Diff line change
Expand Up @@ -676,9 +676,13 @@ public void onTimedMetaDataAvailable(MediaPlayer mp, TimedMetaData data) {

try {
String rawMeta = new String(data.getMetaData(), "UTF-8");
WritableMap id3 = Arguments.createMap();

int indexOfSecondToLast0 = rawMeta.lastIndexOf('\000', rawMeta.length()-2 );
// Last character is a 0 by definition
String jsonDataString = rawMeta.substring(indexOfSecondToLast0+1, rawMeta.length()-1); // -1, not -2, b/c inclusive

id3.putString(EVENT_PROP_METADATA_VALUE, rawMeta.substring(rawMeta.lastIndexOf("\u0003") + 1));
WritableMap id3 = Arguments.createMap();
id3.putString(EVENT_PROP_METADATA_VALUE, jsonDataString);
id3.putString(EVENT_PROP_METADATA_IDENTIFIER, "id3/TDEN");

WritableArray metadata = new WritableNativeArray();
Expand Down Expand Up @@ -774,10 +778,10 @@ private void selectTimedMetadataTrack(MediaPlayer mp) {
try { // It's possible this could throw an exception if the framework doesn't support getting track info
MediaPlayer.TrackInfo[] trackInfo = mp.getTrackInfo();
for (int i = 0; i < trackInfo.length; ++i) {
if (trackInfo[i].getTrackType() == MediaPlayer.TrackInfo.MEDIA_TRACK_TYPE_TIMEDTEXT) {
//if (trackInfo[i].getTrackType() == MediaPlayer.TrackInfo.MEDIA_TRACK_TYPE_TIMEDTEXT) {
mp.selectTrack(i);
break;
}
// break;
// }
}
} catch (Exception e) {}
}
Expand Down

0 comments on commit 4fb0b38

Please sign in to comment.