Hi all.
I am trying to build a video player that when a player touches the screen, the video stops and then skips to the next storyboard scene?
I have made multiple attempts. Can someone shed some light on this? Thanks! Scott
Hi all.
I am trying to build a video player that when a player touches the screen, the video stops and then skips to the next storyboard scene?
I have made multiple attempts. Can someone shed some light on this? Thanks! Scott
Did you add an onTouch event listener to the video object? Can I see the code you’ve tried?
Beyond,
Thanks for the quick response!! Here is the code bellow.
S
display.setStatusBar( display.HiddenStatusBar)
local widget = require “widget”
local box
local v
local isTall = ( “iPhone” == system.getInfo( “model” ) ) and ( display.pixelHeight > 960 )
if isTall then
print(display.pixelWidth)
print(display.pixelHeight)
v = native.newVideo( 0, 0, 1136, 640)
v.x = 320
v.y = 400
v.rotation = 90
else
print(display.pixelWidth)
print(display.pixelHeight)
v = native.newVideo( 0, 0, 1136, 640)
v.x = 320
v.y = 480
v.rotation = 90
end
–v = display.newRect( 40, 40, 100, 100 )
v:load( “DS_Intro_v7.mp4”, system.ResourceDirectory )
v:play()
local function onScreenTouch (event)
v:pause()
end
v:addEventListener( “touch”, onScreenTouch )
Any chance of adding the touch event listener before the load or play action? The only other option is to add an invisible object on top of the video and give that object a touch listener. Not sure if video objects can also have a touch listener.
I think the last time this issue was raised (quite some time ago), I tested the addition of a Runtime touch listener (not a touch listener on the video itself) and it worked exactly as expected… the video could be controlled by that global touch listener. Give that a try and see if it solves the issue.
Regards,
Brent
Brent,
That worked perfectly!! Thank you so much. BTW: I really enjoy all of your tutorials, they really got me on my feet fairly quickly. So a BIG THANKS for those.
Keep up the good work!
Scott
Did you add an onTouch event listener to the video object? Can I see the code you’ve tried?
Beyond,
Thanks for the quick response!! Here is the code bellow.
S
display.setStatusBar( display.HiddenStatusBar)
local widget = require “widget”
local box
local v
local isTall = ( “iPhone” == system.getInfo( “model” ) ) and ( display.pixelHeight > 960 )
if isTall then
print(display.pixelWidth)
print(display.pixelHeight)
v = native.newVideo( 0, 0, 1136, 640)
v.x = 320
v.y = 400
v.rotation = 90
else
print(display.pixelWidth)
print(display.pixelHeight)
v = native.newVideo( 0, 0, 1136, 640)
v.x = 320
v.y = 480
v.rotation = 90
end
–v = display.newRect( 40, 40, 100, 100 )
v:load( “DS_Intro_v7.mp4”, system.ResourceDirectory )
v:play()
local function onScreenTouch (event)
v:pause()
end
v:addEventListener( “touch”, onScreenTouch )
Any chance of adding the touch event listener before the load or play action? The only other option is to add an invisible object on top of the video and give that object a touch listener. Not sure if video objects can also have a touch listener.
I think the last time this issue was raised (quite some time ago), I tested the addition of a Runtime touch listener (not a touch listener on the video itself) and it worked exactly as expected… the video could be controlled by that global touch listener. Give that a try and see if it solves the issue.
Regards,
Brent
Brent,
That worked perfectly!! Thank you so much. BTW: I really enjoy all of your tutorials, they really got me on my feet fairly quickly. So a BIG THANKS for those.
Keep up the good work!
Scott
@Brent Is it not possible to add a touch event to a native video object? They seem to behave fairly normally in other areas (can add physics, etc). Also, are there any plans to add support for native.newVideo in the simulator?
Thanks!
@Brent Is it not possible to add a touch event to a native video object? They seem to behave fairly normally in other areas (can add physics, etc). Also, are there any plans to add support for native.newVideo in the simulator?
Thanks!