Support clip start/end points in demo app
Demo app supports clip start/end points and demonstrates manual ad insertions. PiperOrigin-RevId: 324574358
This commit is contained in:
parent
9392dff225
commit
abfe7a2314
@ -262,6 +262,8 @@
|
|||||||
companion ad slots without accessing the `AdDisplayContainer`.
|
companion ad slots without accessing the `AdDisplayContainer`.
|
||||||
* Add missing notification of `VideoAdPlayerCallback.onLoaded`.
|
* Add missing notification of `VideoAdPlayerCallback.onLoaded`.
|
||||||
* Demo app:
|
* Demo app:
|
||||||
|
* Support clip start/end points in `exolist.json` and demostrate manual ad
|
||||||
|
insertion.
|
||||||
* Retain previous position in list of samples.
|
* Retain previous position in list of samples.
|
||||||
* Replace the `extensions` variant with `decoderExtensions` and make the
|
* Replace the `extensions` variant with `decoderExtensions` and make the
|
||||||
demo app use the Cronet and IMA extensions by default.
|
demo app use the Cronet and IMA extensions by default.
|
||||||
|
@ -397,6 +397,23 @@
|
|||||||
"drm_license_url": "https://proxy.uat.widevine.com/proxy?provider=widevine_test"
|
"drm_license_url": "https://proxy.uat.widevine.com/proxy?provider=widevine_test"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Manual ad insertion",
|
||||||
|
"playlist": [
|
||||||
|
{
|
||||||
|
"uri": "https://html5demos.com/assets/dizzy.mp4",
|
||||||
|
"clip_end_position_ms": 10000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"uri": "https://storage.googleapis.com/exoplayer-test-media-1/mp4/frame-counter-one-hour.mp4",
|
||||||
|
"clip_end_position_ms": 5000
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"uri": "https://html5demos.com/assets/dizzy.mp4",
|
||||||
|
"clip_start_position_ms": 10000
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
@ -62,6 +62,8 @@ public class IntentUtil {
|
|||||||
public static final String URI_EXTRA = "uri";
|
public static final String URI_EXTRA = "uri";
|
||||||
public static final String IS_LIVE_EXTRA = "is_live";
|
public static final String IS_LIVE_EXTRA = "is_live";
|
||||||
public static final String MIME_TYPE_EXTRA = "mime_type";
|
public static final String MIME_TYPE_EXTRA = "mime_type";
|
||||||
|
public static final String START_POSITION_MS_EXTRA = "start_position_ms";
|
||||||
|
public static final String END_POSITION_MS_EXTRA = "end_position_ms";
|
||||||
// For backwards compatibility only.
|
// For backwards compatibility only.
|
||||||
public static final String EXTENSION_EXTRA = "extension";
|
public static final String EXTENSION_EXTRA = "extension";
|
||||||
|
|
||||||
@ -87,13 +89,11 @@ public class IntentUtil {
|
|||||||
if (ACTION_VIEW_LIST.equals(intent.getAction())) {
|
if (ACTION_VIEW_LIST.equals(intent.getAction())) {
|
||||||
int index = 0;
|
int index = 0;
|
||||||
while (intent.hasExtra(URI_EXTRA + "_" + index)) {
|
while (intent.hasExtra(URI_EXTRA + "_" + index)) {
|
||||||
Uri uri = Uri.parse(intent.getStringExtra(URI_EXTRA + "_" + index));
|
String extrasSuffix = "_" + index;
|
||||||
|
Uri uri = Uri.parse(intent.getStringExtra(URI_EXTRA + extrasSuffix));
|
||||||
mediaItems.add(
|
mediaItems.add(
|
||||||
createMediaItemFromIntent(
|
createMediaItemFromIntent(
|
||||||
uri,
|
uri, intent, extrasSuffix, downloadTracker.getDownloadRequest(uri)));
|
||||||
intent,
|
|
||||||
/* extrasKeySuffix= */ "_" + index,
|
|
||||||
downloadTracker.getDownloadRequest(uri)));
|
|
||||||
index++;
|
index++;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@ -109,17 +109,22 @@ public class IntentUtil {
|
|||||||
public static void addToIntent(List<MediaItem> mediaItems, Intent intent) {
|
public static void addToIntent(List<MediaItem> mediaItems, Intent intent) {
|
||||||
Assertions.checkArgument(!mediaItems.isEmpty());
|
Assertions.checkArgument(!mediaItems.isEmpty());
|
||||||
if (mediaItems.size() == 1) {
|
if (mediaItems.size() == 1) {
|
||||||
MediaItem.PlaybackProperties playbackProperties =
|
MediaItem mediaItem = mediaItems.get(0);
|
||||||
checkNotNull(mediaItems.get(0).playbackProperties);
|
MediaItem.PlaybackProperties playbackProperties = checkNotNull(mediaItem.playbackProperties);
|
||||||
intent.setAction(IntentUtil.ACTION_VIEW).setData(playbackProperties.uri);
|
intent.setAction(ACTION_VIEW).setData(mediaItem.playbackProperties.uri);
|
||||||
addPlaybackPropertiesToIntent(playbackProperties, intent, /* extrasKeySuffix= */ "");
|
addPlaybackPropertiesToIntent(playbackProperties, intent, /* extrasKeySuffix= */ "");
|
||||||
|
addClippingPropertiesToIntent(
|
||||||
|
mediaItem.clippingProperties, intent, /* extrasKeySuffix= */ "");
|
||||||
} else {
|
} else {
|
||||||
intent.setAction(IntentUtil.ACTION_VIEW_LIST);
|
intent.setAction(ACTION_VIEW_LIST);
|
||||||
for (int i = 0; i < mediaItems.size(); i++) {
|
for (int i = 0; i < mediaItems.size(); i++) {
|
||||||
|
MediaItem mediaItem = mediaItems.get(i);
|
||||||
MediaItem.PlaybackProperties playbackProperties =
|
MediaItem.PlaybackProperties playbackProperties =
|
||||||
checkNotNull(mediaItems.get(i).playbackProperties);
|
checkNotNull(mediaItem.playbackProperties);
|
||||||
intent.putExtra(IntentUtil.URI_EXTRA + ("_" + i), playbackProperties.uri.toString());
|
intent.putExtra(URI_EXTRA + ("_" + i), playbackProperties.uri.toString());
|
||||||
addPlaybackPropertiesToIntent(playbackProperties, intent, /* extrasKeySuffix= */ "_" + i);
|
addPlaybackPropertiesToIntent(playbackProperties, intent, /* extrasKeySuffix= */ "_" + i);
|
||||||
|
addClippingPropertiesToIntent(
|
||||||
|
mediaItem.clippingProperties, intent, /* extrasKeySuffix= */ "_" + i);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -156,7 +161,12 @@ public class IntentUtil {
|
|||||||
.setCustomCacheKey(downloadRequest != null ? downloadRequest.customCacheKey : null)
|
.setCustomCacheKey(downloadRequest != null ? downloadRequest.customCacheKey : null)
|
||||||
.setMimeType(mimeType)
|
.setMimeType(mimeType)
|
||||||
.setAdTagUri(intent.getStringExtra(AD_TAG_URI_EXTRA + extrasKeySuffix))
|
.setAdTagUri(intent.getStringExtra(AD_TAG_URI_EXTRA + extrasKeySuffix))
|
||||||
.setSubtitles(createSubtitlesFromIntent(intent, extrasKeySuffix));
|
.setSubtitles(createSubtitlesFromIntent(intent, extrasKeySuffix))
|
||||||
|
.setClipStartPositionMs(
|
||||||
|
intent.getLongExtra(START_POSITION_MS_EXTRA + extrasKeySuffix, 0))
|
||||||
|
.setClipEndPositionMs(
|
||||||
|
intent.getLongExtra(END_POSITION_MS_EXTRA + extrasKeySuffix, C.TIME_END_OF_SOURCE));
|
||||||
|
|
||||||
return populateDrmPropertiesFromIntent(builder, intent, extrasKeySuffix).build();
|
return populateDrmPropertiesFromIntent(builder, intent, extrasKeySuffix).build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -279,4 +289,15 @@ public class IntentUtil {
|
|||||||
intent.putExtra(
|
intent.putExtra(
|
||||||
DRM_SESSION_FOR_CLEAR_TYPES_EXTRA + extrasKeySuffix, typeStrings.toArray(new String[0]));
|
DRM_SESSION_FOR_CLEAR_TYPES_EXTRA + extrasKeySuffix, typeStrings.toArray(new String[0]));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void addClippingPropertiesToIntent(
|
||||||
|
MediaItem.ClippingProperties clippingProperties, Intent intent, String extrasKeySuffix) {
|
||||||
|
if (clippingProperties.startPositionMs != 0) {
|
||||||
|
intent.putExtra(
|
||||||
|
START_POSITION_MS_EXTRA + extrasKeySuffix, clippingProperties.startPositionMs);
|
||||||
|
}
|
||||||
|
if (clippingProperties.endPositionMs != C.TIME_END_OF_SOURCE) {
|
||||||
|
intent.putExtra(END_POSITION_MS_EXTRA + extrasKeySuffix, clippingProperties.endPositionMs);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -412,6 +412,12 @@ public class SampleChooserActivity extends AppCompatActivity
|
|||||||
}
|
}
|
||||||
reader.endArray();
|
reader.endArray();
|
||||||
break;
|
break;
|
||||||
|
case "clip_start_position_ms":
|
||||||
|
mediaItem.setClipStartPositionMs(reader.nextLong());
|
||||||
|
break;
|
||||||
|
case "clip_end_position_ms":
|
||||||
|
mediaItem.setClipEndPositionMs(reader.nextLong());
|
||||||
|
break;
|
||||||
case "ad_tag_uri":
|
case "ad_tag_uri":
|
||||||
mediaItem.setAdTagUri(reader.nextString());
|
mediaItem.setAdTagUri(reader.nextString());
|
||||||
break;
|
break;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user