Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Controls (seek bar) does not show and a black screen appear on start of Ti.Media.VideoPlayer for android

$
0
0

Hi, video player does not working properly for android. I am having a problem with no control bar and a black screen on start of video player. I want to get rid of that black screen. iOS working properly on start of video player like this image. I just want the same thing for android. But android shows a black screen like this on start of video player and if i click on that black screen then a control bar appears like this. After clicking on the play button of control bar, video starts to play like iOS. I just want the same thing that iOS do with no black screen at least. At jira, there is a story like this [ jira ] and it's status is resolve. But i think this is not resolve yet. Currently i'm working with Titanium 3.3.0.GA sdk and target android sdk 19. Please help me out. Below is my code - In app.js

var w = Ti.UI.createWindow({
    backgroundColor : "#fff"
});
 
var videoPlayer = Titanium.Media.createVideoPlayer({
    top : 2,
    autoplay : false,
    //height : Ti.UI.FILL,
    //width : Ti.UI.FILL,
    mediaControlStyle : Titanium.Media.VIDEO_CONTROL_DEFAULT,
    scalingMode : Titanium.Media.VIDEO_SCALING_ASPECT_FIT
});
 
var Get_MP4 = require('module');
new Get_MP4('FAaVD8j8Y3o', function(_url) {
    //videoPlayer.url = _url;
    videoPlayer.setUrl(_url);
    w.add(videoPlayer);
});
 
w.open();
In module.js
module.exports = function(videoId, callback) {
    var url = 'http://m.youtube.com/watch?ajax=1&layout=mobile&tsp=1&utcoffset=330&v=' + videoId;
    var referer = 'http://www.youtube.com/watch?v=' + videoId;
    var xhr = Ti.Network.createHTTPClient({
        onload : function(e) {
            try {
                var json = this.responseText.substring(4, this.responseText.length);
                var response = JSON.parse(json);
                var video = response.content.video;
                if (videoId == video.encrypted_id) {
                    var streamurl = response.content.player_data.fmt_stream_map ? response.content.player_data.fmt_stream_map[0].url : response.content.player_data.stream_url;
                    console.log('Info: streamingURL='+streamurl);
                    callback(streamurl);
 
                } else {
                    console.log('ap  '+err);
                    callback(null);
                    return;
                }
            } catch(err) {
                console.log('ae  '+err);
                callback(null);
                return;
            }
        },
        onerror : function(e) {
            console.log('ad  '+e);
            callback(null);
        },
        timeout : 60000 // in milliseconds
    });
    xhr.open("GET", url);
    xhr.setRequestHeader('Referer', referer);
    xhr.setRequestHeader('User-Agent', (Ti.Android || true)//
    ? 'Mozilla/5.0 (Linux; U; Android 2.2.1; en-gb; GT-I9003 Build/FROYO) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1'//
    : 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_8_2) AppleWebKit/536.26.14 (KHTML, like Gecko) Version/6.0.1 Safari/536.26.14');
    xhr.send();
};

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>