I hope this is fairly simple. I have a video video I want to play. The video should loop back to the beginning once it has finished playing.
TIA!
Jerry
Label: corona android iphone ipad building error inmobi problem display screen View image tableView failed object physics touch button game lua config event listener |
I hope this is fairly simple. I have a video video I want to play. The video should loop back to the beginning once it has finished playing.
TIA!
Jerry
Hey Jerry,
This code is from another thread I posted in a bit back (the one I mentioned earlier I hoped to dig up) -
1 2 3 4 5 6 7 8 9 10 11 | local playMyVideo local function executeDelay (event) timer.performWithDelay ( 10000, playMyVideo, 1) end playMyVideo = function() media.playVideo( "sample.m4v", false, executeDelay ) end playMyVideo() |
Thanks Peach! Just one question for clarification sake. I'm using director, so I assume this bit of code goes into the lua file that pertains to the video and not in the Main.lua or some other file?
Jerry
I'm such a noob. ;-) Maybe it would be better to show you what I have. I can't seem to incorporate your code with what I already have. What follows is probably overkill, but better too much info than too little. Sorry, but I don't know how to show the line numbers as they appear in Textmate.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | function new() local numPages = 1 local menuGroup = display.newGroup() _G.kwk_readMe = 0; local curPage = 1 local disposeAudios local disposeTweens local Play local backgroundimage local drawScreen = function() backgroundimage = display.newImageRect( "p1_backgroundimage.png", 1024, 768 ); backgroundimage.x = 512; backgroundimage.y = 384; backgroundimage.alpha = 1 menuGroup:insert(backgroundimage) menuGroup.backgroundimage = backgroundimage local onPlayTouch = function(event) --if event.phase=="release" and Play.isActive then media.playVideo( "sample.mov", system.ResourceDirectory, true ) -- end end |
Evening Jerry - edited your post to put it in Lua tags so it was readable ;)
You would use my exact code in whatever screen/scene you were playing the video in. If you are using director then no, this would not be main.lua - perhaps myvideo1.lua, or the like.
You should just be able to paste my exact code in*, change the delay then test in the Xcode simulator.
*Where you have it would be fine, but you need all the code to test properly. I'd suggested playing with buttons or the like after getting the basic video looping how you like it :)
Peach
Ah! No wonder I could not get it to work. I was trying to figure out what part of my code change so that yours would work.
I don't know what Carlos is paying you, but it is not enough. ;-)
Jerry
PS @ Carlos....A brief tutorial on how to paste code on this forum so that Lua tags and line numbers show might be helpful. I know that are directions at the bottom of the "Post a reply area," but those directions presuppose those posting know how to implement them. This is a new user area. ;-)
Glad to hear it - all good now?
I don't know but I feel like in the rules I might have explained Lua tags. Anyway, here is how to use them;
< lua > this is my code < / lua >
Without the spaces;
1 2 | this is my code with a second line to show numbers |