Android webview几秒钟后停止播放

时间:2014-04-05 18:45:04

标签: android video-streaming android-videoview

我正在尝试在videoview中播放视频流。

有些视频在几秒钟后停止播放。我在 LOGCAT

中获得了以下信息
04-05 21:36:28.991: W/AudioSystem(9041): AudioFlinger server died!
04-05 21:36:28.991: W/IMediaDeathNotifier(9041): media server died
04-05 21:36:28.991: E/MediaPlayer(9041): error (100, 0)
04-05 21:36:28.991: E/MediaPlayer(9041): Mediaserver died in 16 state
04-05 21:36:30.001: E/MediaPlayer(9041): Error (100,0)
04-05 21:36:30.001: D/VideoView(9041): Error: 100,0
您可以在下方找到我用于播放视频的代码:

    String LINK = item.getVideoUrl();

    VideoView videoView =(VideoView)view.findViewById(R.id.ivVideoPlayer);

    MediaController mc = new MediaController(view.getContext());
    mc.setAnchorView(videoView);
    mc.setMediaPlayer(videoView);
    Uri video = Uri.parse(LINK);
    videoView.setMediaController(mc);
    videoView.setVideoURI(video);
    videoView.requestFocus();
    videoView.start();

    return view;

我该如何解决这个问题?

1 个答案:

答案 0 :(得分:0)

我有同样的问题(错误100,mediaserver死了,等等)。我通过使用.stopPlayback()解决它,并再次启动流。以下是我的代码部分:

private void startWatchVideo(final string video_link) {
        videoViewVA.setMediaController(new MediaController(this));
        videoViewVA.setVideoURI(Uri.parse(video_link));
        videoViewVA.requestFocus();
        videoViewVA.setOnPreparedListener(new OnPreparedListener() {
            public void onPrepared(MediaPlayer media) {
                media.start();
            }
        });

        videoViewVA.setOnErrorListener(new OnErrorListener() {
            @Override
            public boolean onError(MediaPlayer media, int what, int extra) {
                if (what == 100)
                {
                    videoViewVA.stopPlayback();
                    startWatchVideo(video_link);
                }
                return true;
            }
        });
    }

在练习中,视频看起来只是放慢速度