有没有人见过一个Android应用程序使用嵌入式播放器播放YouTube视频? [英] Has anyone seen an Android app play a youtube video using the embedded player?

查看:622
本文介绍了有没有人见过一个Android应用程序使用嵌入式播放器播放YouTube视频?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经几乎放弃希望。我想我的应用程序里面打我的的LinearLayout 嵌入YouTube视频。我尝试了的WebView ,但音频不与视频排队,而​​控制不是很敏感。我试过RTSP,但是这也不能工作。

I've all but given up hope. I want my application to play an embedded youtube video inside of my LinearLayout. I tried a WebView, but the audio doesn't line up with the video, and the controls are not very responsive . I tried RTSP, but that didn't work either.

我见过在这里问的问题,没有人能够回答这个问题。

I've seen the question asked here, and no one has been able to answer it.

我要的是有我的 VideoView / 的MediaPlayer 玩的的MediaController 控制。这是可能的Andr​​oid中?有没有人看到YouTube视频实际上是一个Android应用程序里面玩? YouTube应用做它,为什么不能别人?每个YouTube应用我已经下载或者启动一个意图或者它只是不工作。

All I want is to have my VideoView / MediaPlayer playing a youtube video with the MediaController controls. Is this possible in Android? Has anyone seen a youtube video actually play inside of an Android application? The Youtube app does it, why can't anyone else? Every youtube app I've downloaded either launches an Intent or it just doesn't work.

推荐答案

在此code这里是我做了什么马蒂,
我删除从UI的MediaControllers跑到我的YouTube视频流RTSP扔在我的布局有一个与我需要的按钮基本VideoView。您可以在实际行动在这里看到这在Android Market上的https://market.android.com/details?id=com.sbrecords&feature=search_result#?t=W251bGwsMSwyLDEsImNvbS5zYnJlY29yZHMiXQ.. VIDEO_URL = \"rtsp://v7.cache3.c.youtube.com/CjgLENy73wIaLwkeUryQ8ZkCqRMYJCAkFEIJbXYtZ29vZ2xlSARSB3Jlc3VsdHNg6KnB9MbH8sVODA==/0/0/0/video.3gp\";

In this code here is what I have done Marty, I removed the MediaControllers from the UI and ran my youtube video stream threw rtsp and in my layout there is a basic VideoView with my needed button. you can see this in real action here on the Android Markethttps://market.android.com/details?id=com.sbrecords&feature=search_result#?t=W251bGwsMSwyLDEsImNvbS5zYnJlY29yZHMiXQ.. video_url = "rtsp://v7.cache3.c.youtube.com/CjgLENy73wIaLwkeUryQ8ZkCqRMYJCAkFEIJbXYtZ29vZ2xlSARSB3Jlc3VsdHNg6KnB9MbH8sVODA==/0/0/0/video.3gp";

        try {
                final VideoView videoView =(VideoView)findViewById(R.id.videoView1);
          //1   //mediaController = new MediaController(Splashscreen.this);
          //2   //mediaController.setAnchorView(videoView);
                // Set video link (mp4 format )
                Uri video = Uri.parse(video_url);
                //videoView.setMediaController(mediaController);
                videoView.setVideoURI(video);
                videoView.setOnPreparedListener(new OnPreparedListener() {
                    public void onPrepared(MediaPlayer mp) {
                        progressDialog.dismiss();
                       videoView.start();
                    }
                });

             }catch(Exception e){
                  progressDialog.dismiss();
                 System.out.println("Video Play Error :"+e.getMessage());
             }
    // Thread to waste time while displaying splash screen
    Thread SplashThread = new Thread() {
        @Override
        public void run() {
            try {
                synchronized (this) {
                    // Wait given period of time
                    wait(7450000);
                }
            } catch (InterruptedException ex) {
            }

            finish();

这篇关于有没有人见过一个Android应用程序使用嵌入式播放器播放YouTube视频?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