Android的VideoView错误1,0 [英] Android VideoView Error 1,0

查看:1671
本文介绍了Android的VideoView错误1,0的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这就是主要目标应用是播放特定的视频文件。

I have an application thats main goal is to play a specific video file.

它播放视频,有时正确。但其他时候,它给了我这个错误:

it plays the video correctly sometimes. But other times it gives me this error:

03-21 14:52:36.181: I/AwesomePlayer(119): 
setDataSource_l('/data/data/my.package.name/files/MyMovie.mp4')
03-21 14:52:36.196: W/VideoView(26612): Unable to open content: /data/data/my.package.name/files/MyMovie.mp4
03-21 14:52:36.196: W/VideoView(26612): java.lang.IllegalArgumentException: The surface has been released
03-21 14:52:36.196: W/VideoView(26612):     at android.media.MediaPlayer._setVideoSurface(Native Method)
03-21 14:52:36.196: W/VideoView(26612):     at android.media.MediaPlayer.setDisplay(MediaPlayer.java:633)
03-21 14:52:36.196: W/VideoView(26612):     at android.widget.VideoView.openVideo(VideoView.java:222)
03-21 14:52:36.196: W/VideoView(26612):     at android.widget.VideoView.access$2000(VideoView.java:49)
03-21 14:52:36.196: W/VideoView(26612):     at android.widget.VideoView$6.surfaceCreated(VideoView.java:465)
03-21 14:52:36.196: W/VideoView(26612):     at android.view.SurfaceView.updateWindow(SurfaceView.java:533)
03-21 14:52:36.196: W/VideoView(26612):     at android.view.SurfaceView.access$000(SurfaceView.java:81)
03-21 14:52:36.196: W/VideoView(26612):     at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:169)
03-21 14:52:36.196: W/VideoView(26612):     at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:590)
03-21 14:52:36.196: W/VideoView(26612):     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1617)
03-21 14:52:36.196: W/VideoView(26612):     at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2442)
03-21 14:52:36.196: W/VideoView(26612):     at android.os.Handler.dispatchMessage(Handler.java:99)
03-21 14:52:36.196: W/VideoView(26612):     at android.os.Looper.loop(Looper.java:137)
03-21 14:52:36.196: W/VideoView(26612):     at android.app.ActivityThread.main(ActivityThread.java:4424)
03-21 14:52:36.196: W/VideoView(26612):     at java.lang.reflect.Method.invokeNative(Native Method)
03-21 14:52:36.196: W/VideoView(26612):     at java.lang.reflect.Method.invoke(Method.java:511)
03-21 14:52:36.196: W/VideoView(26612):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-21 14:52:36.196: W/VideoView(26612):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-21 14:52:36.196: W/VideoView(26612):     at dalvik.system.NativeStart.main(Native Method)
03-21 14:52:36.196: D/VideoView(26612): Error: 1,0

我使用的是prepared听众打电话开始是这样的:

I am using the prepared listener to call start like this:

mVideoView.setOnPreparedListener(new MediaPlayer.OnPreparedListener() {
    @Override
    public void onPrepared(MediaPlayer arg0) {
        mVideoView.start();

    }
});

和我设置数据源与此:

file = new File(this.getFilesDir() + File.separator + VIDEO_FILE_NAME);
mVideoView.setVideoPath(file.getAbsolutePath());

我知道肯定该文件确实存在,并且是正确的格式。

I know for certain that the file does exist and is the proper format.

我的应用程序必须从报警触发启动的能力。这似乎只是一个问题的时候,而设备屏幕关闭(我的应用程序将打开屏幕具备唤醒锁)触发器触发并启动我的应用程序。如果我手动启动应用程序,或触发与视频画面播放发生罚款。这个错误也仅存在的对Galaxy Nexus的。我可以运行在一台Nexus S(以及其他一长串)完全相同的code和启动一次比一次优秀。

My application has the ability to be launched from an alarm trigger. It seems to only be a problem when the trigger fires and launches my app while the devices screen is turned off(my app will turn the screen on with a wake lock). If I manually launch the app, or the trigger happens with the screen on the video plays fine. This error is also only occuring on the Galaxy Nexus. I can run the exact same code on a Nexus S(as well as a long list of others) and it starts fine every time.

有谁知道什么具体的Galaxy Nexus的或ICS,可能会导致这种行为?以及是否有什么我可以尝试修复有什么建议?

Does anyone know of anything specific to the Galaxy Nexus or ICS that could cause this behavior? And are there any suggestions for what I could try to fix?

推荐答案

UThis连接到您的SurfaceView。
请确保你不碰你有你叫prepare的MediaPlayer后SurfaceView,它是可见的。在你的情况下试图唤醒屏幕,确保一切都发生在正确的顺序。所以preparing在MediaPlayer播放是您的应用程序应该做的最后一件事。这可能是因为在prepare /播放之前的应用程序是完全清醒,导致应用程序试图操纵SurfaceView启动。

UThis is connected to your SurfaceView. Make sure you don't touch the SurfaceView after you have called prepare on you MediaPlayer and that it is visible. In your case where you try to wake up the screen make sure that everything happens in the correct order. So preparing the MediaPlayer for playback is the very last thing which your app should do. It could be that the prepare/playback is initiated prior to the app being fully awake, causing the app to attempt to manipulate the SurfaceView.

后续code例子说明如何触发的那种异常:

The follow code example illustrates how to trigger that kind of exception:

   private void setupVideo(String file){
      ...
      mSurfaceView = (SurfaceView) findViewById(R.id.surface);
      mHolder = mSurfaceView.getHolder(); // DON'T TOUCH BEHIND THIS POINT
      mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
      mMediaPlayer.setDisplay(mHolder);
      mMediaPlayer.setOnPreparedListener(this);
      mMediaPlayer.prepare();
   }
   @Override
   public void onPrepared(final MediaPlayer mp) {
      mSurfaceView.setVisibility(View.VISIBLE); // THIS WILL CAUSE THE ERROR
      mp.start();
   }

这篇关于Android的VideoView错误1,0的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