This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class PlayerErrorListener extends Player.DefaultEventListener { | |
@Override | |
public void onPlayerError(ExoPlaybackException error) { | |
handlePlayerError(error); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return new DashMediaSource.Factory(chunkSourceFactory, manifestDataSourceFactory) | |
.setManifestParser(new CustomManifestParser()) | |
.createMediaSource(manifestUri, eventHandler, eventListener); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
return new DashMediaSource( | |
manifestUri, | |
manifestDataSourceFactory, | |
new CustomManifestParser(), | |
chunkSourceFactory, | |
DashMediaSource.DEFAULT_MIN_LOADABLE_RETRY_COUNT, | |
DashMediaSource.DEFAULT_LIVE_PRESENTATION_DELAY_PREFER_MANIFEST_MS, | |
eventHandler, | |
eventListener); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Enable tunneling if supported by the current media and device configuration. | |
trackSelector.setTunnelingAudioSessionId(C.generateAudioSessionIdV21(this)); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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! | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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"/> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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" |
NewerOlder