Merge pull request #1074 from react-native-community/bugfix/no-text-title
Text track cleanups
This commit is contained in:
commit
b3291ca190
@ -520,9 +520,9 @@ class ReactExoplayerView extends FrameLayout implements
|
|||||||
Format format = groups.get(i).getFormat(0);
|
Format format = groups.get(i).getFormat(0);
|
||||||
WritableMap textTrack = Arguments.createMap();
|
WritableMap textTrack = Arguments.createMap();
|
||||||
textTrack.putInt("index", i);
|
textTrack.putInt("index", i);
|
||||||
textTrack.putString("title", format.id);
|
textTrack.putString("title", format.id != null ? format.id : "");
|
||||||
textTrack.putString("type", format.sampleMimeType);
|
textTrack.putString("type", format.sampleMimeType);
|
||||||
textTrack.putString("language", format.language);
|
textTrack.putString("language", format.language != null ? format.language : "");
|
||||||
textTracks.pushMap(textTrack);
|
textTracks.pushMap(textTrack);
|
||||||
}
|
}
|
||||||
return textTracks;
|
return textTracks;
|
||||||
|
@ -126,10 +126,14 @@ public class ReactExoplayerViewManager extends ViewGroupManager<ReactExoplayerVi
|
|||||||
@ReactProp(name = PROP_SELECTED_TEXT_TRACK)
|
@ReactProp(name = PROP_SELECTED_TEXT_TRACK)
|
||||||
public void setSelectedTextTrack(final ReactExoplayerView videoView,
|
public void setSelectedTextTrack(final ReactExoplayerView videoView,
|
||||||
@Nullable ReadableMap selectedTextTrack) {
|
@Nullable ReadableMap selectedTextTrack) {
|
||||||
String typeString = selectedTextTrack.hasKey(PROP_SELECTED_TEXT_TRACK_TYPE)
|
String typeString = null;
|
||||||
|
Dynamic value = null;
|
||||||
|
if (selectedTextTrack != null) {
|
||||||
|
typeString = selectedTextTrack.hasKey(PROP_SELECTED_TEXT_TRACK_TYPE)
|
||||||
? selectedTextTrack.getString(PROP_SELECTED_TEXT_TRACK_TYPE) : null;
|
? selectedTextTrack.getString(PROP_SELECTED_TEXT_TRACK_TYPE) : null;
|
||||||
Dynamic value = selectedTextTrack.hasKey(PROP_SELECTED_TEXT_TRACK_VALUE)
|
value = selectedTextTrack.hasKey(PROP_SELECTED_TEXT_TRACK_VALUE)
|
||||||
? selectedTextTrack.getDynamic(PROP_SELECTED_TEXT_TRACK_VALUE) : null;
|
? selectedTextTrack.getDynamic(PROP_SELECTED_TEXT_TRACK_VALUE) : null;
|
||||||
|
}
|
||||||
videoView.setSelectedTextTrack(typeString, value);
|
videoView.setSelectedTextTrack(typeString, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -702,13 +702,16 @@ static NSString *const timedMetadata = @"timedMetadata";
|
|||||||
mediaSelectionGroupForMediaCharacteristic:AVMediaCharacteristicLegible];
|
mediaSelectionGroupForMediaCharacteristic:AVMediaCharacteristicLegible];
|
||||||
for (int i = 0; i < group.options.count; ++i) {
|
for (int i = 0; i < group.options.count; ++i) {
|
||||||
AVMediaSelectionOption *currentOption = [group.options objectAtIndex:i];
|
AVMediaSelectionOption *currentOption = [group.options objectAtIndex:i];
|
||||||
NSString *title = [[[currentOption commonMetadata]
|
NSString *title = @"";
|
||||||
valueForKey:@"value"]
|
NSArray *values = [[currentOption commonMetadata] valueForKey:@"value"];
|
||||||
objectAtIndex:0];
|
if (values.count > 0) {
|
||||||
|
title = [values objectAtIndex:0];
|
||||||
|
}
|
||||||
|
NSString *language = [currentOption extendedLanguageTag] ? [currentOption extendedLanguageTag] : @"";
|
||||||
NSDictionary *textTrack = @{
|
NSDictionary *textTrack = @{
|
||||||
@"index": [NSNumber numberWithInt:i],
|
@"index": [NSNumber numberWithInt:i],
|
||||||
@"title": title,
|
@"title": title,
|
||||||
@"language": [currentOption extendedLanguageTag]
|
@"language": language
|
||||||
};
|
};
|
||||||
[textTracks addObject:textTrack];
|
[textTracks addObject:textTrack];
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user