Skip to content

Instantly share code, notes, and snippets.

Avatar

Oliver Woodman ojw28

View GitHub Profile
View playlists.java
// Play a list of URIs as a playlist.
List<MediaItem> mediaItems = new ArrayList<>();
for (int i = 0; i < videoUris.length; i++) {
mediaItems.add(MediaItem.fromUri(videoUris[i]));
}
// Set the playlist, prepare and play.
player.setMediaItems(mediaItems);
player.prepare();
player.play()
View eventlistener-new.java
class PlayerErrorListener extends Player.DefaultEventListener {
@Override
public void onPlayerError(ExoPlaybackException error) {
handlePlayerError(error);
}
}
View eventlistener-old.java
class PlayerErrorListener implements Player.EventListener {
@Override
public void onPlayerError(ExoPlaybackException error) {
// We're interested!
handlePlayerError(error);
}
@Override
public void onTimelineChanged(Timeline timeline, Object manifest, int reason) {
View dashmediasource-new.java
return new DashMediaSource.Factory(chunkSourceFactory, manifestDataSourceFactory)
.setManifestParser(new CustomManifestParser())
.createMediaSource(manifestUri, eventHandler, eventListener);
View dashmediasource-old.java
return new DashMediaSource(
manifestUri,
manifestDataSourceFactory,
new CustomManifestParser(),
chunkSourceFactory,
DashMediaSource.DEFAULT_MIN_LOADABLE_RETRY_COUNT,
DashMediaSource.DEFAULT_LIVE_PRESENTATION_DELAY_PREFER_MANIFEST_MS,
eventHandler,
eventListener);
View enable-tunneling.java
// Enable tunneling if supported by the current media and device configuration.
trackSelector.setTunnelingAudioSessionId(C.generateAudioSessionIdV21(this));
View handle_id3_metadata.java
@Override
public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
for (int i = 0; i < trackGroups.length; i++) {
TrackGroup trackGroup = trackGroups.get(i);
for (int j = 0; j < trackGroup.length; j++) {
Metadata trackMetadata = trackGroup.getFormat(j).metadata;
if (trackMetadata != null) {
// We found metadata. Do something with it here!
}
}
View simple_player_activity_3.xml.diff
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.exoplayer2.ui.SimpleExoPlayerView android:id="@+id/player"
android:layout_width="match_parent"
- android:layout_height="match_parent"/>
+ android:layout_height="match_parent"
+ app:controller_layout_id="@layout/custom_controls"/>
View exo_playback_control_view.xml
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageButton android:id="@id/exo_play"
android:layout_width="100dp"
android:layout_height="100dp"
android:layout_gravity="center"
android:background="#CC000000"
style="@style/ExoMediaButton.Play"/>
View simple_player_activity_3.xml.diff
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.google.android.exoplayer2.ui.SimpleExoPlayerView android:id="@+id/player"
android:layout_width="match_parent"
android:layout_height="match_parent"
- app:resize_mode="fill"/>
+ app:resize_mode="fill"