Safari(iOS): Embed YouTube Video Always Plays In Low Quality

杀马特。学长 韩版系。学妹 提交于 2019-12-12 20:51:26

问题


I need to play YouTube Videos with at least 720p resolution on my mobile tv web app, but safari plays them always with the lowest quality, that sucks.

I tried a lot of solutions that have been already posted, but they seem to be outdated. e.g. &vq=hd720, &hd=1, &vq=hd1080 appending to the embed iframe, unfortunately it's not working.

I also tried to do it with the youtube javascript api, what a surprise, no luck either.

Any other solutions I could try? The Videos are uploaded in portrait format 720x1280.


回答1:


I ran into these exact same issues today and ultimately came up with a bit of a hack that worked for my specific needs. The trick is to double the size of one of the parent elements that's wrapping the iframe embed and then to scale it down again using a transform. For example:

.video-wrap {
  width: 200%; 
  transform: scale(0.5);
  transform-origin: left top;
}

Alternatively, you can also specify an exact width/height for it if you're trying to get exactly 360, 720, 1080, etc.

The only major downside to this "solution" is that it will also scale down the whole video player UI. In my case this was acceptable because there are other UI elements that allow the user to control the video.

I'm also only applying these styles to smaller screens based on css breakpoints, because the larger screens pull in the right resolution video regardless.

I really hope YouTube will eventually fix their setPlaybackQuality function, but in the mean time, I hope this helps someone out.



来源:https://stackoverflow.com/questions/38337171/safariios-embed-youtube-video-always-plays-in-low-quality

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!