我在Coverflow视图中设置了 Exoplayer ,该播放器工作正常。
原因:但是在我尝试通过各种方法解决它的屏幕上, Exoplayerview不可见。
到目前为止,我已经完成了一些代码,发布在下面,
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() {}
});
}
从下面的代码中,你们可以帮助我解决这个问题,并能够找出问题所在。