打开设备后无法立即加载资源,但之后可以加载资源。发生了什么事?
我的应用程序通过 Media Player 类加载并播放视频作为资产。但我注意到,每当我关闭设备(三星 Galaxy Tab)、重新打开并运行应用程序时,视频都不会加载。但如果我等待几分钟并重新运行我的应用程序,它就会起作用。
设备启动时可能发生什么情况导致将我的视频作为资产文件加载失败?我说“失败”,但我在日志中没有看到任何明显的错误。
我知道在启动时,设备必须执行诸如查找媒体之类的步骤。因此,在完成之前,播放可能无法正常工作。在我知道可以播放视频之前,如何知道一切都已完成并准备就绪?
My application loads and plays a video as an asset through the Media Player class. But I've noticed that whenever I turn off my device (a Samsung Galaxy Tab), turn it back on and run the application the video doesn't load. But if I wait a few minutes and re-run my application it works.
What could be going on at the device start up that would make loading my video as an asset file fail? I say "fail", but I don't see any obvious errors in the log.
I know that on start up, the device has to through steps like finding media. So maybe playback doesn't work until that's done. How do I find out that everything is finished and ready before I know I can play a video?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以尝试使用 Intent 过滤器在清单中注册
BroadcastReceiver
android.intent.action.BOOT_COMPLETED
。它需要权限android.permission.RECEIVE_BOOT_COMPLETED
< /a>You can try registering a
BroadcastReceiver
in the manifest with intent filterandroid.intent.action.BOOT_COMPLETED
. It requires the permissionandroid.permission.RECEIVE_BOOT_COMPLETED