mirror of
https://github.com/androidx/media.git
synced 2025-05-13 02:29:52 +08:00
Move decoder and ABR preferences to overflow menu
------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=208977806
This commit is contained in:
parent
94c7fbbc24
commit
ab72dd44ed
@ -559,17 +559,6 @@
|
|||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"name": "ABR",
|
|
||||||
"samples": [
|
|
||||||
{
|
|
||||||
"name": "Random ABR - Google Glass (MP4,H264)",
|
|
||||||
"uri": "https://www.youtube.com/api/manifest/dash/id/bf5bb2419360daf1/source/youtube?as=fmp4_audio_clear,fmp4_sd_hd_clear&sparams=ip,ipbits,expire,source,id,as&ip=0.0.0.0&ipbits=0&expire=19000000000&signature=51AF5F39AB0CEC3E5497CD9C900EBFEAECCCB5C7.8506521BFC350652163895D4C26DEE124209AA9E&key=ik0",
|
|
||||||
"extension": "mpd",
|
|
||||||
"abr_algorithm": "random"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"name": "360",
|
"name": "360",
|
||||||
"samples": [
|
"samples": [
|
||||||
|
@ -107,8 +107,8 @@ public class PlayerActivity extends Activity
|
|||||||
public static final String AD_TAG_URI_EXTRA = "ad_tag_uri";
|
public static final String AD_TAG_URI_EXTRA = "ad_tag_uri";
|
||||||
|
|
||||||
public static final String ABR_ALGORITHM_EXTRA = "abr_algorithm";
|
public static final String ABR_ALGORITHM_EXTRA = "abr_algorithm";
|
||||||
private static final String ABR_ALGORITHM_DEFAULT = "default";
|
public static final String ABR_ALGORITHM_DEFAULT = "default";
|
||||||
private static final String ABR_ALGORITHM_RANDOM = "random";
|
public static final String ABR_ALGORITHM_RANDOM = "random";
|
||||||
|
|
||||||
public static final String SPHERICAL_STEREO_MODE_EXTRA = "spherical_stereo_mode";
|
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_MONO = "mono";
|
||||||
|
@ -24,6 +24,9 @@ import android.os.AsyncTask;
|
|||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.util.JsonReader;
|
import android.util.JsonReader;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
import android.view.Menu;
|
||||||
|
import android.view.MenuInflater;
|
||||||
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.View.OnClickListener;
|
import android.view.View.OnClickListener;
|
||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
@ -55,8 +58,11 @@ public class SampleChooserActivity extends Activity
|
|||||||
|
|
||||||
private static final String TAG = "SampleChooserActivity";
|
private static final String TAG = "SampleChooserActivity";
|
||||||
|
|
||||||
|
private boolean useExtensionRenderers;
|
||||||
private DownloadTracker downloadTracker;
|
private DownloadTracker downloadTracker;
|
||||||
private SampleAdapter sampleAdapter;
|
private SampleAdapter sampleAdapter;
|
||||||
|
private MenuItem preferExtensionDecodersMenuItem;
|
||||||
|
private MenuItem randomAbrMenuItem;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(Bundle savedInstanceState) {
|
||||||
@ -90,7 +96,9 @@ public class SampleChooserActivity extends Activity
|
|||||||
Arrays.sort(uris);
|
Arrays.sort(uris);
|
||||||
}
|
}
|
||||||
|
|
||||||
downloadTracker = ((DemoApplication) getApplication()).getDownloadTracker();
|
DemoApplication application = (DemoApplication) getApplication();
|
||||||
|
useExtensionRenderers = application.useExtensionRenderers();
|
||||||
|
downloadTracker = application.getDownloadTracker();
|
||||||
SampleListLoader loaderTask = new SampleListLoader();
|
SampleListLoader loaderTask = new SampleListLoader();
|
||||||
loaderTask.execute(uris);
|
loaderTask.execute(uris);
|
||||||
|
|
||||||
@ -105,6 +113,22 @@ public class SampleChooserActivity extends Activity
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCreateOptionsMenu(Menu menu) {
|
||||||
|
MenuInflater inflater = getMenuInflater();
|
||||||
|
inflater.inflate(R.menu.sample_chooser_menu, menu);
|
||||||
|
preferExtensionDecodersMenuItem = menu.findItem(R.id.prefer_extension_decoders);
|
||||||
|
preferExtensionDecodersMenuItem.setVisible(useExtensionRenderers);
|
||||||
|
randomAbrMenuItem = menu.findItem(R.id.random_abr);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onOptionsItemSelected(MenuItem item) {
|
||||||
|
item.setChecked(!item.isChecked());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
@ -135,7 +159,13 @@ public class SampleChooserActivity extends Activity
|
|||||||
public boolean onChildClick(
|
public boolean onChildClick(
|
||||||
ExpandableListView parent, View view, int groupPosition, int childPosition, long id) {
|
ExpandableListView parent, View view, int groupPosition, int childPosition, long id) {
|
||||||
Sample sample = (Sample) view.getTag();
|
Sample sample = (Sample) view.getTag();
|
||||||
startActivity(sample.buildIntent(this));
|
startActivity(
|
||||||
|
sample.buildIntent(
|
||||||
|
/* context= */ this,
|
||||||
|
preferExtensionDecodersMenuItem.isChecked(),
|
||||||
|
randomAbrMenuItem.isChecked()
|
||||||
|
? PlayerActivity.ABR_ALGORITHM_RANDOM
|
||||||
|
: PlayerActivity.ABR_ALGORITHM_DEFAULT));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -245,10 +275,8 @@ public class SampleChooserActivity extends Activity
|
|||||||
String drmLicenseUrl = null;
|
String drmLicenseUrl = null;
|
||||||
String[] drmKeyRequestProperties = null;
|
String[] drmKeyRequestProperties = null;
|
||||||
boolean drmMultiSession = false;
|
boolean drmMultiSession = false;
|
||||||
boolean preferExtensionDecoders = false;
|
|
||||||
ArrayList<UriSample> playlistSamples = null;
|
ArrayList<UriSample> playlistSamples = null;
|
||||||
String adTagUri = null;
|
String adTagUri = null;
|
||||||
String abrAlgorithm = null;
|
|
||||||
String sphericalStereoMode = null;
|
String sphericalStereoMode = null;
|
||||||
|
|
||||||
reader.beginObject();
|
reader.beginObject();
|
||||||
@ -288,11 +316,6 @@ public class SampleChooserActivity extends Activity
|
|||||||
case "drm_multi_session":
|
case "drm_multi_session":
|
||||||
drmMultiSession = reader.nextBoolean();
|
drmMultiSession = reader.nextBoolean();
|
||||||
break;
|
break;
|
||||||
case "prefer_extension_decoders":
|
|
||||||
Assertions.checkState(!insidePlaylist,
|
|
||||||
"Invalid attribute on nested item: prefer_extension_decoders");
|
|
||||||
preferExtensionDecoders = reader.nextBoolean();
|
|
||||||
break;
|
|
||||||
case "playlist":
|
case "playlist":
|
||||||
Assertions.checkState(!insidePlaylist, "Invalid nesting of playlists");
|
Assertions.checkState(!insidePlaylist, "Invalid nesting of playlists");
|
||||||
playlistSamples = new ArrayList<>();
|
playlistSamples = new ArrayList<>();
|
||||||
@ -305,11 +328,6 @@ public class SampleChooserActivity extends Activity
|
|||||||
case "ad_tag_uri":
|
case "ad_tag_uri":
|
||||||
adTagUri = reader.nextString();
|
adTagUri = reader.nextString();
|
||||||
break;
|
break;
|
||||||
case "abr_algorithm":
|
|
||||||
Assertions.checkState(
|
|
||||||
!insidePlaylist, "Invalid attribute on nested item: abr_algorithm");
|
|
||||||
abrAlgorithm = reader.nextString();
|
|
||||||
break;
|
|
||||||
case "spherical_stereo_mode":
|
case "spherical_stereo_mode":
|
||||||
Assertions.checkState(
|
Assertions.checkState(
|
||||||
!insidePlaylist, "Invalid attribute on nested item: spherical_stereo_mode");
|
!insidePlaylist, "Invalid attribute on nested item: spherical_stereo_mode");
|
||||||
@ -327,13 +345,10 @@ public class SampleChooserActivity extends Activity
|
|||||||
if (playlistSamples != null) {
|
if (playlistSamples != null) {
|
||||||
UriSample[] playlistSamplesArray = playlistSamples.toArray(
|
UriSample[] playlistSamplesArray = playlistSamples.toArray(
|
||||||
new UriSample[playlistSamples.size()]);
|
new UriSample[playlistSamples.size()]);
|
||||||
return new PlaylistSample(
|
return new PlaylistSample(sampleName, drmInfo, playlistSamplesArray);
|
||||||
sampleName, preferExtensionDecoders, abrAlgorithm, drmInfo, playlistSamplesArray);
|
|
||||||
} else {
|
} else {
|
||||||
return new UriSample(
|
return new UriSample(
|
||||||
sampleName,
|
sampleName,
|
||||||
preferExtensionDecoders,
|
|
||||||
abrAlgorithm,
|
|
||||||
drmInfo,
|
drmInfo,
|
||||||
uri,
|
uri,
|
||||||
extension,
|
extension,
|
||||||
@ -496,19 +511,15 @@ public class SampleChooserActivity extends Activity
|
|||||||
|
|
||||||
private abstract static class Sample {
|
private abstract static class Sample {
|
||||||
public final String name;
|
public final String name;
|
||||||
public final boolean preferExtensionDecoders;
|
|
||||||
public final String abrAlgorithm;
|
|
||||||
public final DrmInfo drmInfo;
|
public final DrmInfo drmInfo;
|
||||||
|
|
||||||
public Sample(
|
public Sample(String name, DrmInfo drmInfo) {
|
||||||
String name, boolean preferExtensionDecoders, String abrAlgorithm, DrmInfo drmInfo) {
|
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.preferExtensionDecoders = preferExtensionDecoders;
|
|
||||||
this.abrAlgorithm = abrAlgorithm;
|
|
||||||
this.drmInfo = drmInfo;
|
this.drmInfo = drmInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Intent buildIntent(Context context) {
|
public Intent buildIntent(
|
||||||
|
Context context, boolean preferExtensionDecoders, String abrAlgorithm) {
|
||||||
Intent intent = new Intent(context, PlayerActivity.class);
|
Intent intent = new Intent(context, PlayerActivity.class);
|
||||||
intent.putExtra(PlayerActivity.PREFER_EXTENSION_DECODERS_EXTRA, preferExtensionDecoders);
|
intent.putExtra(PlayerActivity.PREFER_EXTENSION_DECODERS_EXTRA, preferExtensionDecoders);
|
||||||
intent.putExtra(PlayerActivity.ABR_ALGORITHM_EXTRA, abrAlgorithm);
|
intent.putExtra(PlayerActivity.ABR_ALGORITHM_EXTRA, abrAlgorithm);
|
||||||
@ -529,14 +540,12 @@ public class SampleChooserActivity extends Activity
|
|||||||
|
|
||||||
public UriSample(
|
public UriSample(
|
||||||
String name,
|
String name,
|
||||||
boolean preferExtensionDecoders,
|
|
||||||
String abrAlgorithm,
|
|
||||||
DrmInfo drmInfo,
|
DrmInfo drmInfo,
|
||||||
Uri uri,
|
Uri uri,
|
||||||
String extension,
|
String extension,
|
||||||
String adTagUri,
|
String adTagUri,
|
||||||
String sphericalStereoMode) {
|
String sphericalStereoMode) {
|
||||||
super(name, preferExtensionDecoders, abrAlgorithm, drmInfo);
|
super(name, drmInfo);
|
||||||
this.uri = uri;
|
this.uri = uri;
|
||||||
this.extension = extension;
|
this.extension = extension;
|
||||||
this.adTagUri = adTagUri;
|
this.adTagUri = adTagUri;
|
||||||
@ -544,8 +553,9 @@ public class SampleChooserActivity extends Activity
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Intent buildIntent(Context context) {
|
public Intent buildIntent(
|
||||||
return super.buildIntent(context)
|
Context context, boolean preferExtensionDecoders, String abrAlgorithm) {
|
||||||
|
return super.buildIntent(context, preferExtensionDecoders, abrAlgorithm)
|
||||||
.setData(uri)
|
.setData(uri)
|
||||||
.putExtra(PlayerActivity.EXTENSION_EXTRA, extension)
|
.putExtra(PlayerActivity.EXTENSION_EXTRA, extension)
|
||||||
.putExtra(PlayerActivity.AD_TAG_URI_EXTRA, adTagUri)
|
.putExtra(PlayerActivity.AD_TAG_URI_EXTRA, adTagUri)
|
||||||
@ -561,23 +571,22 @@ public class SampleChooserActivity extends Activity
|
|||||||
|
|
||||||
public PlaylistSample(
|
public PlaylistSample(
|
||||||
String name,
|
String name,
|
||||||
boolean preferExtensionDecoders,
|
|
||||||
String abrAlgorithm,
|
|
||||||
DrmInfo drmInfo,
|
DrmInfo drmInfo,
|
||||||
UriSample... children) {
|
UriSample... children) {
|
||||||
super(name, preferExtensionDecoders, abrAlgorithm, drmInfo);
|
super(name, drmInfo);
|
||||||
this.children = children;
|
this.children = children;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Intent buildIntent(Context context) {
|
public Intent buildIntent(
|
||||||
|
Context context, boolean preferExtensionDecoders, String abrAlgorithm) {
|
||||||
String[] uris = new String[children.length];
|
String[] uris = new String[children.length];
|
||||||
String[] extensions = new String[children.length];
|
String[] extensions = new String[children.length];
|
||||||
for (int i = 0; i < children.length; i++) {
|
for (int i = 0; i < children.length; i++) {
|
||||||
uris[i] = children[i].uri.toString();
|
uris[i] = children[i].uri.toString();
|
||||||
extensions[i] = children[i].extension;
|
extensions[i] = children[i].extension;
|
||||||
}
|
}
|
||||||
return super.buildIntent(context)
|
return super.buildIntent(context, preferExtensionDecoders, abrAlgorithm)
|
||||||
.putExtra(PlayerActivity.URI_LIST_EXTRA, uris)
|
.putExtra(PlayerActivity.URI_LIST_EXTRA, uris)
|
||||||
.putExtra(PlayerActivity.EXTENSION_LIST_EXTRA, extensions)
|
.putExtra(PlayerActivity.EXTENSION_LIST_EXTRA, extensions)
|
||||||
.setAction(PlayerActivity.ACTION_VIEW_LIST);
|
.setAction(PlayerActivity.ACTION_VIEW_LIST);
|
||||||
|
25
demos/main/src/main/res/menu/sample_chooser_menu.xml
Normal file
25
demos/main/src/main/res/menu/sample_chooser_menu.xml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<!-- Copyright (C) 2018 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.
|
||||||
|
-->
|
||||||
|
<menu xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
|
<item android:id="@+id/prefer_extension_decoders"
|
||||||
|
android:title="@string/prefer_extension_decoders"
|
||||||
|
android:showAsAction="never"
|
||||||
|
android:checkable="true"/>
|
||||||
|
<item android:id="@+id/random_abr"
|
||||||
|
android:title="@string/random_abr"
|
||||||
|
android:showAsAction="never"
|
||||||
|
android:checkable="true"/>
|
||||||
|
</menu>
|
@ -61,4 +61,8 @@
|
|||||||
|
|
||||||
<string name="download_ads_unsupported">IMA does not support offline ads</string>
|
<string name="download_ads_unsupported">IMA does not support offline ads</string>
|
||||||
|
|
||||||
|
<string name="prefer_extension_decoders">Prefer extension decoders</string>
|
||||||
|
|
||||||
|
<string name="random_abr">Enable random ABR</string>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user