MediaController.show() 崩溃

发布于 2024-12-14 06:23:48 字数 3280 浏览 2 评论 0原文

我的媒体控制器有问题,这部分代码在 Acer Liquid (gingerbread)、Archos 43 (froyo) e Archos 32 (froyo) 等不同设备上运行完美,

VideoView videoView = (VideoView) findViewById(R.id.videoView1);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView); 
File filevideo = new File(Environment.getExternalStorageDirectory() + "/edizionitsm/firenze/map_" + map_n + "/",filename + "_" + language + ".mp4");
Uri video = Uri.fromFile(filevideo);
videoView.setMediaController(mediaController);
videoView.setVideoURI(video);
videoView.start();

但在 Point of View Pro Tab2 上(姜饼)它在活动开始时崩溃。

11-09 14:12:59.640: E/AndroidRuntime(31433): FATAL EXCEPTION: main
11-09 14:12:59.640: E/AndroidRuntime(31433): java.lang.RuntimeException: Unable to start activity ComponentInfo{edizionitsm.archeoplayer/edizionitsm.archeoplayer.Player}: java.lang.NullPointerException
11-09 14:12:59.640: E/AndroidRuntime(31433):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
11-09 14:12:59.640: E/AndroidRuntime(31433):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
11-09 14:12:59.640: E/AndroidRuntime(31433):    at android.app.ActivityThread.access$1500(ActivityThread.java:117)
11-09 14:12:59.640: E/AndroidRuntime(31433):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
11-09 14:12:59.640: E/AndroidRuntime(31433):    at android.os.Handler.dispatchMessage(Handler.java:99)
11-09 14:12:59.640: E/AndroidRuntime(31433):    at android.os.Looper.loop(Looper.java:123)
11-09 14:12:59.640: E/AndroidRuntime(31433):    at android.app.ActivityThread.main(ActivityThread.java:3683)
11-09 14:12:59.640: E/AndroidRuntime(31433):    at java.lang.reflect.Method.invokeNative(Native Method)
11-09 14:12:59.640: E/AndroidRuntime(31433):    at java.lang.reflect.Method.invoke(Method.java:507)
11-09 14:12:59.640: E/AndroidRuntime(31433):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-09 14:12:59.640: E/AndroidRuntime(31433):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-09 14:12:59.640: E/AndroidRuntime(31433):    at dalvik.system.NativeStart.main(Native Method)
11-09 14:12:59.640: E/AndroidRuntime(31433): Caused by: java.lang.NullPointerException
11-09 14:12:59.640: E/AndroidRuntime(31433):    at android.widget.MediaController.disableUnsupportedButtons(MediaController.java:640)
11-09 14:12:59.640: E/AndroidRuntime(31433):    at android.widget.MediaController.show(MediaController.java:674)
11-09 14:12:59.640: E/AndroidRuntime(31433):    at android.widget.MediaController.show(MediaController.java:631)
11-09 14:12:59.640: E/AndroidRuntime(31433):    at android.widget.VideoView.start(VideoView.java:962)
11-09 14:12:59.640: E/AndroidRuntime(31433):    at edizionitsm.archeoplayer.Player.onCreate(Player.java:48)
11-09 14:12:59.640: E/AndroidRuntime(31433):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-09 14:12:59.640: E/AndroidRuntime(31433):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
11-09 14:12:59.640: E/AndroidRuntime(31433):    ... 11 more

问题出在 mediacontroller 类的 show() 函数中。我该如何解决它? 谢谢。

i've a problem with mediacontroller, this part of code works perfecty on different devices as Acer Liquid (gingerbread), Archos 43 (froyo) e Archos 32 (froyo)...

VideoView videoView = (VideoView) findViewById(R.id.videoView1);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView); 
File filevideo = new File(Environment.getExternalStorageDirectory() + "/edizionitsm/firenze/map_" + map_n + "/",filename + "_" + language + ".mp4");
Uri video = Uri.fromFile(filevideo);
videoView.setMediaController(mediaController);
videoView.setVideoURI(video);
videoView.start();

