Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/video/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
android youtube api未按预期播放视频_Android_Video_Android Youtube Api - Fatal编程技术网

android youtube api未按预期播放视频

android youtube api未按预期播放视频,android,video,android-youtube-api,Android,Video,Android Youtube Api,我正在尝试嵌入一个适用于android的youtube api,除了视频只播放一秒钟,然后自动停止之外,一切都很好。但是,当我进入全屏模式时,视频会按预期播放 @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentVi

我正在尝试嵌入一个适用于android的youtube api,除了视频只播放一秒钟,然后自动停止之外,一切都很好。但是,当我进入全屏模式时,视频会按预期播放

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    requestWindowFeature(Window.FEATURE_NO_TITLE);
    setContentView(R.layout.activity_show);

    ivThumbnail = (ImageView) findViewById(R.id.ivThumbnail);
    tv = (ImageView) findViewById(R.id.tv);

    Intent i = getIntent();
    screenCase = i.getIntExtra("screenCase", -1);

    selectedVideoId = Splash.playlists[screenCase].getItems().get(0).getVideo().getId();

    setProperTvImage();
    createButtons();

    ivThumbnail.setImageBitmap(Splash.playlists[screenCase]
            .thumbnails[0]);

    youtubeLV = (ListView)findViewById(R.id.lvPlaylist);
    adapter = new MyYoutubeListAdapter(this, Splash.playlists[screenCase].getItems(), screenCase);

    youtubeLV.setAdapter(adapter);
    youtubeLV.setOnItemClickListener(this);

    youtubePlayerView = (YouTubePlayerView) findViewById(R.id.youtube_view); 
    youtubePlayerView.initialize(DeveloperKey.DEVELOPER_KEY, this); //init Player

}
初始化成功

public void onInitializationSuccess(Provider arg0, YouTubePlayer _player,
        boolean wasRestored) {

    this.player = _player;
    //player.setPlayerStyle(PlayerStyle.CHROMELESS);

    if(!wasRestored){
        playVideoAtSelection();
    }

}
最后播放视频选择方法

private void playVideoAtSelection() {

    if(player != null){
        Log.e("player ", "not null");
        player.cueVideo(selectedVideoId);
    }else{
        Log.e("player ", "null");
    }

}

有什么建议吗?

好吧,现在回答有点晚了,但是有人可能会无意中发现这篇文章,并且可能会有所了解

我也面临同样的问题,下面的第一个选项解决了我的问题

在对类似问题进行了大量搜索之后,我发现了两件事

1) 检查YoutubePlayerView(在活动XML中)是否具有填充选项。如果有衬垫,请将其拆下

2) 根据youtube Api文档,YoutubePlayerView的最小指定大小为200 x 110 dp。在这种情况下,对尺寸进行适当的更改


希望它能帮助别人。

为什么是这个。玩家=\u玩家?你试过只用player=\u player吗?我发现了问题,但目前没有解决方案。问题在于所做的布局。使用youtube api,您无法在播放器上放置任何视图。在我的例子中,我只是尝试在电视图像中显示播放器,我在其中使用alpha。但youtube仍然不允许这样做,我不明白为什么。