chris
chris

Reputation: 1065

Titanium Mobile videoPlayer on Android not working

I'm trying to play a .mp4 by clicking a button. I've tested this with different SDK's, heres the results:

1.7.5: Black screen when pressing button 1.8.0.1 & 1.8.1: Nothing happens

The event is registered as the alert 'Test' is working if it is uncommented. Here's my code below:

// Create main window
var win = Ti.UI.createWindow({  
    backgroundColor: '#fff'
});

// Initialize the variable that will hold the playing video
var activeVideo;

// Create a play button
var button = Ti.UI.createButton({
    title: 'Play Video',
});

// Add the button to the window
win.add(button);

// Listen for a 'click' on the button
button.addEventListener('click', function () {
    // alert('Test');
    // Create the media player
    activeVideo = Ti.Media.createVideoPlayer({
        url: 'video.mp4',
        autoplay: true
    });
});

// Open the window
win.open();

Upvotes: 0

Views: 1394

Answers (1)

Mike H
Mike H

Reputation: 86

The video player was not added to the window. Try: win.add(activeVideo);

Upvotes: 1

Related Questions