Iframe video on Android Hybrid App with Phonegap

2019-07-29 17:05发布

I embedded a youtube video on my index.html file.

<iframe id="video" width="640" height="360" src="//www.youtube.com/embed/xxxxxxxxx?rel=0&amp;controls=0&amp;showinfo=0" frameborder="0" allowfullscreen></iframe>
  • I created the app via cmd with Cordova Phonegap like this:

    cordova create hello com.example.hello HelloWorld
    
  • Replaced my html,css, js files in the app folder.

  • Added android platform:

    cordova platform add android
    
  • Opened Eclipse, imported the app, and run it.

  • I put the .apk on my tablet and everythings works fine, but the video doesn't work.

    I get the error "Web page not avaiable" instead of the video.

How can I fix this?

2条回答
孤傲高冷的网名
2楼-- · 2019-07-29 17:38

Solved.

I simply added http: in link on the src attribute.

<iframe id="video" width="640" height="360" src="HTTP://www.youtube.com/embed/xxxxxxxxx?rel=0&amp;controls=0&amp;showinfo=0" frameborder="0" allowfullscreen></iframe>
查看更多
兄弟一词,经得起流年.
3楼-- · 2019-07-29 18:00

You should probably white list youtube.

http://cordova.apache.org/docs/en/3.6.0/guide_appdev_whitelist_index.md.html

<access origin="http://*.youtube.com" />
查看更多
登录 后发表回答