gpt4 book ai didi

java - Android:直接从 obb 文件扩展中读取 .mp4 文件不起作用 - 在状态 1 中调用 prepareAsync

转载 作者:行者123 更新时间:2023-11-29 21:08:22 31 4
gpt4 key购买 nike

我正在尝试使用 APK 扩展 Zip 库直接从扩展文件加载 .mp4 文件,如下所示:http://developer.android.com/google/play/expansion-files.html我还包括了此处提出的建议:Where is the SampleZipfileProvider class?

我对 list 的添加:

<provider
android:authorities="com.package.app.provider.ZipFileContentProvider"
android:name=".ZipFileContentProvider">
</provider>

我的 ZipFileContentProvider 类:

package com.package.app;

import com.android.vending.expansion.zipfile.APEZProvider;

public class ZipFileContentProvider extends APEZProvider {

@Override
public String getAuthority() {
return "com.package.app.provider.ZipFileContentProvider";
}
}

我的代码:

VideoView vid = (VideoView)findViewById(R.id.videoView1);
String filename = "Main";
final String AUTHORITY = "com.package.app.provider.ZipFileContentProvider";
final Uri CONTENT_URI = Uri.parse("content://" + AUTHORITY);
vid.setVideoURI(Uri.parse(CONTENT_URI + "/" + filename + ".mp4"));

执行此操作会产生以下日志,它会在状态 1 调用的 prepareAsync 上使应用程序崩溃:

05-20 13:30:31.791: V/MediaPlayer-JNI(23535): native_setup
05-20 13:30:31.791: V/MediaPlayer(23535): constructor
05-20 13:30:31.796: V/MediaPlayer(23535): setListener
05-20 13:30:31.796: I/MediaPlayer(23535): path is null
05-20 13:30:31.811: V/MediaPlayer(23535): setVideoSurfaceTexture
05-20 13:30:31.811: V/MediaPlayer-JNI(23535): setAudioStreamType: 3
05-20 13:30:31.811: V/MediaPlayer(23535): MediaPlayer::setAudioStreamType
05-20 13:30:31.811: V/MediaPlayer(23535): setVideoSurfaceTexture
05-20 13:30:31.811: V/MediaPlayer(23535): prepareAsync
05-20 13:30:31.811: E/MediaPlayer(23535): prepareAsync called in state 1
05-20 13:30:31.811: D/AndroidRuntime(23535): Shutting down VM
05-20 13:30:31.811: W/dalvikvm(23535): threadid=1: thread exiting with uncaught exception (group=0x41d322a0)
05-20 13:30:31.816: E/AndroidRuntime(23535): FATAL EXCEPTION: main
05-20 13:30:31.816: E/AndroidRuntime(23535): java.lang.IllegalStateException
05-20 13:30:31.816: E/AndroidRuntime(23535): at android.media.MediaPlayer.prepareAsync(Native Method)
05-20 13:30:31.816: E/AndroidRuntime(23535): at android.widget.VideoView.openVideo(VideoView.java:239)
05-20 13:30:31.816: E/AndroidRuntime(23535): at android.widget.VideoView.access$2000(VideoView.java:51)
05-20 13:30:31.816: E/AndroidRuntime(23535): at android.widget.VideoView$6.surfaceCreated(VideoView.java:478)
05-20 13:30:31.816: E/AndroidRuntime(23535): at android.view.SurfaceView.updateWindow(SurfaceView.java:609)
05-20 13:30:31.816: E/AndroidRuntime(23535): at android.view.SurfaceView.access$000(SurfaceView.java:86)
05-20 13:30:31.816: E/AndroidRuntime(23535): at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:178)
05-20 13:30:31.816: E/AndroidRuntime(23535): at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:703)
05-20 13:30:31.816: E/AndroidRuntime(23535): at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1956)
05-20 13:30:31.816: E/AndroidRuntime(23535): at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1120)
05-20 13:30:31.816: E/AndroidRuntime(23535): at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4604)
05-20 13:30:31.816: E/AndroidRuntime(23535): at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
05-20 13:30:31.816: E/AndroidRuntime(23535): at android.view.Choreographer.doCallbacks(Choreographer.java:555)
05-20 13:30:31.816: E/AndroidRuntime(23535): at android.view.Choreographer.doFrame(Choreographer.java:525)
05-20 13:30:31.816: E/AndroidRuntime(23535): at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
05-20 13:30:31.816: E/AndroidRuntime(23535): at android.os.Handler.handleCallback(Handler.java:615)
05-20 13:30:31.816: E/AndroidRuntime(23535): at android.os.Handler.dispatchMessage(Handler.java:92)
05-20 13:30:31.816: E/AndroidRuntime(23535): at android.os.Looper.loop(Looper.java:137)
05-20 13:30:31.816: E/AndroidRuntime(23535): at android.app.ActivityThread.main(ActivityThread.java:4921)
05-20 13:30:31.816: E/AndroidRuntime(23535): at java.lang.reflect.Method.invokeNative(Native Method)
05-20 13:30:31.816: E/AndroidRuntime(23535): at java.lang.reflect.Method.invoke(Method.java:511)
05-20 13:30:31.816: E/AndroidRuntime(23535): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1038)
05-20 13:30:31.816: E/AndroidRuntime(23535): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:805)
05-20 13:30:31.816: E/AndroidRuntime(23535): at dalvik.system.NativeStart.main(Native Method)

我找不到原因,有什么想法吗?

最佳答案

发现问题:

我用的obb文件是压缩过的,导致这个错误。在 OSX 下,我找不到创建未压缩文件的正确方法,Windows 下的 WinRAR 完成了这项工作:)

关于java - Android:直接从 obb 文件扩展中读取 .mp4 文件不起作用 - 在状态 1 中调用 prepareAsync,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23758747/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com