0

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();
chris
  • 1,055
  • 11
  • 14
  • hey chris you are setting the media player to the var activeVariable, does that then need to be activated, .open(), or set to a viewable area or anything. I don't have my Titanium stuff on this machine, but looking at it seems there might be one more step? Have you tried other video formats? Is the path right? – Ryan Doom Feb 08 '12 at 05:49

1 Answers1

1

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

Mike H
  • 76
  • 2