mirror of
https://github.com/samsonjs/media.git
synced 2026-04-27 15:07:40 +00:00
Read media items from intent
PiperOrigin-RevId: 307442976
This commit is contained in:
parent
6a36574af3
commit
628234fd1f
4 changed files with 238 additions and 247 deletions
|
|
@ -0,0 +1,196 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2020 The Android Open Source Project
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.google.android.exoplayer2.demo;
|
||||||
|
|
||||||
|
import static com.google.android.exoplayer2.util.Assertions.checkNotNull;
|
||||||
|
|
||||||
|
import android.content.Intent;
|
||||||
|
import android.net.Uri;
|
||||||
|
import androidx.annotation.Nullable;
|
||||||
|
import com.google.android.exoplayer2.C;
|
||||||
|
import com.google.android.exoplayer2.MediaItem;
|
||||||
|
import com.google.android.exoplayer2.offline.DownloadRequest;
|
||||||
|
import com.google.android.exoplayer2.util.MimeTypes;
|
||||||
|
import com.google.android.exoplayer2.util.Util;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/** Util to read from an intent. */
|
||||||
|
public class IntentUtil {
|
||||||
|
|
||||||
|
// Actions.
|
||||||
|
|
||||||
|
public static final String ACTION_VIEW = "com.google.android.exoplayer.demo.action.VIEW";
|
||||||
|
public static final String ACTION_VIEW_LIST =
|
||||||
|
"com.google.android.exoplayer.demo.action.VIEW_LIST";
|
||||||
|
|
||||||
|
// Activity extras.
|
||||||
|
|
||||||
|
public static final String SPHERICAL_STEREO_MODE_EXTRA = "spherical_stereo_mode";
|
||||||
|
public static final String SPHERICAL_STEREO_MODE_MONO = "mono";
|
||||||
|
public static final String SPHERICAL_STEREO_MODE_TOP_BOTTOM = "top_bottom";
|
||||||
|
public static final String SPHERICAL_STEREO_MODE_LEFT_RIGHT = "left_right";
|
||||||
|
|
||||||
|
// Player configuration extras.
|
||||||
|
|
||||||
|
public static final String ABR_ALGORITHM_EXTRA = "abr_algorithm";
|
||||||
|
public static final String ABR_ALGORITHM_DEFAULT = "default";
|
||||||
|
public static final String ABR_ALGORITHM_RANDOM = "random";
|
||||||
|
|
||||||
|
// Media item configuration extras.
|
||||||
|
|
||||||
|
public static final String URI_EXTRA = "uri";
|
||||||
|
public static final String EXTENSION_EXTRA = "extension";
|
||||||
|
public static final String IS_LIVE_EXTRA = "is_live";
|
||||||
|
|
||||||
|
public static final String DRM_SCHEME_EXTRA = "drm_scheme";
|
||||||
|
public static final String DRM_LICENSE_URL_EXTRA = "drm_license_url";
|
||||||
|
public static final String DRM_KEY_REQUEST_PROPERTIES_EXTRA = "drm_key_request_properties";
|
||||||
|
public static final String DRM_SESSION_FOR_CLEAR_TYPES_EXTRA = "drm_session_for_clear_types";
|
||||||
|
public static final String DRM_MULTI_SESSION_EXTRA = "drm_multi_session";
|
||||||
|
public static final String AD_TAG_URI_EXTRA = "ad_tag_uri";
|
||||||
|
public static final String SUBTITLE_URI_EXTRA = "subtitle_uri";
|
||||||
|
public static final String SUBTITLE_MIME_TYPE_EXTRA = "subtitle_mime_type";
|
||||||
|
public static final String SUBTITLE_LANGUAGE_EXTRA = "subtitle_language";
|
||||||
|
// For backwards compatibility only.
|
||||||
|
public static final String DRM_SCHEME_UUID_EXTRA = "drm_scheme_uuid";
|
||||||
|
|
||||||
|
public static final String PREFER_EXTENSION_DECODERS_EXTRA = "prefer_extension_decoders";
|
||||||
|
public static final String TUNNELING_EXTRA = "tunneling";
|
||||||
|
|
||||||
|
/** Creates a list of {@link MediaItem media items} from an {@link Intent}. */
|
||||||
|
public static List<MediaItem> createMediaItemsFromIntent(
|
||||||
|
Intent intent, DownloadTracker downloadTracker) {
|
||||||
|
List<MediaItem> mediaItems = new ArrayList<>();
|
||||||
|
if (ACTION_VIEW_LIST.equals(intent.getAction())) {
|
||||||
|
int index = 0;
|
||||||
|
while (intent.hasExtra(URI_EXTRA + "_" + index)) {
|
||||||
|
Uri uri = Uri.parse(intent.getStringExtra(URI_EXTRA + "_" + index));
|
||||||
|
mediaItems.add(
|
||||||
|
createMediaItemFromIntent(
|
||||||
|
uri,
|
||||||
|
intent,
|
||||||
|
/* extrasKeySuffix= */ "_" + index,
|
||||||
|
downloadTracker.getDownloadRequest(uri)));
|
||||||
|
index++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Uri uri = intent.getData();
|
||||||
|
mediaItems.add(
|
||||||
|
createMediaItemFromIntent(
|
||||||
|
uri, intent, /* extrasKeySuffix= */ "", downloadTracker.getDownloadRequest(uri)));
|
||||||
|
}
|
||||||
|
return mediaItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static MediaItem createMediaItemFromIntent(
|
||||||
|
Uri uri, Intent intent, String extrasKeySuffix, @Nullable DownloadRequest downloadRequest) {
|
||||||
|
String extension = intent.getStringExtra(EXTENSION_EXTRA + extrasKeySuffix);
|
||||||
|
MediaItem.Builder builder =
|
||||||
|
new MediaItem.Builder()
|
||||||
|
.setSourceUri(uri)
|
||||||
|
.setStreamKeys(downloadRequest != null ? downloadRequest.streamKeys : null)
|
||||||
|
.setCustomCacheKey(downloadRequest != null ? downloadRequest.customCacheKey : null)
|
||||||
|
.setMimeType(inferAdaptiveStreamMimeType(uri, extension))
|
||||||
|
.setAdTagUri(intent.getStringExtra(AD_TAG_URI_EXTRA + extrasKeySuffix))
|
||||||
|
.setSubtitles(createSubtitlesFromIntent(intent, extrasKeySuffix));
|
||||||
|
return populateDrmPropertiesFromIntent(builder, intent, extrasKeySuffix).build();
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<MediaItem.Subtitle> createSubtitlesFromIntent(
|
||||||
|
Intent intent, String extrasKeySuffix) {
|
||||||
|
if (!intent.hasExtra(SUBTITLE_URI_EXTRA + extrasKeySuffix)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
return Collections.singletonList(
|
||||||
|
new MediaItem.Subtitle(
|
||||||
|
Uri.parse(intent.getStringExtra(SUBTITLE_URI_EXTRA + extrasKeySuffix)),
|
||||||
|
checkNotNull(intent.getStringExtra(SUBTITLE_MIME_TYPE_EXTRA + extrasKeySuffix)),
|
||||||
|
intent.getStringExtra(SUBTITLE_LANGUAGE_EXTRA + extrasKeySuffix),
|
||||||
|
C.SELECTION_FLAG_DEFAULT));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static MediaItem.Builder populateDrmPropertiesFromIntent(
|
||||||
|
MediaItem.Builder builder, Intent intent, String extrasKeySuffix) {
|
||||||
|
String schemeKey = DRM_SCHEME_EXTRA + extrasKeySuffix;
|
||||||
|
String schemeUuidKey = DRM_SCHEME_UUID_EXTRA + extrasKeySuffix;
|
||||||
|
if (!intent.hasExtra(schemeKey) && !intent.hasExtra(schemeUuidKey)) {
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
String drmSchemeExtra =
|
||||||
|
intent.hasExtra(schemeKey)
|
||||||
|
? intent.getStringExtra(schemeKey)
|
||||||
|
: intent.getStringExtra(schemeUuidKey);
|
||||||
|
String[] drmSessionForClearTypesExtra =
|
||||||
|
intent.getStringArrayExtra(DRM_SESSION_FOR_CLEAR_TYPES_EXTRA + extrasKeySuffix);
|
||||||
|
Map<String, String> headers = new HashMap<>();
|
||||||
|
String[] keyRequestPropertiesArray =
|
||||||
|
intent.getStringArrayExtra(DRM_KEY_REQUEST_PROPERTIES_EXTRA + extrasKeySuffix);
|
||||||
|
if (keyRequestPropertiesArray != null) {
|
||||||
|
for (int i = 0; i < keyRequestPropertiesArray.length; i += 2) {
|
||||||
|
headers.put(keyRequestPropertiesArray[i], keyRequestPropertiesArray[i + 1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
builder
|
||||||
|
.setDrmUuid(Util.getDrmUuid(Util.castNonNull(drmSchemeExtra)))
|
||||||
|
.setDrmLicenseUri(intent.getStringExtra(DRM_LICENSE_URL_EXTRA + extrasKeySuffix))
|
||||||
|
.setDrmSessionForClearTypes(toTrackTypeList(drmSessionForClearTypesExtra))
|
||||||
|
.setDrmMultiSession(
|
||||||
|
intent.getBooleanExtra(DRM_MULTI_SESSION_EXTRA + extrasKeySuffix, false))
|
||||||
|
.setDrmLicenseRequestHeaders(headers);
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static List<Integer> toTrackTypeList(@Nullable String[] trackTypeStringsArray) {
|
||||||
|
if (trackTypeStringsArray == null) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
HashSet<Integer> trackTypes = new HashSet<>();
|
||||||
|
for (String trackTypeString : trackTypeStringsArray) {
|
||||||
|
switch (Util.toLowerInvariant(trackTypeString)) {
|
||||||
|
case "audio":
|
||||||
|
trackTypes.add(C.TRACK_TYPE_AUDIO);
|
||||||
|
break;
|
||||||
|
case "video":
|
||||||
|
trackTypes.add(C.TRACK_TYPE_VIDEO);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new IllegalArgumentException("Invalid track type: " + trackTypeString);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return new ArrayList<>(trackTypes);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Nullable
|
||||||
|
private static String inferAdaptiveStreamMimeType(Uri uri, @Nullable String extension) {
|
||||||
|
@C.ContentType int contentType = Util.inferContentType(uri, extension);
|
||||||
|
switch (contentType) {
|
||||||
|
case C.TYPE_DASH:
|
||||||
|
return MimeTypes.APPLICATION_MPD;
|
||||||
|
case C.TYPE_HLS:
|
||||||
|
return MimeTypes.APPLICATION_M3U8;
|
||||||
|
case C.TYPE_SS:
|
||||||
|
return MimeTypes.APPLICATION_SS;
|
||||||
|
case C.TYPE_OTHER:
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -39,10 +39,8 @@ import com.google.android.exoplayer2.Player;
|
||||||
import com.google.android.exoplayer2.RenderersFactory;
|
import com.google.android.exoplayer2.RenderersFactory;
|
||||||
import com.google.android.exoplayer2.SimpleExoPlayer;
|
import com.google.android.exoplayer2.SimpleExoPlayer;
|
||||||
import com.google.android.exoplayer2.audio.AudioAttributes;
|
import com.google.android.exoplayer2.audio.AudioAttributes;
|
||||||
import com.google.android.exoplayer2.demo.Sample.UriSample;
|
|
||||||
import com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.DecoderInitializationException;
|
import com.google.android.exoplayer2.mediacodec.MediaCodecRenderer.DecoderInitializationException;
|
||||||
import com.google.android.exoplayer2.mediacodec.MediaCodecUtil.DecoderQueryException;
|
import com.google.android.exoplayer2.mediacodec.MediaCodecUtil.DecoderQueryException;
|
||||||
import com.google.android.exoplayer2.offline.DownloadRequest;
|
|
||||||
import com.google.android.exoplayer2.source.BehindLiveWindowException;
|
import com.google.android.exoplayer2.source.BehindLiveWindowException;
|
||||||
import com.google.android.exoplayer2.source.DefaultMediaSourceFactory;
|
import com.google.android.exoplayer2.source.DefaultMediaSourceFactory;
|
||||||
import com.google.android.exoplayer2.source.TrackGroupArray;
|
import com.google.android.exoplayer2.source.TrackGroupArray;
|
||||||
|
|
@ -66,7 +64,6 @@ import java.lang.reflect.Constructor;
|
||||||
import java.net.CookieHandler;
|
import java.net.CookieHandler;
|
||||||
import java.net.CookieManager;
|
import java.net.CookieManager;
|
||||||
import java.net.CookiePolicy;
|
import java.net.CookiePolicy;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|
@ -74,45 +71,6 @@ import java.util.List;
|
||||||
public class PlayerActivity extends AppCompatActivity
|
public class PlayerActivity extends AppCompatActivity
|
||||||
implements OnClickListener, PlaybackPreparer, PlayerControlView.VisibilityListener {
|
implements OnClickListener, PlaybackPreparer, PlayerControlView.VisibilityListener {
|
||||||
|
|
||||||
// Activity extras.
|
|
||||||
|
|
||||||
public static final String SPHERICAL_STEREO_MODE_EXTRA = "spherical_stereo_mode";
|
|
||||||
public static final String SPHERICAL_STEREO_MODE_MONO = "mono";
|
|
||||||
public static final String SPHERICAL_STEREO_MODE_TOP_BOTTOM = "top_bottom";
|
|
||||||
public static final String SPHERICAL_STEREO_MODE_LEFT_RIGHT = "left_right";
|
|
||||||
|
|
||||||
// Actions.
|
|
||||||
|
|
||||||
public static final String ACTION_VIEW = "com.google.android.exoplayer.demo.action.VIEW";
|
|
||||||
public static final String ACTION_VIEW_LIST =
|
|
||||||
"com.google.android.exoplayer.demo.action.VIEW_LIST";
|
|
||||||
|
|
||||||
// Player configuration extras.
|
|
||||||
|
|
||||||
public static final String ABR_ALGORITHM_EXTRA = "abr_algorithm";
|
|
||||||
public static final String ABR_ALGORITHM_DEFAULT = "default";
|
|
||||||
public static final String ABR_ALGORITHM_RANDOM = "random";
|
|
||||||
|
|
||||||
// Media item configuration extras.
|
|
||||||
|
|
||||||
public static final String URI_EXTRA = "uri";
|
|
||||||
public static final String EXTENSION_EXTRA = "extension";
|
|
||||||
public static final String IS_LIVE_EXTRA = "is_live";
|
|
||||||
|
|
||||||
public static final String DRM_SCHEME_EXTRA = "drm_scheme";
|
|
||||||
public static final String DRM_LICENSE_URL_EXTRA = "drm_license_url";
|
|
||||||
public static final String DRM_KEY_REQUEST_PROPERTIES_EXTRA = "drm_key_request_properties";
|
|
||||||
public static final String DRM_SESSION_FOR_CLEAR_TYPES_EXTRA = "drm_session_for_clear_types";
|
|
||||||
public static final String DRM_MULTI_SESSION_EXTRA = "drm_multi_session";
|
|
||||||
public static final String PREFER_EXTENSION_DECODERS_EXTRA = "prefer_extension_decoders";
|
|
||||||
public static final String TUNNELING_EXTRA = "tunneling";
|
|
||||||
public static final String AD_TAG_URI_EXTRA = "ad_tag_uri";
|
|
||||||
public static final String SUBTITLE_URI_EXTRA = "subtitle_uri";
|
|
||||||
public static final String SUBTITLE_MIME_TYPE_EXTRA = "subtitle_mime_type";
|
|
||||||
public static final String SUBTITLE_LANGUAGE_EXTRA = "subtitle_language";
|
|
||||||
// For backwards compatibility only.
|
|
||||||
public static final String DRM_SCHEME_UUID_EXTRA = "drm_scheme_uuid";
|
|
||||||
|
|
||||||
// Saved instance state keys.
|
// Saved instance state keys.
|
||||||
|
|
||||||
private static final String KEY_TRACK_SELECTOR_PARAMETERS = "track_selector_parameters";
|
private static final String KEY_TRACK_SELECTOR_PARAMETERS = "track_selector_parameters";
|
||||||
|
|
@ -154,7 +112,7 @@ public class PlayerActivity extends AppCompatActivity
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
String sphericalStereoMode = intent.getStringExtra(SPHERICAL_STEREO_MODE_EXTRA);
|
String sphericalStereoMode = intent.getStringExtra(IntentUtil.SPHERICAL_STEREO_MODE_EXTRA);
|
||||||
if (sphericalStereoMode != null) {
|
if (sphericalStereoMode != null) {
|
||||||
setTheme(R.style.PlayerTheme_Spherical);
|
setTheme(R.style.PlayerTheme_Spherical);
|
||||||
}
|
}
|
||||||
|
|
@ -176,11 +134,11 @@ public class PlayerActivity extends AppCompatActivity
|
||||||
playerView.requestFocus();
|
playerView.requestFocus();
|
||||||
if (sphericalStereoMode != null) {
|
if (sphericalStereoMode != null) {
|
||||||
int stereoMode;
|
int stereoMode;
|
||||||
if (SPHERICAL_STEREO_MODE_MONO.equals(sphericalStereoMode)) {
|
if (IntentUtil.SPHERICAL_STEREO_MODE_MONO.equals(sphericalStereoMode)) {
|
||||||
stereoMode = C.STEREO_MODE_MONO;
|
stereoMode = C.STEREO_MODE_MONO;
|
||||||
} else if (SPHERICAL_STEREO_MODE_TOP_BOTTOM.equals(sphericalStereoMode)) {
|
} else if (IntentUtil.SPHERICAL_STEREO_MODE_TOP_BOTTOM.equals(sphericalStereoMode)) {
|
||||||
stereoMode = C.STEREO_MODE_TOP_BOTTOM;
|
stereoMode = C.STEREO_MODE_TOP_BOTTOM;
|
||||||
} else if (SPHERICAL_STEREO_MODE_LEFT_RIGHT.equals(sphericalStereoMode)) {
|
} else if (IntentUtil.SPHERICAL_STEREO_MODE_LEFT_RIGHT.equals(sphericalStereoMode)) {
|
||||||
stereoMode = C.STEREO_MODE_LEFT_RIGHT;
|
stereoMode = C.STEREO_MODE_LEFT_RIGHT;
|
||||||
} else {
|
} else {
|
||||||
showToast(R.string.error_unrecognized_stereo_mode);
|
showToast(R.string.error_unrecognized_stereo_mode);
|
||||||
|
|
@ -198,7 +156,7 @@ public class PlayerActivity extends AppCompatActivity
|
||||||
} else {
|
} else {
|
||||||
DefaultTrackSelector.ParametersBuilder builder =
|
DefaultTrackSelector.ParametersBuilder builder =
|
||||||
new DefaultTrackSelector.ParametersBuilder(/* context= */ this);
|
new DefaultTrackSelector.ParametersBuilder(/* context= */ this);
|
||||||
boolean tunneling = intent.getBooleanExtra(TUNNELING_EXTRA, false);
|
boolean tunneling = intent.getBooleanExtra(IntentUtil.TUNNELING_EXTRA, false);
|
||||||
if (Util.SDK_INT >= 21 && tunneling) {
|
if (Util.SDK_INT >= 21 && tunneling) {
|
||||||
builder.setTunnelingAudioSessionId(C.generateAudioSessionIdV21(/* context= */ this));
|
builder.setTunnelingAudioSessionId(C.generateAudioSessionIdV21(/* context= */ this));
|
||||||
}
|
}
|
||||||
|
|
@ -337,15 +295,17 @@ public class PlayerActivity extends AppCompatActivity
|
||||||
private void initializePlayer() {
|
private void initializePlayer() {
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
Intent intent = getIntent();
|
Intent intent = getIntent();
|
||||||
|
|
||||||
mediaItems = createMediaItems(intent);
|
mediaItems = createMediaItems(intent);
|
||||||
if (mediaItems.isEmpty()) {
|
if (mediaItems.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
TrackSelection.Factory trackSelectionFactory;
|
TrackSelection.Factory trackSelectionFactory;
|
||||||
String abrAlgorithm = intent.getStringExtra(ABR_ALGORITHM_EXTRA);
|
String abrAlgorithm = intent.getStringExtra(IntentUtil.ABR_ALGORITHM_EXTRA);
|
||||||
if (abrAlgorithm == null || ABR_ALGORITHM_DEFAULT.equals(abrAlgorithm)) {
|
if (abrAlgorithm == null || IntentUtil.ABR_ALGORITHM_DEFAULT.equals(abrAlgorithm)) {
|
||||||
trackSelectionFactory = new AdaptiveTrackSelection.Factory();
|
trackSelectionFactory = new AdaptiveTrackSelection.Factory();
|
||||||
} else if (ABR_ALGORITHM_RANDOM.equals(abrAlgorithm)) {
|
} else if (IntentUtil.ABR_ALGORITHM_RANDOM.equals(abrAlgorithm)) {
|
||||||
trackSelectionFactory = new RandomTrackSelection.Factory();
|
trackSelectionFactory = new RandomTrackSelection.Factory();
|
||||||
} else {
|
} else {
|
||||||
showToast(R.string.error_unrecognized_abr_algorithm);
|
showToast(R.string.error_unrecognized_abr_algorithm);
|
||||||
|
|
@ -354,7 +314,7 @@ public class PlayerActivity extends AppCompatActivity
|
||||||
}
|
}
|
||||||
|
|
||||||
boolean preferExtensionDecoders =
|
boolean preferExtensionDecoders =
|
||||||
intent.getBooleanExtra(PREFER_EXTENSION_DECODERS_EXTRA, false);
|
intent.getBooleanExtra(IntentUtil.PREFER_EXTENSION_DECODERS_EXTRA, false);
|
||||||
RenderersFactory renderersFactory =
|
RenderersFactory renderersFactory =
|
||||||
((DemoApplication) getApplication()).buildRenderersFactory(preferExtensionDecoders);
|
((DemoApplication) getApplication()).buildRenderersFactory(preferExtensionDecoders);
|
||||||
|
|
||||||
|
|
@ -389,35 +349,19 @@ public class PlayerActivity extends AppCompatActivity
|
||||||
|
|
||||||
private List<MediaItem> createMediaItems(Intent intent) {
|
private List<MediaItem> createMediaItems(Intent intent) {
|
||||||
String action = intent.getAction();
|
String action = intent.getAction();
|
||||||
boolean actionIsListView = ACTION_VIEW_LIST.equals(action);
|
boolean actionIsListView = IntentUtil.ACTION_VIEW_LIST.equals(action);
|
||||||
if (!actionIsListView && !ACTION_VIEW.equals(action)) {
|
if (!actionIsListView && !IntentUtil.ACTION_VIEW.equals(action)) {
|
||||||
showToast(getString(R.string.unexpected_intent_action, action));
|
showToast(getString(R.string.unexpected_intent_action, action));
|
||||||
finish();
|
finish();
|
||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
|
|
||||||
Sample intentAsSample = Sample.createFromIntent(intent);
|
List<MediaItem> mediaItems =
|
||||||
UriSample[] samples =
|
IntentUtil.createMediaItemsFromIntent(
|
||||||
intentAsSample instanceof Sample.PlaylistSample
|
intent, ((DemoApplication) getApplication()).getDownloadTracker());
|
||||||
? ((Sample.PlaylistSample) intentAsSample).children
|
|
||||||
: new UriSample[] {(UriSample) intentAsSample};
|
|
||||||
|
|
||||||
List<MediaItem> mediaItems = new ArrayList<>();
|
|
||||||
boolean hasAds = false;
|
boolean hasAds = false;
|
||||||
for (UriSample sample : samples) {
|
for (int i = 0; i < mediaItems.size(); i++) {
|
||||||
MediaItem mediaItem = sample.toMediaItem();
|
MediaItem mediaItem = mediaItems.get(i);
|
||||||
DownloadRequest downloadRequest =
|
|
||||||
((DemoApplication) getApplication())
|
|
||||||
.getDownloadTracker()
|
|
||||||
.getDownloadRequest(Assertions.checkNotNull(mediaItem.playbackProperties).sourceUri);
|
|
||||||
if (downloadRequest != null) {
|
|
||||||
mediaItem =
|
|
||||||
mediaItem
|
|
||||||
.buildUpon()
|
|
||||||
.setStreamKeys(downloadRequest.streamKeys)
|
|
||||||
.setCustomCacheKey(downloadRequest.customCacheKey)
|
|
||||||
.build();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!Util.checkCleartextTrafficPermitted(mediaItem)) {
|
if (!Util.checkCleartextTrafficPermitted(mediaItem)) {
|
||||||
showToast(R.string.error_cleartext_not_permitted);
|
showToast(R.string.error_cleartext_not_permitted);
|
||||||
|
|
@ -442,7 +386,6 @@ public class PlayerActivity extends AppCompatActivity
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
hasAds |= mediaItem.playbackProperties.adTagUri != null;
|
hasAds |= mediaItem.playbackProperties.adTagUri != null;
|
||||||
mediaItems.add(mediaItem);
|
|
||||||
}
|
}
|
||||||
if (!hasAds) {
|
if (!hasAds) {
|
||||||
releaseAdsLoader();
|
releaseAdsLoader();
|
||||||
|
|
|
||||||
|
|
@ -15,82 +15,20 @@
|
||||||
*/
|
*/
|
||||||
package com.google.android.exoplayer2.demo;
|
package com.google.android.exoplayer2.demo;
|
||||||
|
|
||||||
import static com.google.android.exoplayer2.demo.PlayerActivity.ACTION_VIEW_LIST;
|
|
||||||
import static com.google.android.exoplayer2.demo.PlayerActivity.AD_TAG_URI_EXTRA;
|
|
||||||
import static com.google.android.exoplayer2.demo.PlayerActivity.DRM_KEY_REQUEST_PROPERTIES_EXTRA;
|
|
||||||
import static com.google.android.exoplayer2.demo.PlayerActivity.DRM_LICENSE_URL_EXTRA;
|
|
||||||
import static com.google.android.exoplayer2.demo.PlayerActivity.DRM_MULTI_SESSION_EXTRA;
|
|
||||||
import static com.google.android.exoplayer2.demo.PlayerActivity.DRM_SCHEME_EXTRA;
|
|
||||||
import static com.google.android.exoplayer2.demo.PlayerActivity.DRM_SCHEME_UUID_EXTRA;
|
|
||||||
import static com.google.android.exoplayer2.demo.PlayerActivity.DRM_SESSION_FOR_CLEAR_TYPES_EXTRA;
|
|
||||||
import static com.google.android.exoplayer2.demo.PlayerActivity.EXTENSION_EXTRA;
|
|
||||||
import static com.google.android.exoplayer2.demo.PlayerActivity.IS_LIVE_EXTRA;
|
|
||||||
import static com.google.android.exoplayer2.demo.PlayerActivity.SUBTITLE_LANGUAGE_EXTRA;
|
|
||||||
import static com.google.android.exoplayer2.demo.PlayerActivity.SUBTITLE_MIME_TYPE_EXTRA;
|
|
||||||
import static com.google.android.exoplayer2.demo.PlayerActivity.SUBTITLE_URI_EXTRA;
|
|
||||||
import static com.google.android.exoplayer2.demo.PlayerActivity.URI_EXTRA;
|
|
||||||
|
|
||||||
import android.content.Intent;
|
import android.content.Intent;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import androidx.annotation.Nullable;
|
import androidx.annotation.Nullable;
|
||||||
import com.google.android.exoplayer2.C;
|
import com.google.android.exoplayer2.C;
|
||||||
import com.google.android.exoplayer2.MediaItem;
|
|
||||||
import com.google.android.exoplayer2.util.Assertions;
|
import com.google.android.exoplayer2.util.Assertions;
|
||||||
import com.google.android.exoplayer2.util.MimeTypes;
|
|
||||||
import com.google.android.exoplayer2.util.Util;
|
import com.google.android.exoplayer2.util.Util;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
/* package */ abstract class Sample {
|
/* package */ abstract class Sample {
|
||||||
|
|
||||||
/**
|
|
||||||
* Returns the mime type which is one of {@link MimeTypes#APPLICATION_MPD} for DASH, {@link
|
|
||||||
* MimeTypes#APPLICATION_M3U8} for HLS, {@link MimeTypes#APPLICATION_SS} for SmoothStreaming or
|
|
||||||
* {@code null} for all other streams.
|
|
||||||
*
|
|
||||||
* @param uri The uri of the stream.
|
|
||||||
* @param extension The extension
|
|
||||||
* @return The adaptive mime type or {@code null} for non-adaptive streams.
|
|
||||||
*/
|
|
||||||
@Nullable
|
|
||||||
public static String inferAdaptiveStreamMimeType(Uri uri, @Nullable String extension) {
|
|
||||||
@C.ContentType int contentType = Util.inferContentType(uri, extension);
|
|
||||||
switch (contentType) {
|
|
||||||
case C.TYPE_DASH:
|
|
||||||
return MimeTypes.APPLICATION_MPD;
|
|
||||||
case C.TYPE_HLS:
|
|
||||||
return MimeTypes.APPLICATION_M3U8;
|
|
||||||
case C.TYPE_SS:
|
|
||||||
return MimeTypes.APPLICATION_SS;
|
|
||||||
case C.TYPE_OTHER:
|
|
||||||
default:
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static final class UriSample extends Sample {
|
public static final class UriSample extends Sample {
|
||||||
|
|
||||||
public static UriSample createFromIntent(Uri uri, Intent intent, String extrasKeySuffix) {
|
|
||||||
String extension = intent.getStringExtra(EXTENSION_EXTRA + extrasKeySuffix);
|
|
||||||
String adsTagUriString = intent.getStringExtra(AD_TAG_URI_EXTRA + extrasKeySuffix);
|
|
||||||
boolean isLive =
|
|
||||||
intent.getBooleanExtra(IS_LIVE_EXTRA + extrasKeySuffix, /* defaultValue= */ false);
|
|
||||||
Uri adTagUri = adsTagUriString != null ? Uri.parse(adsTagUriString) : null;
|
|
||||||
return new UriSample(
|
|
||||||
/* name= */ null,
|
|
||||||
uri,
|
|
||||||
extension,
|
|
||||||
isLive,
|
|
||||||
DrmInfo.createFromIntent(intent, extrasKeySuffix),
|
|
||||||
adTagUri,
|
|
||||||
/* sphericalStereoMode= */ null,
|
|
||||||
SubtitleInfo.createFromIntent(intent, extrasKeySuffix));
|
|
||||||
}
|
|
||||||
|
|
||||||
public final Uri uri;
|
public final Uri uri;
|
||||||
public final String extension;
|
public final String extension;
|
||||||
public final boolean isLive;
|
public final boolean isLive;
|
||||||
|
|
@ -120,23 +58,24 @@ import java.util.UUID;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addToIntent(Intent intent) {
|
public void addToIntent(Intent intent) {
|
||||||
intent.setAction(PlayerActivity.ACTION_VIEW).setData(uri);
|
intent.setAction(IntentUtil.ACTION_VIEW).setData(uri);
|
||||||
intent.putExtra(PlayerActivity.IS_LIVE_EXTRA, isLive);
|
intent.putExtra(IntentUtil.IS_LIVE_EXTRA, isLive);
|
||||||
intent.putExtra(PlayerActivity.SPHERICAL_STEREO_MODE_EXTRA, sphericalStereoMode);
|
intent.putExtra(IntentUtil.SPHERICAL_STEREO_MODE_EXTRA, sphericalStereoMode);
|
||||||
addPlayerConfigToIntent(intent, /* extrasKeySuffix= */ "");
|
addPlayerConfigToIntent(intent, /* extrasKeySuffix= */ "");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addToPlaylistIntent(Intent intent, String extrasKeySuffix) {
|
public void addToPlaylistIntent(Intent intent, String extrasKeySuffix) {
|
||||||
intent.putExtra(PlayerActivity.URI_EXTRA + extrasKeySuffix, uri.toString());
|
intent.putExtra(IntentUtil.URI_EXTRA + extrasKeySuffix, uri.toString());
|
||||||
intent.putExtra(PlayerActivity.IS_LIVE_EXTRA + extrasKeySuffix, isLive);
|
intent.putExtra(IntentUtil.IS_LIVE_EXTRA + extrasKeySuffix, isLive);
|
||||||
addPlayerConfigToIntent(intent, extrasKeySuffix);
|
addPlayerConfigToIntent(intent, extrasKeySuffix);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addPlayerConfigToIntent(Intent intent, String extrasKeySuffix) {
|
private void addPlayerConfigToIntent(Intent intent, String extrasKeySuffix) {
|
||||||
intent
|
intent
|
||||||
.putExtra(EXTENSION_EXTRA + extrasKeySuffix, extension)
|
.putExtra(IntentUtil.EXTENSION_EXTRA + extrasKeySuffix, extension)
|
||||||
.putExtra(
|
.putExtra(
|
||||||
AD_TAG_URI_EXTRA + extrasKeySuffix, adTagUri != null ? adTagUri.toString() : null);
|
IntentUtil.AD_TAG_URI_EXTRA + extrasKeySuffix,
|
||||||
|
adTagUri != null ? adTagUri.toString() : null);
|
||||||
if (drmInfo != null) {
|
if (drmInfo != null) {
|
||||||
drmInfo.addToIntent(intent, extrasKeySuffix);
|
drmInfo.addToIntent(intent, extrasKeySuffix);
|
||||||
}
|
}
|
||||||
|
|
@ -144,38 +83,6 @@ import java.util.UUID;
|
||||||
subtitleInfo.addToIntent(intent, extrasKeySuffix);
|
subtitleInfo.addToIntent(intent, extrasKeySuffix);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public MediaItem toMediaItem() {
|
|
||||||
MediaItem.Builder builder =
|
|
||||||
new MediaItem.Builder()
|
|
||||||
.setSourceUri(uri)
|
|
||||||
.setMimeType(inferAdaptiveStreamMimeType(uri, extension))
|
|
||||||
.setAdTagUri(adTagUri);
|
|
||||||
if (drmInfo != null) {
|
|
||||||
Map<String, String> headers = new HashMap<>();
|
|
||||||
if (drmInfo.drmKeyRequestProperties != null) {
|
|
||||||
for (int i = 0; i < drmInfo.drmKeyRequestProperties.length; i += 2) {
|
|
||||||
headers.put(drmInfo.drmKeyRequestProperties[i], drmInfo.drmKeyRequestProperties[i + 1]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
builder
|
|
||||||
.setDrmLicenseUri(drmInfo.drmLicenseUrl)
|
|
||||||
.setDrmLicenseRequestHeaders(headers)
|
|
||||||
.setDrmUuid(drmInfo.drmScheme)
|
|
||||||
.setDrmMultiSession(drmInfo.drmMultiSession)
|
|
||||||
.setDrmSessionForClearTypes(Util.toList(drmInfo.drmSessionForClearTypes));
|
|
||||||
}
|
|
||||||
if (subtitleInfo != null) {
|
|
||||||
builder.setSubtitles(
|
|
||||||
Collections.singletonList(
|
|
||||||
new MediaItem.Subtitle(
|
|
||||||
subtitleInfo.uri,
|
|
||||||
subtitleInfo.mimeType,
|
|
||||||
subtitleInfo.language,
|
|
||||||
C.SELECTION_FLAG_DEFAULT)));
|
|
||||||
}
|
|
||||||
return builder.build();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class PlaylistSample extends Sample {
|
public static final class PlaylistSample extends Sample {
|
||||||
|
|
@ -189,7 +96,7 @@ import java.util.UUID;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void addToIntent(Intent intent) {
|
public void addToIntent(Intent intent) {
|
||||||
intent.setAction(PlayerActivity.ACTION_VIEW_LIST);
|
intent.setAction(IntentUtil.ACTION_VIEW_LIST);
|
||||||
for (int i = 0; i < children.length; i++) {
|
for (int i = 0; i < children.length; i++) {
|
||||||
children[i].addToPlaylistIntent(intent, /* extrasKeySuffix= */ "_" + i);
|
children[i].addToPlaylistIntent(intent, /* extrasKeySuffix= */ "_" + i);
|
||||||
}
|
}
|
||||||
|
|
@ -198,33 +105,6 @@ import java.util.UUID;
|
||||||
|
|
||||||
public static final class DrmInfo {
|
public static final class DrmInfo {
|
||||||
|
|
||||||
public static DrmInfo createFromIntent(Intent intent, String extrasKeySuffix) {
|
|
||||||
String schemeKey = DRM_SCHEME_EXTRA + extrasKeySuffix;
|
|
||||||
String schemeUuidKey = DRM_SCHEME_UUID_EXTRA + extrasKeySuffix;
|
|
||||||
if (!intent.hasExtra(schemeKey) && !intent.hasExtra(schemeUuidKey)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
String drmSchemeExtra =
|
|
||||||
intent.hasExtra(schemeKey)
|
|
||||||
? intent.getStringExtra(schemeKey)
|
|
||||||
: intent.getStringExtra(schemeUuidKey);
|
|
||||||
UUID drmScheme = Util.getDrmUuid(drmSchemeExtra);
|
|
||||||
String drmLicenseUrl = intent.getStringExtra(DRM_LICENSE_URL_EXTRA + extrasKeySuffix);
|
|
||||||
String[] keyRequestPropertiesArray =
|
|
||||||
intent.getStringArrayExtra(DRM_KEY_REQUEST_PROPERTIES_EXTRA + extrasKeySuffix);
|
|
||||||
String[] drmSessionForClearTypesExtra =
|
|
||||||
intent.getStringArrayExtra(DRM_SESSION_FOR_CLEAR_TYPES_EXTRA + extrasKeySuffix);
|
|
||||||
int[] drmSessionForClearTypes = toTrackTypeArray(drmSessionForClearTypesExtra);
|
|
||||||
boolean drmMultiSession =
|
|
||||||
intent.getBooleanExtra(DRM_MULTI_SESSION_EXTRA + extrasKeySuffix, false);
|
|
||||||
return new DrmInfo(
|
|
||||||
drmScheme,
|
|
||||||
drmLicenseUrl,
|
|
||||||
keyRequestPropertiesArray,
|
|
||||||
drmSessionForClearTypes,
|
|
||||||
drmMultiSession);
|
|
||||||
}
|
|
||||||
|
|
||||||
public final UUID drmScheme;
|
public final UUID drmScheme;
|
||||||
public final String drmLicenseUrl;
|
public final String drmLicenseUrl;
|
||||||
public final String[] drmKeyRequestProperties;
|
public final String[] drmKeyRequestProperties;
|
||||||
|
|
@ -246,33 +126,24 @@ import java.util.UUID;
|
||||||
|
|
||||||
public void addToIntent(Intent intent, String extrasKeySuffix) {
|
public void addToIntent(Intent intent, String extrasKeySuffix) {
|
||||||
Assertions.checkNotNull(intent);
|
Assertions.checkNotNull(intent);
|
||||||
intent.putExtra(DRM_SCHEME_EXTRA + extrasKeySuffix, drmScheme.toString());
|
intent.putExtra(IntentUtil.DRM_SCHEME_EXTRA + extrasKeySuffix, drmScheme.toString());
|
||||||
intent.putExtra(DRM_LICENSE_URL_EXTRA + extrasKeySuffix, drmLicenseUrl);
|
intent.putExtra(IntentUtil.DRM_LICENSE_URL_EXTRA + extrasKeySuffix, drmLicenseUrl);
|
||||||
intent.putExtra(DRM_KEY_REQUEST_PROPERTIES_EXTRA + extrasKeySuffix, drmKeyRequestProperties);
|
intent.putExtra(
|
||||||
|
IntentUtil.DRM_KEY_REQUEST_PROPERTIES_EXTRA + extrasKeySuffix, drmKeyRequestProperties);
|
||||||
ArrayList<String> typeStrings = new ArrayList<>();
|
ArrayList<String> typeStrings = new ArrayList<>();
|
||||||
for (int type : drmSessionForClearTypes) {
|
for (int type : drmSessionForClearTypes) {
|
||||||
// Only audio and video are supported.
|
// Only audio and video are supported.
|
||||||
typeStrings.add(type == C.TRACK_TYPE_AUDIO ? "audio" : "video");
|
typeStrings.add(type == C.TRACK_TYPE_AUDIO ? "audio" : "video");
|
||||||
}
|
}
|
||||||
intent.putExtra(
|
intent.putExtra(
|
||||||
DRM_SESSION_FOR_CLEAR_TYPES_EXTRA + extrasKeySuffix, typeStrings.toArray(new String[0]));
|
IntentUtil.DRM_SESSION_FOR_CLEAR_TYPES_EXTRA + extrasKeySuffix,
|
||||||
intent.putExtra(DRM_MULTI_SESSION_EXTRA + extrasKeySuffix, drmMultiSession);
|
typeStrings.toArray(new String[0]));
|
||||||
|
intent.putExtra(IntentUtil.DRM_MULTI_SESSION_EXTRA + extrasKeySuffix, drmMultiSession);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final class SubtitleInfo {
|
public static final class SubtitleInfo {
|
||||||
|
|
||||||
@Nullable
|
|
||||||
public static SubtitleInfo createFromIntent(Intent intent, String extrasKeySuffix) {
|
|
||||||
if (!intent.hasExtra(SUBTITLE_URI_EXTRA + extrasKeySuffix)) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
return new SubtitleInfo(
|
|
||||||
Uri.parse(intent.getStringExtra(SUBTITLE_URI_EXTRA + extrasKeySuffix)),
|
|
||||||
intent.getStringExtra(SUBTITLE_MIME_TYPE_EXTRA + extrasKeySuffix),
|
|
||||||
intent.getStringExtra(SUBTITLE_LANGUAGE_EXTRA + extrasKeySuffix));
|
|
||||||
}
|
|
||||||
|
|
||||||
public final Uri uri;
|
public final Uri uri;
|
||||||
public final String mimeType;
|
public final String mimeType;
|
||||||
@Nullable public final String language;
|
@Nullable public final String language;
|
||||||
|
|
@ -284,9 +155,9 @@ import java.util.UUID;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addToIntent(Intent intent, String extrasKeySuffix) {
|
public void addToIntent(Intent intent, String extrasKeySuffix) {
|
||||||
intent.putExtra(SUBTITLE_URI_EXTRA + extrasKeySuffix, uri.toString());
|
intent.putExtra(IntentUtil.SUBTITLE_URI_EXTRA + extrasKeySuffix, uri.toString());
|
||||||
intent.putExtra(SUBTITLE_MIME_TYPE_EXTRA + extrasKeySuffix, mimeType);
|
intent.putExtra(IntentUtil.SUBTITLE_MIME_TYPE_EXTRA + extrasKeySuffix, mimeType);
|
||||||
intent.putExtra(SUBTITLE_LANGUAGE_EXTRA + extrasKeySuffix, language);
|
intent.putExtra(IntentUtil.SUBTITLE_LANGUAGE_EXTRA + extrasKeySuffix, language);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -310,25 +181,6 @@ import java.util.UUID;
|
||||||
return Util.toArray(new ArrayList<>(trackTypes));
|
return Util.toArray(new ArrayList<>(trackTypes));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Sample createFromIntent(Intent intent) {
|
|
||||||
if (ACTION_VIEW_LIST.equals(intent.getAction())) {
|
|
||||||
ArrayList<String> intentUris = new ArrayList<>();
|
|
||||||
int index = 0;
|
|
||||||
while (intent.hasExtra(URI_EXTRA + "_" + index)) {
|
|
||||||
intentUris.add(intent.getStringExtra(URI_EXTRA + "_" + index));
|
|
||||||
index++;
|
|
||||||
}
|
|
||||||
UriSample[] children = new UriSample[intentUris.size()];
|
|
||||||
for (int i = 0; i < children.length; i++) {
|
|
||||||
Uri uri = Uri.parse(intentUris.get(i));
|
|
||||||
children[i] = UriSample.createFromIntent(uri, intent, /* extrasKeySuffix= */ "_" + i);
|
|
||||||
}
|
|
||||||
return new PlaylistSample(/* name= */ null, children);
|
|
||||||
} else {
|
|
||||||
return UriSample.createFromIntent(intent.getData(), intent, /* extrasKeySuffix= */ "");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public final String name;
|
public final String name;
|
||||||
|
|
||||||
public Sample(String name) {
|
public Sample(String name) {
|
||||||
|
|
|
||||||
|
|
@ -230,14 +230,14 @@ public class SampleChooserActivity extends AppCompatActivity
|
||||||
Sample sample = (Sample) view.getTag();
|
Sample sample = (Sample) view.getTag();
|
||||||
Intent intent = new Intent(this, PlayerActivity.class);
|
Intent intent = new Intent(this, PlayerActivity.class);
|
||||||
intent.putExtra(
|
intent.putExtra(
|
||||||
PlayerActivity.PREFER_EXTENSION_DECODERS_EXTRA,
|
IntentUtil.PREFER_EXTENSION_DECODERS_EXTRA,
|
||||||
isNonNullAndChecked(preferExtensionDecodersMenuItem));
|
isNonNullAndChecked(preferExtensionDecodersMenuItem));
|
||||||
String abrAlgorithm =
|
String abrAlgorithm =
|
||||||
isNonNullAndChecked(randomAbrMenuItem)
|
isNonNullAndChecked(randomAbrMenuItem)
|
||||||
? PlayerActivity.ABR_ALGORITHM_RANDOM
|
? IntentUtil.ABR_ALGORITHM_RANDOM
|
||||||
: PlayerActivity.ABR_ALGORITHM_DEFAULT;
|
: IntentUtil.ABR_ALGORITHM_DEFAULT;
|
||||||
intent.putExtra(PlayerActivity.ABR_ALGORITHM_EXTRA, abrAlgorithm);
|
intent.putExtra(IntentUtil.ABR_ALGORITHM_EXTRA, abrAlgorithm);
|
||||||
intent.putExtra(PlayerActivity.TUNNELING_EXTRA, isNonNullAndChecked(tunnelingMenuItem));
|
intent.putExtra(IntentUtil.TUNNELING_EXTRA, isNonNullAndChecked(tunnelingMenuItem));
|
||||||
sample.addToIntent(intent);
|
sample.addToIntent(intent);
|
||||||
startActivity(intent);
|
startActivity(intent);
|
||||||
return true;
|
return true;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue