Upgrade to ExoPlayer 2.8.2
This commit is contained in:
parent
f0ee821225
commit
40cafdcb2e
@ -5,7 +5,10 @@ A `<Video>` component for react-native, as seen in
|
||||
|
||||
Requires react-native >= 0.40.0, for RN support of 0.19.0 - 0.39.0 please use a pre 1.0 version.
|
||||
|
||||
### Version 3.0 breaking changes
|
||||
### Version 4.0.0 breaking changes
|
||||
Version 4.0 now requires Android SDK 26 or higher to use ExoPlayer. This is the default version as of React Native 0.56 and will be required by Google for all apps in October 2018.
|
||||
|
||||
### Version 3.0.0 breaking changes
|
||||
Version 3.0 features a number of changes to existing behavior. See [Updating](#updating) for changes.
|
||||
|
||||
## TOC
|
||||
|
@ -19,9 +19,18 @@ android {
|
||||
dependencies {
|
||||
//noinspection GradleDynamicVersion
|
||||
provided "com.facebook.react:react-native:${safeExtGet('reactNativeVersion', '+')}"
|
||||
compile 'com.google.android.exoplayer:exoplayer:2.8.2'
|
||||
compile('com.google.android.exoplayer:exoplayer:2.8.2') {
|
||||
exclude group: 'com.android.support'
|
||||
}
|
||||
|
||||
// All support libs must use the same version
|
||||
compile "com.android.support:support-annotations:${safeExtGet('supportLibVersion', '+')}"
|
||||
compile "com.android.support:support-compat:${safeExtGet('supportLibVersion', '+')}"
|
||||
compile "com.android.support:support-media-compat:${safeExtGet('supportLibVersion', '+')}"
|
||||
|
||||
compile('com.google.android.exoplayer:extension-okhttp:2.8.2') {
|
||||
exclude group: 'com.squareup.okhttp3', module: 'okhttp'
|
||||
}
|
||||
compile 'com.squareup.okhttp3:okhttp:3.9.1'
|
||||
compile 'com.squareup.okhttp3:okhttp:3.11.0'
|
||||
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ class ReactExoplayerView extends FrameLayout implements
|
||||
|
||||
private DataSource.Factory mediaDataSourceFactory;
|
||||
private SimpleExoPlayer player;
|
||||
private MappingTrackSelector trackSelector;
|
||||
private DefaultTrackSelector trackSelector;
|
||||
private boolean playerNeedsSource;
|
||||
|
||||
private int resumeWindow;
|
||||
@ -533,12 +533,12 @@ class ReactExoplayerView extends FrameLayout implements
|
||||
TrackGroupArray groups = info.getTrackGroups(index);
|
||||
for (int i = 0; i < groups.length; ++i) {
|
||||
Format format = groups.get(i).getFormat(0);
|
||||
WritableMap textTrack = Arguments.createMap();
|
||||
textTrack.putInt("index", i);
|
||||
textTrack.putString("title", format.id != null ? format.id : "");
|
||||
textTrack.putString("type", format.sampleMimeType);
|
||||
textTrack.putString("language", format.language != null ? format.language : "");
|
||||
audioTracks.pushMap(textTrack);
|
||||
WritableMap audioTrack = Arguments.createMap();
|
||||
audioTrack.putInt("index", i);
|
||||
audioTrack.putString("title", format.id != null ? format.id : "");
|
||||
audioTrack.putString("type", format.sampleMimeType);
|
||||
audioTrack.putString("language", format.language != null ? format.language : "");
|
||||
audioTracks.pushMap(audioTrack);
|
||||
}
|
||||
return audioTracks;
|
||||
}
|
||||
@ -774,8 +774,13 @@ class ReactExoplayerView extends FrameLayout implements
|
||||
type = "default";
|
||||
}
|
||||
|
||||
DefaultTrackSelector.Parameters disableParameters = trackSelector.getParameters()
|
||||
.buildUpon()
|
||||
.setRendererDisabled(rendererIndex, true)
|
||||
.build();
|
||||
|
||||
if (type.equals("disabled")) {
|
||||
trackSelector.setSelectionOverride(rendererIndex, groups, null);
|
||||
trackSelector.setParameters(disableParameters);
|
||||
return;
|
||||
} else if (type.equals("language")) {
|
||||
for (int i = 0; i < groups.length; ++i) {
|
||||
@ -798,32 +803,30 @@ class ReactExoplayerView extends FrameLayout implements
|
||||
trackIndex = value.asInt();
|
||||
}
|
||||
} else { // default
|
||||
if (rendererIndex == C.TRACK_TYPE_TEXT) { // Use system settings if possible
|
||||
int sdk = android.os.Build.VERSION.SDK_INT;
|
||||
if (sdk > 18 && groups.length > 0) {
|
||||
if (rendererIndex == C.TRACK_TYPE_TEXT && Util.SDK_INT > 18 && groups.length > 0) {
|
||||
// Use system settings if possible
|
||||
CaptioningManager captioningManager
|
||||
= (CaptioningManager)themedReactContext.getSystemService(Context.CAPTIONING_SERVICE);
|
||||
if (captioningManager != null && captioningManager.isEnabled()) {
|
||||
trackIndex = getTrackIndexForDefaultLocale(groups);
|
||||
}
|
||||
} else {
|
||||
trackSelector.setSelectionOverride(rendererIndex, groups, null);
|
||||
return;
|
||||
}
|
||||
} else if (rendererIndex == C.TRACK_TYPE_AUDIO) {
|
||||
trackIndex = getTrackIndexForDefaultLocale(groups);
|
||||
}
|
||||
}
|
||||
|
||||
if (trackIndex == C.INDEX_UNSET) {
|
||||
trackSelector.clearSelectionOverrides(trackIndex);
|
||||
trackSelector.setParameters(disableParameters);
|
||||
return;
|
||||
}
|
||||
|
||||
MappingTrackSelector.SelectionOverride override
|
||||
= new MappingTrackSelector.SelectionOverride(
|
||||
new FixedTrackSelection.Factory(), trackIndex, 0);
|
||||
trackSelector.setSelectionOverride(rendererIndex, groups, override);
|
||||
DefaultTrackSelector.Parameters selectionParameters = trackSelector.getParameters()
|
||||
.buildUpon()
|
||||
.setRendererDisabled(rendererIndex, false)
|
||||
.setSelectionOverride(rendererIndex, groups,
|
||||
new DefaultTrackSelector.SelectionOverride(trackIndex, 0))
|
||||
.build();
|
||||
trackSelector.setParameters(selectionParameters);
|
||||
}
|
||||
|
||||
private int getTrackIndexForDefaultLocale(TrackGroupArray groups) {
|
||||
|
Loading…
Reference in New Issue
Block a user