My clients want the app to play a fullscreen video, but to be able to close it (and go to the next Director screen) by touching the screen. But not with the standard video control buttons, just by touching the screen while the video plays. Can I do that? [import]uid: 102175 topic_id: 31829 reply_id: 331829[/import]
Hi there,
Try the “native” video object, versus the “media” video option. The latter opens a video in a device pop-up which you don’t have much control over. The “native” video object behaves like a Corona display object, and can be manipulated as such (scaled, positioned, etc.) which means that you should be able to place it behind buttons.
http://docs.coronalabs.com/api/library/native/newVideo.html
The catch? It’s iOS only. If you need this for Android, then I don’t know the solution, or if there even is one.
Brent [import]uid: 9747 topic_id: 31829 reply_id: 127069[/import]
Thanks! I’ll try that. I do only need it for iOS. Let’s pray they don’t get any unhealthy Android ideas in their heads
[import]uid: 102175 topic_id: 31829 reply_id: 127074[/import]
Unfortunately I don’t think that will work. All native objects are rendered above the Corona OpenGL canvas - and there’s not a lot we can do about that.
The only thing you can do is to have a border around the video with the buttons/controls, etc…
[import]uid: 33275 topic_id: 31829 reply_id: 127085[/import]
You’re correct @SegaBoy… and sorry for being slightly misleading April… the video is “native” and thus gets rendered atop everything else. So, you can’t place a button or anything in front of the video, but at least you can control the size/placement of it to provide a slight border or row of “control buttons”.
@SegaBoy, it’s probably a long shot, but since a native.newVideo is technically an “object” (as stated in the documentation), is it possible to add a tap/touch listener to it? I haven’t tried it, but IF that was possible and you could receive a response when the user tapped anywhere on the video region, it would then be possible to programmatically stop/clear the video and proceed to something else, as April’s client needs.
Brent
[import]uid: 9747 topic_id: 31829 reply_id: 127117[/import]
Unfortunately not - I believe the only thing we can do at the moment is attach an event listener to register events such as when the video has finished. I could be wrong, but when I last looked at the api it was pretty much just for showing vids - hence you need a little bit of lateral thinking with them.
You can make them physical objects so don’t know whether that could be a possible route or not? [import]uid: 33275 topic_id: 31829 reply_id: 127131[/import]
Hmmm… your note about making the video into a physics object gave me a “crazy idea”. Perhaps you could make the video into a physical sensor, then when the user touches the screen, instead of a traditional tap/touch response, you could actually PLACE a physical object at that location (just a square or circular body), and then use it for a collision detection. The collision detection “began” phase would then programmatically control the video (stop it, pause it, whatever).
Care to give it a try in one of your apps? This workaround might just be insane enough to accomplish the goal!
Brent
[import]uid: 9747 topic_id: 31829 reply_id: 127133[/import]
Hi there,
Try the “native” video object, versus the “media” video option. The latter opens a video in a device pop-up which you don’t have much control over. The “native” video object behaves like a Corona display object, and can be manipulated as such (scaled, positioned, etc.) which means that you should be able to place it behind buttons.
http://docs.coronalabs.com/api/library/native/newVideo.html
The catch? It’s iOS only. If you need this for Android, then I don’t know the solution, or if there even is one.
Brent [import]uid: 9747 topic_id: 31829 reply_id: 127069[/import]
Thanks! I’ll try that. I do only need it for iOS. Let’s pray they don’t get any unhealthy Android ideas in their heads
[import]uid: 102175 topic_id: 31829 reply_id: 127074[/import]
Unfortunately I don’t think that will work. All native objects are rendered above the Corona OpenGL canvas - and there’s not a lot we can do about that.
The only thing you can do is to have a border around the video with the buttons/controls, etc…
[import]uid: 33275 topic_id: 31829 reply_id: 127085[/import]
You’re correct @SegaBoy… and sorry for being slightly misleading April… the video is “native” and thus gets rendered atop everything else. So, you can’t place a button or anything in front of the video, but at least you can control the size/placement of it to provide a slight border or row of “control buttons”.
@SegaBoy, it’s probably a long shot, but since a native.newVideo is technically an “object” (as stated in the documentation), is it possible to add a tap/touch listener to it? I haven’t tried it, but IF that was possible and you could receive a response when the user tapped anywhere on the video region, it would then be possible to programmatically stop/clear the video and proceed to something else, as April’s client needs.
Brent
[import]uid: 9747 topic_id: 31829 reply_id: 127117[/import]
Unfortunately not - I believe the only thing we can do at the moment is attach an event listener to register events such as when the video has finished. I could be wrong, but when I last looked at the api it was pretty much just for showing vids - hence you need a little bit of lateral thinking with them.
You can make them physical objects so don’t know whether that could be a possible route or not? [import]uid: 33275 topic_id: 31829 reply_id: 127131[/import]
Hmmm… your note about making the video into a physics object gave me a “crazy idea”. Perhaps you could make the video into a physical sensor, then when the user touches the screen, instead of a traditional tap/touch response, you could actually PLACE a physical object at that location (just a square or circular body), and then use it for a collision detection. The collision detection “began” phase would then programmatically control the video (stop it, pause it, whatever).
Care to give it a try in one of your apps? This workaround might just be insane enough to accomplish the goal!
Brent
[import]uid: 9747 topic_id: 31829 reply_id: 127133[/import]
Hey April,
You can do that with a runtime event listener. Here’s a little script that loads a video when the app launches. Tapping anywhere on the screen stops the video and removes it.
[code]
local videoSource = “http://trailers.apple.com/movies/independent/pricecheck/pricecheck-tlr1_r640s.mov”
–New video API
local video = native.newVideo( 0, 0, display.contentHeight+2, display.contentWidth+2 )
– load video
print(‘loading video’)
video:load( videoSource, media.RemoteSource )
video:play()
video.x = display.contentCenterX
video.y = display.contentCenterY
video.rotation = 90
local onTouchVideo = function( e )
if e.phase == “ended” then
print(‘tapped to end video’)
– pause the video and remove
video:pause()
video:removeSelf()
video = nil
end
return true
end
Runtime:addEventListener( “touch”, onTouchVideo )
[/code] [import]uid: 3800 topic_id: 31829 reply_id: 128083[/import]
Hey April,
You can do that with a runtime event listener. Here’s a little script that loads a video when the app launches. Tapping anywhere on the screen stops the video and removes it.
[code]
local videoSource = “http://trailers.apple.com/movies/independent/pricecheck/pricecheck-tlr1_r640s.mov”
–New video API
local video = native.newVideo( 0, 0, display.contentHeight+2, display.contentWidth+2 )
– load video
print(‘loading video’)
video:load( videoSource, media.RemoteSource )
video:play()
video.x = display.contentCenterX
video.y = display.contentCenterY
video.rotation = 90
local onTouchVideo = function( e )
if e.phase == “ended” then
print(‘tapped to end video’)
– pause the video and remove
video:pause()
video:removeSelf()
video = nil
end
return true
end
Runtime:addEventListener( “touch”, onTouchVideo )
[/code] [import]uid: 3800 topic_id: 31829 reply_id: 128083[/import]