Video Orientation on Android

I have an app that has a full screen video. My app only supports portrait and I want the video to play in landscape, and just the video.

I see that I can get the systems current orientation by calling: system.orientation

But I don’t know how to tell the video player I want it to use the current system.orientation.

I briefly tried supporting all orientations in the build settings file. This gives me what I want for the video but it breaks all of my other interfaces.

The video player works perfectly on iphone but it won’t rotate on Android. How have you guys solved this problem?

Thanks,
Tim
[import]uid: 39480 topic_id: 17722 reply_id: 317722[/import]

The video orientation is locked to the default orientation on android… unless you use daily builds below 621:

se these threads:

https://developer.anscamobile.com/forum/2010/11/13/play-video-android
https://developer.anscamobile.com/forum/2011/09/27/android-video-download [import]uid: 13632 topic_id: 17722 reply_id: 67552[/import]

We have to have the latest build because the app will be updated regularly and we will need the new features of the SDK. Why wasn’t the goal for this to act like it does on the iphone. The iphone side works perfectly as you would expect. [import]uid: 39480 topic_id: 17722 reply_id: 67556[/import]

if you look in the thread links i posted you will find the answer.

there were some problems with the video player on android. It was restarting the video with the orientation change and weird stuff like that. So the the orientation lock was a temporary fix requested by some users ( including me) [import]uid: 13632 topic_id: 17722 reply_id: 67559[/import]

As of the newest daily build, we’ve modified the video player to support auto-rotation to match the iOS behavior. The video player is no longer locked to the same orientation as the Corona app. Also, video playback no longer restarts when changing orientation. [import]uid: 32256 topic_id: 17722 reply_id: 71103[/import]

That is great news!!! Thanks
[import]uid: 13632 topic_id: 17722 reply_id: 71108[/import]

I’m glad I could help. So, the only thing I took away on Android is the ability to lock the orientation of the video player according to the orientation of the app. But that’s something we should make an API change for and make sure it is supported on iOS too. [import]uid: 32256 topic_id: 17722 reply_id: 71112[/import]

Hate to hijack a thread, but it seems the initial question was answered, and my question is somewhat related…

So I’m building my existing iPhone/iPad app for the Android Market. I’m completely new to Android. So I managed to get a friend to lend me his Droid phone for the night, and test out the videos in our app. Noticing that turning landscape didn’t adjust the video, I found this thread and downloaded the latest daily build and got the landscape feature which is great!

My questions are…

  1. Why doesn’t the video resize to fill the screen, like the iPhone videos do? Is that something I have to code somehow even though I don’t for the iPhone, or is that coming in another daily build soonish?

  2. Is there a way to get a “Done” button while the video is playing like the iPhone has, or do they just have to scroll to the end of the video to finish?

Let me know. Thx. [import]uid: 17341 topic_id: 17722 reply_id: 71539[/import]

Hello britt72,

No worries. You’re asking good question that I’m sure others would be interested in to know.

Regarding question #1, I’ve tested the video player on the Droid2, Samsung Galaxy S2, and Kindle Fire and the video resized itself fine when switching orientations. I did get a report that the video player did not resize itself correctly on a Vizeo tablet. I’ll double check this on the original Droid later today. This may be a device specific issue that we may have to work-around on our end.

Regarding question #2, a “Done” button is unnecessary on Android. Pressing the physical “Back” button on the device will exit the video player. If the video controls are shown onscreen, then the Back button will clear those controls and you will have to press Back on more time to exit the video player. This is Android’s default behavior and not the way Ansca made it.
[import]uid: 32256 topic_id: 17722 reply_id: 71675[/import]

Thx Joshua! Yeah, the phone I was borrowing I just found out is a Motorola Triumph. Not sure if that matters or not. But good to know the resizing would work on most. I have a friend with a Kindle Fire I’m going to test on tonight, so we’ll see if that guy is covered as well. But let me know if you do manage to update so all Androids resize video correctly as I may or may not hold off on submission to the Market until we’re pretty sure it’s covered across the board.

And yeah, for the “Done” button I noticed that regular videos on the Triumph don’t have a “Done” button either. So as long as the back button closes videos and Android users know that, I’m cool with that solution. Thx again!

