I’m having difficulty findind information/tutorials on how to resize media.playVideo() content. It currently plays full screen on my app and will not allow me to return to the app until the video finishes.
Thanks
I’m having difficulty findind information/tutorials on how to resize media.playVideo() content. It currently plays full screen on my app and will not allow me to return to the app until the video finishes.
Thanks
Hello @bcournoyer,
Are you developing for iOS, Android, or both?
“media.playVideo()” plays video in a device-specific player, so it doesn’t allow you to resize/position it. If you want to do that, you’ll need to use “native.newVideo()”… but that doesn’t work on Android, only iOS.
http://docs.coronalabs.com/api/library/native/newVideo.html
When you use this method, the catch is, the video is a “native” object and it will reside above everything else (other display objects, buttons, whatever). You cannot place the video playing in the background (behind other images and such) using either video method.
Does this help somewhat?
Brent Sorrentino
Thanks. It confirms what I’ve found so far. I was hoping there was another way.
Is there a way to close the video window (when using media.play) when the video ends? I couldn’t find a “media.close()” option.
It looks like ther is a command removeSelf().
video:removeSelf()
http://www.coronalabs.com/blog/2012/01/24/using-the-new-native-web-video-apis/
I am not sure if the removeSelf works here because I am not using the new video API but, instead the old media.play. I don’t see a way to remove a media.play() instance because it is not associated to an object.
My only experience with media.play() is it playing full screen to the end of the video and then removing itself using only this line of code:
local videoObj = media.playVideo( “tiger.mp4”, true)
I couldn’t find any control information beyond that.
Cool! I will try that. Thanks a lot!
Hello @bcournoyer,
Are you developing for iOS, Android, or both?
“media.playVideo()” plays video in a device-specific player, so it doesn’t allow you to resize/position it. If you want to do that, you’ll need to use “native.newVideo()”… but that doesn’t work on Android, only iOS.
http://docs.coronalabs.com/api/library/native/newVideo.html
When you use this method, the catch is, the video is a “native” object and it will reside above everything else (other display objects, buttons, whatever). You cannot place the video playing in the background (behind other images and such) using either video method.
Does this help somewhat?
Brent Sorrentino
Thanks. It confirms what I’ve found so far. I was hoping there was another way.
Is there a way to close the video window (when using media.play) when the video ends? I couldn’t find a “media.close()” option.
It looks like ther is a command removeSelf().
video:removeSelf()
http://www.coronalabs.com/blog/2012/01/24/using-the-new-native-web-video-apis/
I am not sure if the removeSelf works here because I am not using the new video API but, instead the old media.play. I don’t see a way to remove a media.play() instance because it is not associated to an object.
My only experience with media.play() is it playing full screen to the end of the video and then removing itself using only this line of code:
local videoObj = media.playVideo( “tiger.mp4”, true)
I couldn’t find any control information beyond that.
Cool! I will try that. Thanks a lot!
Hi guys, sorry to bump this back to the top again but I’m still unsure on something with this.
If I want to provide an “exit” button to allow users to quit watching a video half way through and return to the app, how do I go about this? I can’t find any way to do it when using media.playVideo()
Is there a way to achieve this? The native player doesn’t seem to have a quit button.
Thanks,
Ian
On iOS there is button to close video in native controls. On android you use hardware back button.
If it will help there are some facts.
When on ios and android video ends then onComplete function is triggered. When you open video on ios, application is still running in the background. When you close it using “ready” button (I’m not sure about lablel but it should be blue button in top left corner) also onComplete function is triggered.
On android when you open player then it will take a fraction of second but android will suspend app and app will pause executing code.
So if you write
-- 1st media.playVideo( .... ) print("playing") -- 2nd local function doSomething() print("playing delayed") end media.playVideo(...) timer.performWithDelay(250, doSomething)
In first case, “playing” will be printed instantly beacause it takes some little time to open player. However, in second case “playing delayed” won’t be printed until you close video.
I must emphassise that if you interupt video on android (close it by hardware return button) then onComplete won’t trigger.
So if I’m on iOs then I use onComplete and if I’am on android then I use the same function but as delayed by timer.
Thanks for the info. Much appreciated.
I was ideally looking for a solution that allowed me to play the video at a custom size in a custom popup with a close button but from the looks of it that’s impossible on Android so will go with the above in the default media player.
I hadn’t understood that the close button wouldn’t appear in the simulator (it just displays the video players with no close button).
Fine on device though.
Thanks!
Ian
So using media.playVideo() give us no access to size and position. Is there a way to at keep the video’s original ratio?
I have a portrait-oriented app and the video width take as much as the screen width, but the height is just not right. The video got stretched downward.
How about streaming video? Anyone has experience with this?
Can i stream a video, say from **utube, than play it inside the app?
I tried media.playVideo() and add media.RemoteSource, but i got “could not load video” or such message.
Or should i just use native.newWebView() to open the web page?
Yes, you can play video from Internet be it must be streamed video. Youtube do not stream video (read about streaming).
On Android you cannot control video as such with media.playVideo. what it does is Corona passes video to native android player and suspends. When you close player then Corona resumes.
So Corona do not have control over native player.