Android - 找不到 Youtube 3gp 文件



我正在尝试在我的Android应用程序上播放YouTube视频,但我无法访问从Youtube Api返回的3gp网址。我也尝试在VLC播放器和QuickTime播放器中打开它,但响应始终是播放器无法接收数据。这是VLC播放器日志:

主调试:rtsp://v5.cache2.c.youtube.com/CiILENy73wIaGQmyk7Qe6Z5HyRMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp' successfully opened live555 warning: no data received in 10s. Switching to TCP avcodec debug: ffmpeg codec (H263) stopped main debug: removing module "avcodec" main debug: killing decoder fourcc h263',FIFO 中的 0 PES AVCODEC 调试:FFMPEG 编解码器(AMR 窄带(停止 主调试:删除模块"AVCODEC" 主调试:杀死解码器fourcc samr', 0 PES in FIFO main debug: Program doesn't contain anymore ES live555 debug: RTP subsession 'video/H263-2000' main debug: looking for decoder module: 32 candidates avcodec debug: libavcodec already initialized avcodec debug: trying to use direct rendering avcodec debug: ffmpeg codec (H263) started main debug: using decoder module "avcodec" main debug: TIMER module_need() : 0.758 ms - Total 0.758 ms / 1 intvls (Avg 0.758 ms) main debug: thread (decoder) created at priority 0 (../../src/input/decoder.c:301) main debug: thread started live555 debug: RTP subsession 'audio/AMR' main debug: looking for decoder module: 32 candidates avcodec debug: libavcodec already initialized avcodec debug: ffmpeg codec (AMR narrow band) started avcodec debug: Using 192000 bytes output buffer main debug: using decoder module "avcodec" main debug: TIMER module_need() : 391.931 ms - Total 391.931 ms / 1 intvls (Avg 391.931 ms) main debug: thread (decoder) created at priority 22 (../../src/input/decoder.c:301) main debug: thread started live555 debug: setup start: 0.000000 stop:28.666000 live555 debug: play start: 0.000000 stop:28.666000 live555 error: no data received in 10s, aborting main debug: EOF reached main debug: finished input avcodec debug: ffmpeg codec (H263) stopped main debug: removing module "avcodec" main debug: killing decoder fourcc h263',FIFO中的0 PES AVCODEC 调试:FFMPEG 编解码器(AMR 窄带(停止 主调试:删除模块"AVCODEC" 主调试:杀死解码器fourcc 'samr',FIFO中的0 PES 主调试:删除模块"live555" 主调试:程序不再包含 ES 主调试:线程结束 主调试:死输入 主调试:在没有请求的情况下更改项目(当前 0/1( 主调试:无所事事 macOSX 调试:输入已停止,界面刷新 主调试:"rtsp://v5.cache2.c.youtube.com/CiILENy73wIaGQmyk7Qe6Z5HyRMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp"的 TIMER 输入启动:449.262 ms - 总计 449.262 ms/1 intvls (平均 449.262 ms(

这是安卓日志:

05-18 14:51:42.008: D/MediaPlayer(2152(:无法在客户端打开文件,正在尝试服务器端 05-18 14:51:42.258: D/媒体播放器(2152(: 获取元数据 05-18 14:51:53.823: E/媒体播放器 (2152(: 错误 (1, -2147483648( 05-18 14:51:53.823: 电子媒体播放器 (2152(: 错误 (1,-2147483648( 05-18 14:51:53.823:D/VideoView(2152(:错误:1,-2147483648 05-18 14:51:54.060: D/Android运行时(2152(:关闭虚拟机 05-18 14:51:54.060:W/dalvikvm(2152(:threadid=1:线程退出并出现未捕获的异常(组=0x409c01f8( 05-18 14:51:54.088:E/Android运行时(2152(:致命异常:主要 05-18 14:51:54.088: E/AndroidRuntime(2152(: android.view.WindowManager$BadToken异常: 无法添加窗口 -- 令牌 android.app.LocalActivityManager$LocalActivityRecord@418c8408 无效;您的活动是否正在运行? 05-18 14:51:54.088: E/AndroidRuntime(2152(: at android.view.ViewRootImpl.setView(ViewRootImpl.java:513( 05-18 14:51:54.088: E/AndroidRuntime(2152(: at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:301( 05-18 14:51:54.088: E/AndroidRuntime(2152(: at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:215( 05-18 14:51:54.088: E/AndroidRuntime(2152(: at android.view.WindowManagerImpl$CompatModeWrapper.addView(WindowManagerImpl.java:140( 05-18 14:51:54.088: E/AndroidRuntime(2152(: at android.view.Window$LocalWindowManager.addView(Window.java:537( 05-18 14:51:54.088: E/AndroidRuntime(2152(: at android.app.Dialog.show(Dialog.java:278( 05-18 14:51:54.088: E/AndroidRuntime(2152(: at android.app.AlertDialog$Builder.show(AlertDialog.java:932( 05-18 14:51:54.088: E/AndroidRuntime(2152(: at android.widget.VideoView$4.onError(VideoView.java:382( 05-18 14:51:54.088: E/AndroidRuntime(2152(: at android.media.MediaPlayer$EventHandler.handleMessage(MediaPlayer.java:1553( 05-18 14:51:54.088: E/AndroidRuntime(2152(: at android.os.Handler.dispatchMessage(Handler.java:99( 05-18 14:51:54.088: E/AndroidRuntime(2152(: at android.os.Looper.loop(Looper.java:137( 05-18 14:51:54.088: E/AndroidRuntime(2152(: at android.app.ActivityThread.main(ActivityThread.java:4424( 05-18 14:51:54.088: E/AndroidRuntime(2152(: at java.lang.reflect.Method.invokeNative(Native Method( 05-18 14:51:54.088: E/AndroidRuntime(2152(: at java.lang.reflect.Method.invoke(Method.java:511( 05-18 14:51:54.088: E/AndroidRuntime(2152(: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784( 05-18 14:51:54.088: E/AndroidRuntime(2152(: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551( 05-18 14:51:54.088: E/AndroidRuntime(2152(: at dalvik.system.NativeStart.main(Native Method(

还有我的视频活动类来播放视频:


    public class VideoActivity extends Activity{
        public void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.video);
            VideoView videoView = new VideoView(this);
            String urlRtsp = "rtsp://v5.cache2.c.youtube.com/CiILENy73wIaGQmyk7Qe6Z5HyRMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp";
            videoView.setVideoURI(Uri.parse(urlRtsp));
            videoView.setLayoutParams(new LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT));
            videoView.setMediaController(new MediaController(this));
            videoView.requestFocus();
            videoView.start();
            LinearLayout main = (LinearLayout) findViewById(R.id.video_layout);
            main.addView(videoView);        
       }

    }

我试图理解的是,这是否是 Youtube 问题,或者我的代码中是否有问题。我已经尝试了很多视频,代码中的视频只是我的最后一次尝试。我使用的是安卓SDK版本15。

将其

发布为答案,因为 OP 使用此建议解决了它,以便它可以帮助其他寻找类似解决方案的人。

有一个开源项目,可以在VideoView内播放YouTube视频,称为android-youtube-player。还提供了示例Activity以便可以测试组件。

相关内容

  • 没有找到相关文章

最新更新