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 [import]uid: 39859 topic_id: 15987 reply_id: 315987[/import]
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 [import]uid: 39859 topic_id: 15987 reply_id: 315987[/import]
Hey Jerry,
This code is from another thread I posted in a bit back (the one I mentioned earlier I hoped to dig up) -
[lua]local playMyVideo
local function executeDelay (event)
timer.performWithDelay ( 10000, playMyVideo, 1)
end
playMyVideo = function()
media.playVideo( “sample.m4v”, false, executeDelay )
end
playMyVideo()[/lua]
That has a 10 second delay when the video ends but it doesn’t need to be that high, try 1000, then walk it down a little and see how it goes - there does need to be a slight delay but my 10 second one was just to demonstrate how to write it out 
Let me know if that helps!
Peach [import]uid: 52491 topic_id: 15987 reply_id: 59272[/import]
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 [import]uid: 39859 topic_id: 15987 reply_id: 59355[/import]
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.
[lua]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 [/lua]
[import]uid: 39859 topic_id: 15987 reply_id: 59362[/import]
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 [import]uid: 52491 topic_id: 15987 reply_id: 59453[/import]
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.
[import]uid: 39859 topic_id: 15987 reply_id: 59555[/import]
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;
[lua]this is my code
with a second line to show numbers[/lua]
Easy once you know how 
Peach 
PS - Thanks for the kind words, always most appreciated! [import]uid: 52491 topic_id: 15987 reply_id: 59690[/import]