[import]uid: 17341 topic_id: 17722 reply_id: 71695[/import]

So, I finally got a hold of a Kindle Fire, and I have the same problem where the videos rotate to landscape but they don’t size up to fill the screen. That’s using daily build 701 on the Triumph and the Kindle Fire, and then 703 today on the Kindle Fire. If it helps the videos are 640x360 m4v files. Any chance that’ll be sorted out soonish? [import]uid: 17341 topic_id: 17722 reply_id: 72125[/import]

I was looking into this yesterday, but I haven’t found a solution yet. It’s a tough problem to solve. It looks like an Android bug that I have to work-around.

Also, I’m not having this problem on Kindle Fire. Can you try running sample app “Media\StreamingVideo” that is included with the Corona SDK on your Kindle Fire and see if that orientation issue happens with that app. [import]uid: 32256 topic_id: 17722 reply_id: 72235[/import]

Okay, I narrowed the issue down. The bug fix should be made available in a daily build sometime next week.

I also fixed the video player to correctly center the video when in portrait mode. [import]uid: 32256 topic_id: 17722 reply_id: 72293[/import]

Awesome! That’s great news! Thanks for checking on that! I’ll keep an eye out on the daily build release notes. So do you still want me to try out the sample app video test from the SDK or you’re pretty certain it’s all good to go? [import]uid: 17341 topic_id: 17722 reply_id: 72299[/import]

Don’t bother testing the sample app on your Kindle Fire. I’m quite confident that my code change fixes this problem. :slight_smile: [import]uid: 32256 topic_id: 17722 reply_id: 72363[/import]

i want an intro of my company when app starts, i put a mp4 video, but when the app starts, the video change orientation, it orientation depends of the devide´s orientation, i need to force this orientation to portrait because is an intro of my company. i dont wirte english very well. help me plz, i work in android and use this code:

– include the Corona “storyboard” module
local storyboard = require “storyboard”

– load menu screen
– intro
local onComplete = function(event)
storyboard.gotoScene( “menu” )
print( “video session ended” )
end
media.playVideo( “myvideo.mp4”, true, onComplete ) [import]uid: 149811 topic_id: 17722 reply_id: 135936[/import]

and my build settings are:

settings = {
orientation =
{
default = “portrait”,
},
iphone =
{
plist=
{
UIStatusBarHidden=true,
UIApplicationExitsOnSuspend = true,

CFBundleIconFile = “Icon.png”,
CFBundleIconFiles = {
“Icon.png” ,
“Icon@2x.png” ,
“Icon-72.png” ,
},

},
},
}
[import]uid: 149811 topic_id: 17722 reply_id: 135937[/import]

luchitobj,

That is unfortunately be design. On Android, the [lua]media.playVideo()[/lua] plays the video in a separate activity window which supports all orientations to match the iOS behavior. This behavior was highly demanded by most Corona developers.

If you are developing on iOS, then you can use [lua]native.newVideo()[/lua] instead which will display a video within your app and respect your app’s orientation settings. This API is not available for Android yet, but it is on our current roadmap and we plan on adding it in the future. [import]uid: 32256 topic_id: 17722 reply_id: 135939[/import]

i want an intro of my company when app starts, i put a mp4 video, but when the app starts, the video change orientation, it orientation depends of the devide´s orientation, i need to force this orientation to portrait because is an intro of my company. i dont wirte english very well. help me plz, i work in android and use this code:

– include the Corona “storyboard” module
local storyboard = require “storyboard”

– load menu screen
– intro
local onComplete = function(event)
storyboard.gotoScene( “menu” )
print( “video session ended” )
end
media.playVideo( “myvideo.mp4”, true, onComplete ) [import]uid: 149811 topic_id: 17722 reply_id: 135936[/import]

and my build settings are:

settings = {
orientation =
{
default = “portrait”,
},
iphone =
{
plist=
{
UIStatusBarHidden=true,
UIApplicationExitsOnSuspend = true,

CFBundleIconFile = “Icon.png”,
CFBundleIconFiles = {
“Icon.png” ,
“Icon@2x.png” ,
“Icon-72.png” ,
},

},
},
}
[import]uid: 149811 topic_id: 17722 reply_id: 135937[/import]