playing a series of short videos seamlessly

hi, Looking for the best way to play a series of videos strung together seamlessly, without pausing. Is this at all possible, I think I would need to use the native.newVideo api to avoid timer issues with the media api. Anyone been able to do this? I should be able to preload the video clips and then string them together (like YogaStudio does, for example)
 

best,

Jen

in the interest of science (and with a lil’ help from my friends), here’s a snippet to help you do just this:

I save the name of the videos I want to play in a pipe-delimited format like this: video_1|video_2
and then parse those into a table:

result = {};&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for match in (event.row.combo.."|"):gmatch("(.-)".."|") do &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result[#result+1] = match &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; local currentVideo = 1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; local function onComplete() &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if currentVideo \< #result then&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; timer.performWithDelay(1, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; function (event) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; currentVideo = currentVideo + 1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print(currentVideo) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; media.playVideo( "videos/"..result[currentVideo]..".MPG", true, onComplete) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; media.playVideo("videos/"..result[currentVideo]..".MPG",true,onComplete) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;

When I saw this thread I got a huge sense of deja vu. :slight_smile:
 

 

indeed, indeed. :smiley:

I am wondering now, how to port this to the native.newVideo api. Same idea, we load up a series of videos and queue them to play. Now my problem is the first video plays ok, goes off screen, then only the last video in the sequence plays and gets stuck on screen. Any ideas? I’d rather use native.newVideo due to the nicer format if possible.

combo\_video = native.newVideo( display.contentCenterX, display.contentCenterY,640,360 ) result = {} for match in (params.combo.."|"):gmatch("(.-)".."|") do local t = videos:get(match) result[#result+1] = t end local currentVideo = 1 local function onComplete(event) if video then video:removeSelf() video = nil end if currentVideo \< #result then timer.performWithDelay(1, function (event) currentVideo = currentVideo + 1 print("following videos ",result[currentVideo]) combo\_video:load( result[currentVideo], media.RemoteSource ) combo\_video:addEventListener("video",onComplete) combo\_video:play() end) end end print("first video is ",result[currentVideo]) combo\_video:load( result[currentVideo], media.RemoteSource ) combo\_video:addEventListener( "video", onComplete ) combo\_video:play()

in the interest of science (and with a lil’ help from my friends), here’s a snippet to help you do just this:

I save the name of the videos I want to play in a pipe-delimited format like this: video_1|video_2
and then parse those into a table:

result = {};&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; for match in (event.row.combo.."|"):gmatch("(.-)".."|") do &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; result[#result+1] = match &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; local currentVideo = 1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; local function onComplete() &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; if currentVideo \< #result then&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; timer.performWithDelay(1, &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; function (event) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; currentVideo = currentVideo + 1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; print(currentVideo) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; media.playVideo( "videos/"..result[currentVideo]..".MPG", true, onComplete) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; end &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; media.playVideo("videos/"..result[currentVideo]..".MPG",true,onComplete) &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp; &nbsp;

When I saw this thread I got a huge sense of deja vu. :slight_smile:
 

 

indeed, indeed. :smiley:

I am wondering now, how to port this to the native.newVideo api. Same idea, we load up a series of videos and queue them to play. Now my problem is the first video plays ok, goes off screen, then only the last video in the sequence plays and gets stuck on screen. Any ideas? I’d rather use native.newVideo due to the nicer format if possible.

combo\_video = native.newVideo( display.contentCenterX, display.contentCenterY,640,360 ) result = {} for match in (params.combo.."|"):gmatch("(.-)".."|") do local t = videos:get(match) result[#result+1] = t end local currentVideo = 1 local function onComplete(event) if video then video:removeSelf() video = nil end if currentVideo \< #result then timer.performWithDelay(1, function (event) currentVideo = currentVideo + 1 print("following videos ",result[currentVideo]) combo\_video:load( result[currentVideo], media.RemoteSource ) combo\_video:addEventListener("video",onComplete) combo\_video:play() end) end end print("first video is ",result[currentVideo]) combo\_video:load( result[currentVideo], media.RemoteSource ) combo\_video:addEventListener( "video", onComplete ) combo\_video:play()