Application Quits after trying to call up Video

You must Login before you can answer or comment on any questions.

I am creating a simple application which has a button to play a video in it and once it is clicked, the application in the ios simulator crashes - in the Titanium Studio console, it says that "[INFO] ScrollView received click event, source = [object TiUIButton]" and then "[INFO] Application has exited from Simulator"

var win = Titanium.UI.currentWindow;
win.backgroundColor = '#FFF';
 
var vertScrollView = Titanium.UI.createScrollView({
    contentWidth:'auto',
    contentHeight:'auto',
    top:0,
    bottom:0,
    showVerticalScrollIndicator:true,
    showHorizontalScrollIndicator:false
});
 
var view = Ti.UI.createView({
    backgroundColor:'#fff'
});
 
vertScrollView.add(view)
 
var top = Ti.UI.createImageView({
    image:'../images/top.png',
    left:0,
    height:300,
    width:320,
    top:0,
})
view.add(top);
 
 
var moviebutton = Ti.UI.createButton({
    title:'Open Movie',
    width:200,
    height:40,
    top:275
});
 
moviebutton.addEventListener('click', function() 
{
    var moviewin = Titanium.UI.createWindow({
    });
 
    var activeMovie = Titanium.Media.createVideoPlayer({
    url:'../images/movie.mp4',
    movieControlMode : Titanium.Media.VIDEO_CONTROL_DEFAULT,
    movieControlStyle : Titanium.Media.VIDEO_CONTROL_FULLSCREEN,
    scalingMode : Titanium.Media.VIDEO_SCALING_MODE_FILL,
    fullscreen:true,
    autoplay:false,
}); 
 
    moviewin.add(activeMovie);
 
});
 
view.add(movielabel);
 
 
var view1 = Ti.UI.createView({
    backgroundColor:'#FFF'
});
 
var l = Ti.UI.createLabel({
    text:'This is view 1',
    width:300,
    height:'auto',
    top:12,
    font:{fontSize:24}
});
view1.add(l);
 
 
var view2 = Ti.UI.createView({
    backgroundColor:'#FFF'
});
 
var l2 = Ti.UI.createLabel({
    text:'This is view 2',
    width:300,
    height:'auto',
    top:10,
    font:{fontSize:28}
});
view2.add(l2);
 
var view3 = Ti.UI.createView({
    backgroundColor:'green'
});
var l3 = Ti.UI.createLabel({
    text:'View 3',
    color:'#fff',
    width:'auto',
    height:'auto'
});
view3.add(l3);
 
var view4 = Ti.UI.createView({
    backgroundColor:'black'
});
var l4 = Ti.UI.createLabel({
    text:'View 4',
    color:'#fff',
    width:'auto',
    height:'auto'
});
view4.add(l4);
 
var scrollView = Titanium.UI.createScrollableView({
    views:[vertScrollView,view1,view2,view3,view4],
    showPagingControl:true,
    pagingControlHeight:25,
    maxZoomScale:2.0,
    currentPage:0
});
 
win.add(scrollView);
 
var i=1;
var activeView = view1;
 
scrollView.addEventListener('scroll', function(e)
{
    activeView = e.view;  // the object handle to the view that is about to become visible
    i = e.currentPage;
    Titanium.API.info("scroll called - current index " + i + ' active view ' + activeView);
});
scrollView.addEventListener('click', function(e)
{
    Ti.API.info('ScrollView received click event, source = ' + e.source);
});
scrollView.addEventListener('touchend', function(e)
{
    Ti.API.info('ScrollView received touchend event, source = ' + e.source);
});

— asked 10 months ago by J W
0 Comments

1 Answer

This is because when you click the button, you create a window, then create a movie and add that movie to the window, but you don't do anything else. You need to open the window. Attaching the movie to an unopened window is causing a crash.

Your Answer

Think you can help? Login to answer this question!