Let say we have few video clips and we need to play them continiously with in our iPhone app. The code to play videos continiously are described below.
Code Block :
//Current window var myWin = Ti.UI.currentWindow; //Lets we have three clips named "clip1.mp4, clip2.mp4, clip3.mp4" inside a directory and we will play them continiously. //Count variable that counts clip number var count = 1; //Clip path var clipUrl = "/videos/clip" + count + ".mp4"; //Create the video player var videoPlayer = Titanium.Media.createVideoPlayer({ contentURL : clipUrl , //clip path fullscreen : true, //Open the player with fullscreen autoplay : true, //Clip will be played automatically movieControlMode :Titanium.Media.VIDEO_CONTROL_NONE //Control style }); //Add the player to the current window myWin.add(videoPlayer); //To play next clip on complete of current clip videoPlayer.addEventListener('complete',function(e){ //condition to change the clip name if(count > 3){ count = 1; //To play the first one } clipUrl = "/videos/clip" + count + ".mp4"; //Set the contentURL of the player to play the video videoPlayer .contentURL = clipUrl; //Play the video videoPlayer .play(); count++; });