第一次加载时,视频在2-3秒后停止

时间:2014-07-22 16:01:15

标签: java android android-mediaplayer android-videoview

我从我的服务器下载了一个mp4文件并尝试播放它。 我认为下载部分不是问题,它正在发挥作用。我的问题是当我刚刚下载文件时尝试播放它。视频播放2-3秒,然后因MediaPlayer的错误(1 -1004)而停止。

但是当已下载mp4文件时,视频播放成功。

以下是我使用的视频代码:

    getWindow().setFormat(PixelFormat.UNKNOWN);
    Button buttonStopVideo = (Button) findViewById(R.id.StopVideo);

    // VideoView refference see main.xml
    mVideoView = (VideoView) findViewById(R.id.videoview);

    Log.i("Listener context path",
            "" + this.getDir("Ads", MODE_PRIVATE).getAbsolutePath());

    mVideoView.setVideoPath(srcPath);
    mVideoView.setMediaController(new MediaController(this));
    mVideoView.requestFocus();
    mVideoView.start();
    if(mVideoView.isActivated() && !mVideoView.isPlaying()){
        Intent myIntent = new Intent();
        setResult(RESULT_OK, myIntent);
        finish();
    }

如果您有任何想法,那可能会非常有帮助!

1 个答案:

答案 0 :(得分:0)

我发现,在播放之前我还没有完成DL我的mp4 ......