如何使用YouTube Android Player API播放YouTube实时流? [英] How can I play YouTube live streams with the YouTube Android Player API?

查看:324
本文介绍了如何使用YouTube Android Player API播放YouTube实时流?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我设法使用YouTubePlayer播放了YouTube视频.但是,当我尝试使用YouTubePlayer播放实时流时,没有任何反应. API支持播放实时流吗?如果是这样,我该怎么办?

I have managed to play YouTube videos using YouTubePlayer. However, when I try to play live streams using YouTubePlayer, nothing happens. Is playing live streams supported by the API? If so, how do I do it?

推荐答案

正常播放YouTube视频和直播视频没有区别.我无法在Android 4.1版上播放直播视频.但是在4.2.2版中,实时视频可以成功播放.必须安装最新版本的Youtube官方应用程序才能使用API​​. 代码:

There is no difference in playing normal YouTube videos and live videos.I was unable to play live videos on android version 4.1. however on version 4.2.2, live videos played successfully. Latest version of Official Youtube app must be installed in order to use API. Code:

public void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);   

  YouTubePlayerView youTubeView = (YouTubePlayerView) findViewById(R.id.youtube_view);
  youTubeView.initialize(DEVELOPER_KEY, this);
}
@Override
public void onInitializationSuccess(YouTubePlayer.Provider provider,
        YouTubePlayer player, boolean wasRestored) {

    player.loadVideo("UT86BH2LVUU"); //live vid

}

这篇关于如何使用YouTube Android Player API播放YouTube实时流?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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