Android VideoView 准备失败; OMX-VDEC 报告第二个实例
有问题的代码:
public class VideoPlayer extends Activity {
Bundle bundle;
VideoView vv;
String type;
Uri path;
Context mContext;
ImageView countImage;
@Override
public void onCreate(Bundle savedInstanceState) {
//Remove title bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
//Remove notification bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
super.onCreate(savedInstanceState);
setContentView(R.layout.videoplayer);
mContext = getBaseContext();
vv = (VideoView) findViewById(R.id.videoView1);
countImage = (ImageView) findViewById(R.id.countdownNumber);
countImage.setVisibility(View.GONE);
getWindow().setFormat(PixelFormat.TRANSLUCENT);
// get details from the Bundle's extras.
bundle = getIntent().getExtras();
String playMode = bundle.getString("mode");
if (playMode.compareTo("single") == 0) { playSingle(); }
else if (playMode.compareTo("multi") == 0) { playMulti(); }
else { finish(); }
}
// --- PLAY SINGLE ---
public void playSingle() {
// retrieve name of video to play from the Bundle
String videoname = bundle.getString("videoname");
Uri path = Uri.parse("android.resource://com.sexinfo101.positions.guide/raw/video_" + videoname);
boolean result = false;
int test = mContext.getResources().getIdentifier("video_" + videoname, "raw", mContext.getPackageName());
if (test != 0) { result = true; }
if (!result) { finish(); }
vv.setMediaController(new MediaController(this));
vv.setVideoURI(path);
vv.requestFocus();
//vv.start();
vv.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mp.setLooping(true);
vv.start();
}
});
vv.setOnCompletionListener(new OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
if (!mp.isPlaying()) {
mp.release();
finish(); // we're done here
}
}
});
}
}
logcat 输出:
08-06 15:22:30.770: ERROR/MediaPlayerService(116): Returning PV_PLAYER*************************
08-06 15:22:30.790: ERROR/PlayerDriver(116): Creating Non-Tunnel mode playback - uncompressed MIO
08-06 15:22:30.800: ERROR/OMX-VDEC-720P(116): In OMX vdec Constuctor
08-06 15:22:30.800: ERROR/OMX-VDEC-720P(116): Name of the device is Unknown
08-06 15:22:30.800: ERROR/OMX-VDEC-720P(116): omx_vdec::component_init(): Start of New Playback
08-06 15:22:30.800: ERROR/OMX-VDEC-720P(116): omx_vdec::component_init(): Open returned fd 30
08-06 15:22:31.300: ERROR/OMX-VDEC-720P(116): Reject Second instance of Decoder
08-06 15:22:31.300: ERROR/OMX-VDEC-720P(116): In OMX vdec Destructor
08-06 15:22:31.300: ERROR/OMX-VDEC-720P(116): Waiting on OMX Msg Thread exit
08-06 15:22:31.300: ERROR/OMX-VDEC-720P(116): Waiting on OMX Async Thread exit
08-06 15:22:31.300: ERROR/OMX-VDEC-720P(116): Exit OMX vdec Destructor
08-06 15:22:31.310: ERROR/PlayerDriver(116): Command PLAYER_PREPARE completed with an error or info PVMFErrResource
08-06 15:22:31.320: ERROR/MediaPlayer(1364): error (1, -17)
08-06 15:22:31.330: ERROR/MediaPlayer(1364): Error (1,-17)
后面是更多 logcat 输出:
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): FATAL EXCEPTION: main
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): java.lang.IllegalStateException
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.media.MediaPlayer._reset(Native Method)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.media.MediaPlayer.reset(MediaPlayer.java:1061)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.widget.VideoView.release(VideoView.java:510)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.widget.VideoView.access$2100(VideoView.java:50)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.widget.VideoView$6.surfaceDestroyed(VideoView.java:500)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.view.SurfaceView.reportSurfaceDestroyed(SurfaceView.java:568)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.view.SurfaceView.updateWindow(SurfaceView.java:472)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.view.SurfaceView.onWindowVisibilityChanged(SurfaceView.java:206)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.view.View.dispatchDetachedFromWindow(View.java:6029)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1156)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1156)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1156)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.view.ViewRoot.dispatchDetachedFromWindow(ViewRoot.java:1630)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.view.ViewRoot.doDie(ViewRoot.java:2720)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.view.ViewRoot.die(ViewRoot.java:2690)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.view.WindowManagerImpl.removeViewImmediate(WindowManagerImpl.java:218)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.view.Window$LocalWindowManager.removeViewImmediate(Window.java:436)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3684)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.app.ActivityThread.access$2900(ActivityThread.java:125)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.os.Handler.dispatchMessage(Handler.java:99)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.os.Looper.loop(Looper.java:123)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.app.ActivityThread.main(ActivityThread.java:4627)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at java.lang.reflect.Method.invokeNative(Native Method)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at java.lang.reflect.Method.invoke(Method.java:521)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at dalvik.system.NativeStart.main(Native Method)
我怀疑 logcat 行 "08-06 17:31:29.960: ERROR/OMX-VDEC-720P(116): Reject Second instance of Decoder" 点准备失败的原因,但我不知道第二个实例可能来自哪里。它确实先于解码器的实际关闭,所以即使不是原因,它似乎至少暗示了一个原因。
有什么想法吗?在调试器中,我可以看到已经找到了有效的资源,并且在我从上面的代码中删除了多人功能中的处理程序和可运行对象之前,这段代码曾经工作得很好。
The code in question:
public class VideoPlayer extends Activity {
Bundle bundle;
VideoView vv;
String type;
Uri path;
Context mContext;
ImageView countImage;
@Override
public void onCreate(Bundle savedInstanceState) {
//Remove title bar
this.requestWindowFeature(Window.FEATURE_NO_TITLE);
//Remove notification bar
this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN);
super.onCreate(savedInstanceState);
setContentView(R.layout.videoplayer);
mContext = getBaseContext();
vv = (VideoView) findViewById(R.id.videoView1);
countImage = (ImageView) findViewById(R.id.countdownNumber);
countImage.setVisibility(View.GONE);
getWindow().setFormat(PixelFormat.TRANSLUCENT);
// get details from the Bundle's extras.
bundle = getIntent().getExtras();
String playMode = bundle.getString("mode");
if (playMode.compareTo("single") == 0) { playSingle(); }
else if (playMode.compareTo("multi") == 0) { playMulti(); }
else { finish(); }
}
// --- PLAY SINGLE ---
public void playSingle() {
// retrieve name of video to play from the Bundle
String videoname = bundle.getString("videoname");
Uri path = Uri.parse("android.resource://com.sexinfo101.positions.guide/raw/video_" + videoname);
boolean result = false;
int test = mContext.getResources().getIdentifier("video_" + videoname, "raw", mContext.getPackageName());
if (test != 0) { result = true; }
if (!result) { finish(); }
vv.setMediaController(new MediaController(this));
vv.setVideoURI(path);
vv.requestFocus();
//vv.start();
vv.setOnPreparedListener(new OnPreparedListener() {
@Override
public void onPrepared(MediaPlayer mp) {
mp.setLooping(true);
vv.start();
}
});
vv.setOnCompletionListener(new OnCompletionListener() {
@Override
public void onCompletion(MediaPlayer mp) {
if (!mp.isPlaying()) {
mp.release();
finish(); // we're done here
}
}
});
}
}
The logcat output:
08-06 15:22:30.770: ERROR/MediaPlayerService(116): Returning PV_PLAYER*************************
08-06 15:22:30.790: ERROR/PlayerDriver(116): Creating Non-Tunnel mode playback - uncompressed MIO
08-06 15:22:30.800: ERROR/OMX-VDEC-720P(116): In OMX vdec Constuctor
08-06 15:22:30.800: ERROR/OMX-VDEC-720P(116): Name of the device is Unknown
08-06 15:22:30.800: ERROR/OMX-VDEC-720P(116): omx_vdec::component_init(): Start of New Playback
08-06 15:22:30.800: ERROR/OMX-VDEC-720P(116): omx_vdec::component_init(): Open returned fd 30
08-06 15:22:31.300: ERROR/OMX-VDEC-720P(116): Reject Second instance of Decoder
08-06 15:22:31.300: ERROR/OMX-VDEC-720P(116): In OMX vdec Destructor
08-06 15:22:31.300: ERROR/OMX-VDEC-720P(116): Waiting on OMX Msg Thread exit
08-06 15:22:31.300: ERROR/OMX-VDEC-720P(116): Waiting on OMX Async Thread exit
08-06 15:22:31.300: ERROR/OMX-VDEC-720P(116): Exit OMX vdec Destructor
08-06 15:22:31.310: ERROR/PlayerDriver(116): Command PLAYER_PREPARE completed with an error or info PVMFErrResource
08-06 15:22:31.320: ERROR/MediaPlayer(1364): error (1, -17)
08-06 15:22:31.330: ERROR/MediaPlayer(1364): Error (1,-17)
Followed by more logcat output:
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): FATAL EXCEPTION: main
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): java.lang.IllegalStateException
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.media.MediaPlayer._reset(Native Method)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.media.MediaPlayer.reset(MediaPlayer.java:1061)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.widget.VideoView.release(VideoView.java:510)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.widget.VideoView.access$2100(VideoView.java:50)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.widget.VideoView$6.surfaceDestroyed(VideoView.java:500)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.view.SurfaceView.reportSurfaceDestroyed(SurfaceView.java:568)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.view.SurfaceView.updateWindow(SurfaceView.java:472)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.view.SurfaceView.onWindowVisibilityChanged(SurfaceView.java:206)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.view.View.dispatchDetachedFromWindow(View.java:6029)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1156)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1156)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1156)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.view.ViewRoot.dispatchDetachedFromWindow(ViewRoot.java:1630)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.view.ViewRoot.doDie(ViewRoot.java:2720)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.view.ViewRoot.die(ViewRoot.java:2690)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.view.WindowManagerImpl.removeViewImmediate(WindowManagerImpl.java:218)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.view.Window$LocalWindowManager.removeViewImmediate(Window.java:436)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:3684)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.app.ActivityThread.access$2900(ActivityThread.java:125)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2066)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.os.Handler.dispatchMessage(Handler.java:99)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.os.Looper.loop(Looper.java:123)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at android.app.ActivityThread.main(ActivityThread.java:4627)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at java.lang.reflect.Method.invokeNative(Native Method)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at java.lang.reflect.Method.invoke(Method.java:521)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
08-06 15:24:29.400: ERROR/AndroidRuntime(1364): at dalvik.system.NativeStart.main(Native Method)
My suspicion is that the logcat line "08-06 17:31:29.960: ERROR/OMX-VDEC-720P(116): Reject Second instance of Decoder" points to the cause of the failure in prepare, but I have no clue where this second instance could be coming from. It does precede the actual shutdown of the decoder, so if not the cause, it seems to at least hint at one.
Any thoughts? In the debugger I can see that a valid resource has been found, and this code used to work just fine before I swapped out Timers for Handler and Runnables in the multi-player function which I cut from the above code.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
好吧,事实证明这是固件/操作系统/设备问题。该问题可能是由我最近开始使用我的华为 IDEOS X5 U8800 手机获得 root 访问权限的 SuperBoot 启动 ROM 引起的。根据开发人员的说法,这个引导 ROM 是为固件版本 136 开发的,而我使用的是 135。升级后,一切似乎都再次顺利运行,包括 WiFi 访问和一切:)
可以在此处找到讨论此问题的论坛主题的链接: <一href="http://android.modaco.com/topic/340374-25-may-r1-superboot-and-then-some-for-the-huawei-u8800-ideos-x5/" rel="nofollow">http://android.modaco.com/topic/340374-25-may-r1-superboot-and-then-some-for-the-huawei-u8800-ideos-x5/
Okay, this turned out to be a firmware/OS/device issue. The problem may have been induced by the SuperBoot boot ROM I started using recently to gain root access on my Huawei IDEOS X5 U8800 phone. This boot ROM according to the developer was developed for firmware revision 136, and I was using 135. After upgrading everything seems to work smoothly again, including WiFi access and everything :)
The link to the forum thread discussing this issue can be found here: http://android.modaco.com/topic/340374-25-may-r1-superboot-and-then-some-for-the-huawei-u8800-ideos-x5/