I'm accessing an mp4 file on the web - it runs just fine in the browser but for some reason I can only seem to get the audio portion to work in my app. Any help would be appreciated.
Relevant Gradle:
android {
compileSdkVersion 28
minSdkVersion 17
targetSdkVersion 28
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation "com.android.support:support-compat:28.0.0"
implementation "com.android.support:support-media-compat:28.0.0"
implementation "com.google.android.exoplayer:exoplayer-core:2.7.2"
implementation "com.google.android.exoplayer:exoplayer-ui:2.7.2"
}
Layout View:
<com.google.android.exoplayer2.ui.PlayerView
android:id="@+id/playerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent"
android:layout_marginTop="0dp"
android:layout_marginRight="0dp"
app:layout_constraintRight_toRightOf="parent"
android:layout_marginBottom="0dp"
android:layout_marginLeft="0dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintBottom_toTopOf="@+id/horizontalHalf"
/>
Relevant code within Fragment:
private SimpleExoPlayer mExoPlayer;
private static MediaSessionCompat mMediaSession;
private PlaybackStateCompat.Builder mStateBuilder;
BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
TrackSelection.Factory videoTrackSelectionFactory =
new AdaptiveTrackSelection.Factory(bandwidthMeter);
TrackSelector trackSelector =
new DefaultTrackSelector(videoTrackSelectionFactory);
LoadControl loadControl = new DefaultLoadControl();
DefaultRenderersFactory renderersFactory = new DefaultRenderersFactory(mParentActivity);
mExoPlayer = ExoPlayerFactory.newSimpleInstance(renderersFactory, trackSelector, loadControl);
mPlayerView.setPlayer(mExoPlayer);
mExoPlayer.addListener(this);
DefaultDataSourceFactory dataSourceFactory = new DefaultDataSourceFactory(mParentActivity, "APP_NAME");
DefaultExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
MediaSource mediaSource = new ExtractorMediaSource.Factory(dataSourceFactory).setExtractorsFactory(extractorsFactory).createMediaSource(mediaUri);
mExoPlayer.prepare(mediaSource);
mExoPlayer.setPlayWhenReady(true);