...but on a Point of View Pro Tab2 (gingerbread) it crash at the beginning of the activity.

11-09 14:12:59.640: E/AndroidRuntime(31433): FATAL EXCEPTION: main
11-09 14:12:59.640: E/AndroidRuntime(31433): java.lang.RuntimeException: Unable to start activity ComponentInfo{edizionitsm.archeoplayer/edizionitsm.archeoplayer.Player}: java.lang.NullPointerException
11-09 14:12:59.640: E/AndroidRuntime(31433):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
11-09 14:12:59.640: E/AndroidRuntime(31433):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
11-09 14:12:59.640: E/AndroidRuntime(31433):    at android.app.ActivityThread.access$1500(ActivityThread.java:117)
11-09 14:12:59.640: E/AndroidRuntime(31433):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
11-09 14:12:59.640: E/AndroidRuntime(31433):    at android.os.Handler.dispatchMessage(Handler.java:99)
11-09 14:12:59.640: E/AndroidRuntime(31433):    at android.os.Looper.loop(Looper.java:123)
11-09 14:12:59.640: E/AndroidRuntime(31433):    at android.app.ActivityThread.main(ActivityThread.java:3683)
11-09 14:12:59.640: E/AndroidRuntime(31433):    at java.lang.reflect.Method.invokeNative(Native Method)
11-09 14:12:59.640: E/AndroidRuntime(31433):    at java.lang.reflect.Method.invoke(Method.java:507)
11-09 14:12:59.640: E/AndroidRuntime(31433):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
11-09 14:12:59.640: E/AndroidRuntime(31433):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
11-09 14:12:59.640: E/AndroidRuntime(31433):    at dalvik.system.NativeStart.main(Native Method)
11-09 14:12:59.640: E/AndroidRuntime(31433): Caused by: java.lang.NullPointerException
11-09 14:12:59.640: E/AndroidRuntime(31433):    at android.widget.MediaController.disableUnsupportedButtons(MediaController.java:640)
11-09 14:12:59.640: E/AndroidRuntime(31433):    at android.widget.MediaController.show(MediaController.java:674)
11-09 14:12:59.640: E/AndroidRuntime(31433):    at android.widget.MediaController.show(MediaController.java:631)
11-09 14:12:59.640: E/AndroidRuntime(31433):    at android.widget.VideoView.start(VideoView.java:962)
11-09 14:12:59.640: E/AndroidRuntime(31433):    at edizionitsm.archeoplayer.Player.onCreate(Player.java:48)
11-09 14:12:59.640: E/AndroidRuntime(31433):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
11-09 14:12:59.640: E/AndroidRuntime(31433):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
11-09 14:12:59.640: E/AndroidRuntime(31433):    ... 11 more

the problem is in the function show() of mediacontroller class. How can i resolve it?
Thank you.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

叫思念不要吵 2024-12-21 06:23:48

我在 3.1 Honeycomb 上遇到了类似的问题,并使用 setMediaPlayer 来解决它。使用 setMediaPlayer 按此顺序尝试您的代码。

VideoView videoView = (VideoView) findViewById(R.id.videoView1);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);

mediaController.setMediaPlayer(videoView);

File filevideo = new File(Environment.getExternalStorageDirectory() + "/edizionitsm/firenze/map_" + map_n + "/",filename + "_" + language + ".mp4");
Uri video = Uri.fromFile(filevideo);
videoView.setMediaController(mediaController);
videoView.setVideoURI(video);
videoView.start();

I had a similar problem on 3.1 Honeycomb and used setMediaPlayer to resolve it. Try your code in this order with setMediaPlayer.

VideoView videoView = (VideoView) findViewById(R.id.videoView1);
MediaController mediaController = new MediaController(this);
mediaController.setAnchorView(videoView);

mediaController.setMediaPlayer(videoView);

File filevideo = new File(Environment.getExternalStorageDirectory() + "/edizionitsm/firenze/map_" + map_n + "/",filename + "_" + language + ".mp4");
Uri video = Uri.fromFile(filevideo);
videoView.setMediaController(mediaController);
videoView.setVideoURI(video);
videoView.start();
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文