Play video after touch button

Messing around with snippets of code wanting to get a video to play after touch event…but not having much luck…can anyone paste a quick code?

thanx
display.setStatusBar( display.HiddenStatusBar )

media.playVideo( “roll2.m4v”, true, onComplete )
local button = display.newImage( “button.png” )
button.x = display.contentWidth / 2
button.y = display.contentHeight - 50

function button:tap( event )
local r = math.random( 0, 255 )
local g = math.random( 0, 255 )
local b = math.random( 0, 255 )

textObject:setTextColor( r, g, b )
button:addEventListener( “tap”, button )

transition.to( textObject, { time=1000, y=textObject.y+100 } ) [import]uid: 30601 topic_id: 14530 reply_id: 314530[/import]

This should work :

[code]

local button1 = display.newImage(“button.png”)
button.x = display.contentWidth * 0.5
button.y = display.contentHeight * 0.5
button.myName = “Media”

local function onVideoComplete(event)
print(“Video playback completed”)

return 0
end

local function buttonHandler(event)
local target = event.target

if target.myName == “Media” then
media.playVideo( “roll2.m4v”, true, onVideoComplete)
end

return true
end

button:addEventListener(“touch”, buttonHandler)
[/code] [import]uid: 84637 topic_id: 14530 reply_id: 53755[/import]

Great thanx,

I just had a quick try but noticed the .m4v file is listed as audio in the corona project manager assets file type?

Maybe this is why I can see anything? the file has no audio either so I can’t hear anything, maybe it is playing?

The video file is viewable in the preview pane or using quicktime.

Tried converting vid format to .avi .mp4 .wmv but keep getting this warning:

WARNING: Simulator does not support device video
Video playback completed

They are all listed as audio/mp3 files…

Any thoughts? [import]uid: 30601 topic_id: 14530 reply_id: 53822[/import]

Try using a mp4 file. The simulator indeed doesn’t support video playback. You will need to build for device or xcode simulator to view the video. [import]uid: 84637 topic_id: 14530 reply_id: 53876[/import]

So cannot make app using video clip?
If no vid support in simulator cannot check if working.

Im only beginner and chose Corona because easy to use when don’t know any programming language.

ok, thanks anyway. [import]uid: 30601 topic_id: 14530 reply_id: 53881[/import]

You can check if it’s working via building for device/xcode simulator like I said above… [import]uid: 84637 topic_id: 14530 reply_id: 53900[/import]