Я установил Exoplayer в режиме Coverflow, плеер работает нормально.
Причина: Но представление Exoplayer не отображается на экране, который я пытался разрешить различными способами.
Я сделал некоторый код, который размещен ниже,
private void playMedia(String video) {
mBandwidthMeter = new DefaultBandwidthMeter();
mAdaptiveTrackSelectionFactory = new AdaptiveTrackSelection.Factory(mBandwidthMeter);
mTrackSelector = new DefaultTrackSelector(mAdaptiveTrackSelectionFactory);
mLoadControl = new DefaultLoadControl();
mSimpleExoPlayer = ExoPlayerFactory.newSimpleInstance(getApplicationContext(), mTrackSelector, mLoadControl);
videoPlayback.setPlayer(mSimpleExoPlayer);
DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
// Produces DataSource instances through which media data is loaded.
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(getApplicationContext(),
Util.getUserAgent(getApplicationContext(), "com.exoplayerdemo"), bandwidthMeter);
// Produces Extractor instances for parsing the media data.
ExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
// This is the MediaSource representing the media to be played.
MediaSource videoSource = new ExtractorMediaSource(Uri.parse(video),
dataSourceFactory, extractorsFactory, null, null);
// Prepare the player with the source.
mLoopingMediaSource = new LoopingMediaSource(videoSource);
mSimpleExoPlayer.prepare(videoSource);
mSimpleExoPlayer.setPlayWhenReady(true);
mSimpleExoPlayer.addListener(new ExoPlayer.EventListener() {
@Override
public void onTimelineChanged(Timeline timeline, Object manifest, int reason) {}
@Override
public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {}
@Override
public void onLoadingChanged(boolean isLoading) {}
@Override
public void onPlayerStateChanged(boolean playWhenReady, int playbackState) {}
@Override
public void onRepeatModeChanged(int repeatMode) {}
@Override
public void onShuffleModeEnabledChanged(boolean shuffleModeEnabled) {}
@Override
public void onPlayerError(ExoPlaybackException error) {
//Toast.makeText(EducationDetailView.this, error.getMessage(), Toast.LENGTH_SHORT).show();
}
@Override
public void onPositionDiscontinuity(int reason) {}
@Override
public void onPlaybackParametersChanged(PlaybackParameters playbackParameters) {}
@Override
public void onSeekProcessed() {}
});
}
Из приведенного ниже кода вы, ребята, можете помочь мне выйти из этой проблемы и определить ее.