在我的应用程序中,我想显示来自服务器URI路径的视频, 在这里,第一次播放视频,当我想第二次播放视频时,视频没有播放,并显示弹出窗口,如无法播放此视频
以下是我的错误
E/MediaPlayer: setDataSource: IOException! uri=https://www.merastories.com/VideoFiles/a81d1e5c-3e23-418a-9ba8-fca601d1a966-VID_20180322_152225.mp4
java.io.FileNotFoundException: No content provider: https://www.merastories.com/VideoFiles/a81d1e5c-3e23-418a-9ba8-fca601d1a966-VID_20180322_152225.mp4
at android.content.ContentResolver.openTypedAssetFileDescriptor(ContentResolver.java:1123)
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:958)
at android.content.ContentResolver.openAssetFileDescriptor(ContentResolver.java:881)
at android.media.MediaPlayer.setDataSource(MediaPlayer.java:1018)
at android.widget.VideoView.openVideo(VideoView.java:437)
at android.widget.VideoView$7.surfaceCreated(VideoView.java:742)
at android.view.SurfaceView.updateWindow(SurfaceView.java:676)
at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:203)
at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:944)
at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2417)
at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1321)
at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6708)
at android.view.Choreographer$CallbackRecord.run(Choreographer.java:894)
at android.view.Choreographer.doCallbacks(Choreographer.java:696)
at android.view.Choreographer.doFrame(Choreographer.java:631)
at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:880)
at android.os.Handler.handleCallback(Handler.java:822)
at android.os.Handler.dispatchMessage(Handler.java:104)
at android.os.Looper.loop(Looper.java:207)
at android.app.ActivityThread.main(ActivityThread.java:5811)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:791)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:681)
提前致谢。
答案 0 :(得分:0)
试试这个
String path="https://www.merastories.com/VideoFiles/a81d1e5c-3e23-418a-9ba8-fca601d1a966-VID_20180322_152225.mp4";
Uri uri=Uri.parse(path1);
VideoView videoview=findViewById(R.id.videoview);
video.setVideoURI(uri);
video.start();
答案 1 :(得分:0)
使用ExoPlayer在任何地方显示视频 “编译'com.google.android.exoplayer:exoplayer:r2.5.2'”
使用Exoplayer的代码
if (videoUri != null) {
shouldAutoPlay = true;
bandwidthMeter = new DefaultBandwidthMeter();
mediaDataSourceFactory = new DefaultDataSourceFactory(this, Util.getUserAgent(this, MyApplication.getApplication().getResources().getString(R.string.app_name)), (TransferListener<? super DataSource>) bandwidthMeter);
window = new Timeline.Window();
initializePlayer(videoUrl);
}
private void initializePlayer(Uri iVideoUri) {
simpleExoPlayerView = (SimpleExoPlayerView) findViewById(R.id.video_view);
simpleExoPlayerView.requestFocus();
TrackSelection.Factory videoTrackSelectionFactory =
new AdaptiveTrackSelection.Factory(bandwidthMeter);
trackSelector = new DefaultTrackSelector(videoTrackSelectionFactory);
player = ExoPlayerFactory.newSimpleInstance(this, trackSelector);
simpleExoPlayerView.setPlayer(player);
player.setPlayWhenReady(shouldAutoPlay);
DefaultExtractorsFactory extractorsFactory = new DefaultExtractorsFactory();
MediaSource mediaSource = new ExtractorMediaSource(iVideoUri,
mediaDataSourceFactory, extractorsFactory, null, null);
player.prepare(mediaSource);
}
private void releasePlayer() {
if (player != null) {
shouldAutoPlay = player.getPlayWhenReady();
player.release();
player = null;
trackSelector = null;
}