Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

YouTube Webview Problem

I am using the 1.3.2 SDK and in order to play youtube videos I am doing the following.

  • Creating a HTTP Client and getting JSON data for videos
  • Using the results to create an embed code for the video, which is wrapped in html and body tags.
  • Creating a webview and setting the html to the embed code in the following way:
var webview = Ti.UI.createWebView({
   title:'Videos'+index,
   html: embedCode,
   height:50,
   width:100,
   top:5,
   left:195
});

However, when I add the webview to the row in my table, I don't get anything, and if I check the webview.html, it returns as <html></html> and I have no idea how to get it to work.

Anybody have any ideas?

— asked July 7th 2010 by Abraham Vivas
  • 1.3.2
  • iphone
  • webview
  • youtube
0 Comments

1 Answer

  • Accepted Answer

    This works only on device. The emulator cannot open youtube videos.
    The code I use for this is:

    var movie= '<html><head></head>
    <body style="margin:0"> 
    <embed id="yt" src="'+media_url+'" type="application/x-shockwave-flash" width="200" height="200"></embed> 
    </body></html>';
    

    of course this comes to html property, and media_url is the link to the video, something like this

    http://www.youtube.com/watch?v=r70UpNT_ZUc

    — answered July 7th 2010 by Dan Tamas
    permalink
    1 Comment
    • but this is not Autoplaying. how to Autoplay youtube video?

      — commented September 27th 2012 by Jayesh Joshi
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.