星期六, 11月 05, 2016

[jQuery] youtube iFrame API無法在iOS上播放影片的解決方法

測試youtube錯誤,最近幫客戶的網站套了jquery.youtubebackground.js RWD的jquery套件後,就噴了以下錯誤。

Blocked a frame with origin "https://www.youtube.com" from accessing a frame with origin "https://thegrand.com.tw". Protocols, domains, and ports must match


 

Blocked a frame with origin "https://www.youtube.com" from accessing a frame with origin "https://thegrand.com.tw". Protocols, domains, and ports must match.

查了一下原來是這個套件用的是youtube的iframe api,因為在iOS上(safari 和chrome)執行playVideo()這個方法是會爆炸了,雖然有提到可以用cueVideoById("youtubeId")來處理。但用了還是不會播,所以目前的workaround就先讓程式判斷iOS不要先執行play,讓用戶自已點取影片。

http://stackoverflow.com/questions/9934944/embedding-youtube-video-refused-to-display-document-because-display-forbidden-b

https://developers.google.com/youtube/player_parameters?hl=zh-cn#IFrame_Player_API

沒有留言:

張貼留言

留個話吧:)

其他你感興趣的文章

Related Posts with Thumbnails