media.playVideo() troubles when playing videos in sequence

The first video plays, then if I try to start playing a second video in the onComplete handler, the second video won’t play.
Moreover, aftwer a few tries the application freezes.
This is the code I’m using:

media.playVideo( "app-test.mp4", true,   
 function (event)  
 media.playVideo( "app-test.mp4", true, nil)  
 end)  

If I just wait for 1 sec before launching the second video then it works (two videos played in sequence):

media.playVideo( "app-loading.mp4", true,   
 function (event)  
 timer.performWithDelay(1000,  
 function (event)  
 media.playVideo( "app-loading.mp4", true, nil)  
 end)  
 end)  

Of course in the second case the media player closes and then reopens, so it’s not a desirable behaviour.

Please help.
Thanks [import]uid: 3778 topic_id: 14617 reply_id: 314617[/import]

I just ran into this problem and sure enough putting the 2nd video inside a timer solves the problem. I suspect that the timer ends up starting the video in another thread and that it locks up the current thread.

[import]uid: 19626 topic_id: 14617 reply_id: 114693[/import]

I suspect that this issue is happening to you on iOS and not Android, correct?

The [lua]media.playVideo()[/lua] function can only play one video at a time. So, any calls to it while a video is being played will be ignored. The problem here is that the Lua listener is being called just when the video ends, but while the video player is still onscreen and it hasn’t closed itself yet. That is, the video player won’t be closed until just after the Lua listener has been called. Does that make sense? So, setting up a timer to play the next video in say 1 millisecond should theoretically be enough because the previous video player should already be closed.

That said, I still consider this a usability issue with our API. You make a valid point here. I just wanted to explain it so that you can better work-around the issue. [import]uid: 32256 topic_id: 14617 reply_id: 115177[/import]

In my case there was a beginning game video and an end of game video. Even though I tried to play the other one much later, it still wouldn’t play until I put it into a timer. Then it started working. Its like the original thread is tied up and the timer is putting me in a different thread. At least that’s how it feels.

Yes, its on iOS. [import]uid: 19626 topic_id: 14617 reply_id: 115198[/import]