Quantcast
Viewing all articles
Browse latest Browse all 8068

Problem to play youtube video for android

Hi, i'm trying to play a youtube video with webview covered by a scrollview. It's working great with iPhone but android does not working at all. is there any way to play youtube video for android like iPhone do ? i mean a thumbnail video will be appeared first then video will play upon tapping/click. how can i get that for android. i tried like below -

var scrollView = Titanium.UI.createScrollableView({
    backgroundColor : 'silver',
    top : '2dp',
    left : '5dp',
    right : '5dp',
    height : '50%',
    showPagingControl : true,
    pagingControlColor : '#1c75BC',
    pagingControlHeight : 25,
    currentPage : 0
});
 
var videoPlayer = Titanium.Media.createVideoPlayer({
    top : 2,
    //autoplay : true,
    //backgroundColor : 'blue',
    height : Ti.UI.FILL,
    width : Ti.UI.FILL,
    mediaControlStyle : Titanium.Media.VIDEO_CONTROL_DEFAULT,
    scalingMode : Titanium.Media.VIDEO_SCALING_ASPECT_FIT
});
 
videoPlayer.url = 'http://www.youtube.com/embed/FAaVD8j8Y3o?autoplay=1&autohide=1&cc_load_policy=0&color=white&controls=0&fs=0&iv_load_policy=3&modestbranding=1&rel=0&showinfo=0';
 
scrollView.add(videoPlayer);
but this does not work and tried below also -
Ti.Platform.openURL('http://www.youtube.com/watch?v=FAaVD8j8Y3o');
but this is not what i want, because it plays automatically while window create. what should i do now ? Below is my full code that works with iPhone only and need this to implement for android also -
var win = Ti.UI.createWindow({
    backgroundColor : 'green'
});
 
var scrollView = Titanium.UI.createScrollableView({
    backgroundColor : 'silver',
    top : '2dp',
    left : '5dp',
    right : '5dp',
    height : '50%',
    showPagingControl : true,
    pagingControlColor : '#1c75BC',
    pagingControlHeight : 25,
    currentPage : 0
});
 
var webView = Ti.UI.createWebView({
    url : 'http://www.youtube.com/embed/FAaVD8j8Y3o?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,
    height : Ti.UI.FILL,
    width : Ti.UI.FILL
});
 
scrollView.addView(webView);
 
win.add(scrollView);
 
win.open();

Viewing all articles
Browse latest Browse all 8068

Trending Articles