Skip to content

Instantly share code, notes, and snippets.

@FokkeZB
Last active August 28, 2018 18:30
Show Gist options
  • Star 11 You must be signed in to star a gist
  • Fork 3 You must be signed in to fork a gist
  • Save FokkeZB/5354066 to your computer and use it in GitHub Desktop.
Save FokkeZB/5354066 to your computer and use it in GitHub Desktop.
Embedding a YouTube video in Titanium
var win = Ti.UI.createWindow();
var webView = Ti.UI.createWebView({
url: 'http://www.youtube.com/embed/' + myVideoID + '?autoplay=1&autohide=1&cc_load_policy=0&color=white&controls=0&fs=0&iv_load_policy=3&modestbranding=1&rel=0&showinfo=0',
enableZoomControls: false,
scalesPageToFit: false,
scrollsToTop: false,
showScrollbars: false
});
win.add(webView);
win.open();
@skypanther
Copy link

Using the following, you can pop open the native player app instead:

Ti.Platform.openURL('http://www.youtube.com/watch?v=' + myVideoID);

Works on iOS & Android, assuming native player app is installed. If not, you get the video embedded in a browser.

@ygbr
Copy link

ygbr commented Feb 3, 2014

I recommend adding disableBounce: true for iOS so the webview stop scrolling youtube content.

@OwenMelbz
Copy link

Trying this on 3.2.3GA however I'm just getting a white page - when I use the same URL in my desktop browser the video loads as it should. Any ideas?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment