Android 上的 Youtube API 播放器每 2 秒自动暂停一次 [英] Youtube API Player on Android Automatically pauses every 2 seconds

查看:30
本文介绍了Android 上的 Youtube API 播放器每 2 秒自动暂停一次的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个使用 YouTube API 播放 YouTube 视频的应用.当我进入全屏模式时,我将播放器样式切换为 CHROMELESS,因为我想创建自己的一组媒体控件.

I'm making an app that uses the YouTube API to play YouTube videos. When I go into full screen mode, I switch the player style to CHROMELESS because I want to create my own set of media controls.

我开发了一组手势,可以映射到不断变化的音量、亮度和搜索.当这些更改发生时,视频上会弹出一个进度条,实时向用户显示他们的更改.我已将所有视图放在一个 FrameLayout 中,以便在播放器全屏时让进度条显示在屏幕上.

I have developed a set of gestures that map to changing volume, brightness, and seeking. When these changes occur, a progress bar pops up over the video showing the user their changes in real time. I have placed all my Views in a single FrameLayout in order to get the progress bars to show up on screen when the player is fullscreen.

问题是(在我添加音量控制功能之前)一旦我进入全屏模式,视频就会自动暂停.我正在处理方向和 screenSize 改变自己.我注意到它会在我个人制作的搜索栏弹出后大约 2 秒暂停.

The problem is that (before I added volume control functionality) the video would automatically pause as soon as I entered fullscreen mode. I am handling orientation and screenSize changes myself. I noticed that it would pause roughly 2 seconds after my personally made seekbar would pop up.

所以为了测试,我修改了我的代码,没有将播放器样式更改为 CHROMELESS,也就是说,我将其保留为 DEFAULT.我也删除了我的搜索栏,现在视频工作正常;我可以改变亮度并毫无问题地播放视频.在另一个测试中,我从我的代码中删除了 youtubePlayer.pause() 的所有实例,保留了搜索栏,然后改回 CHROMELESS.但是问题又回来了——所以肯定是和搜索栏有关.

So for testing, I altered my code by NOT changing the player style to CHROMELESS, that is, I left it as DEFAULT. I removed my seekbar as well and now the video worked fine; I could change brightness and play the video with no problem. During another test, I removed all instances of youtubePlayer.pause() from my code, left the seekbar in, and changed back to CHROMELESS. But the problem returned--so it must be something to do with the seekbar.

然而,现在我添加了音量控制功能,当我运行它时(即使我不是全屏显示),播放器在我按下播放后几乎立即暂停,之后它根本不起作用.

Now, however, I have added volume control functionality and when I run it (even when I'm not fullscreen) the player pauses almost immediately after I press play and it doesn't work at all afterwards.

谁能帮帮我?当我回到我的电脑时,我会添加一些我的代码.非常感谢您的帮助.

Can anyone help me out? I'll add some of my code when I get back to my computer. I really appreciate your help.

推荐答案

以下是最常见的原因:

  1. UNAUTHORIZED_OVERLAY - 与 YouTube 视图重叠的其他视图

  1. UNAUTHORIZED_OVERLAY - Other views overlapping with youtube view

PLAYER_VIEW_TOO_SMALL - Youtube 视图太小

PLAYER_VIEW_TOO_SMALL - Youtube view too small

USER_DECLINED_RESTRICTED_CONTENT - 尝试播放受限内容

USER_DECLINED_RESTRICTED_CONTENT - Trying to play restricted content

BLOCKED_FOR_APP - 某些视频被应用阻止.

BLOCKED_FOR_APP - Certain videos are blocked for app.

您可以在 链接

这篇关于Android 上的 Youtube API 播放器每 2 秒自动暂停一次的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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