我正在尝试在我的 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 avcodec 中的 0 PES 调试:ffmpeg 编解码器(AMR 窄带)停止主调试:删除模块“avcodec”主调试:杀死解码器fourccsamr', 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 avcodec 调试中的 0 PES:ffmpeg 编解码器(AMR 窄带)停止主调试:删除模块“avcodec”主调试:杀死解码器fourcc `samr',FIFO 主调试中的 0 PES:删除模块“live555”主调试: 程序不再包含 ES main debug: 线程结束 main debug: 死输入 main debug: 在没有请求的情况下更改项目(当前 0/1) main debug: 没什么可玩的 macosx debug: 输入已停止,正在刷新界面 main debug: 'rtsp://v5.cache2.c.youtube.com/CiILENy73wIaGQmyk7Qe6Z5HyRMYDSANFEgGUgZ2aWRlb3MM/0/0/0/video.3gp'的定时器输入启动:449.262 ms - 总计 449.262 ms / 1 intvls(平均 449.262 ms)
这是Android日志:
05-18 14:51:42.008: D/MediaPlayer(2152): 无法在客户端打开文件,尝试服务器端 05-18 14:51:42.258: D/MediaPlayer(2152): getMetadata 05-18 14: 51:53.823: E/MediaPlayer(2152): 错误 (1, -2147483648) 05-18 14:51:53.823: E/MediaPlayer(2152): 错误 (1,-2147483648) 05-18 14:51:53.823: D/VideoView(2152): 错误: 1,-2147483648 05-18 14:51:54.060: D/AndroidRuntime(2152): 关闭 VM 05-18 14:51:54.060: W/dalvikvm(2152): threadid= 1:线程以未捕获的异常退出(组= 0x409c01f8)05-18 14:51:54.088:E/AndroidRuntime(2152):致命异常:主要05-18 14:51:54.088:E/AndroidRuntime(2152):android。 view.WindowManager$BadTokenException: 无法添加窗口——令牌 android.app.LocalActivityManager$LocalActivityRecord@418c8408 无效;您的活动正在运行吗?05-18 14:51:54.088: E/AndroidRuntime(2152):
还有我的 VideoActivity 类来播放视频:
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 问题还是我的代码有问题。我尝试过很多视频,代码中的视频只是我最后一次尝试。我正在使用 Android SDK 版本 15。