Orientation change during video playback

I have an app that plays videos in the iOS default player, then returns to the menu. If the device is rotated during video playback, this change is not reflected in the app when it returns. How can I ensure it updates?

I have this in build.settings:
orientation =
{
default = “portrait”,
supported = {“landscapeLeft”, “landscapeRight”, “landscape”, “portrait”, “portraitUpsideDown”}
}

Thanks. [import]uid: 167874 topic_id: 29285 reply_id: 329285[/import]

I believe you’ll have to rotate the video (using native.newVideo) in an orientationChange event function.

Not 100% on this, so somebody may be able to suggest something different. [import]uid: 33275 topic_id: 29285 reply_id: 117741[/import]

This actually sounds like a bug in Corona. If the app is set up for orientation changes, then all objects should be automatically rotated for you. You shouldn’t have to rotate the native objects yourself. In fact, native object rotation is unfortunately impossible on Android or extremely buggy (I’ve yet to find a way to make it work without issues)… so having the OS rotate these objects needs to happen.

I’ll have someone on our end take a look. [import]uid: 32256 topic_id: 29285 reply_id: 117786[/import]

Thanks. I just want to make sure it’s clear that the video is playing back through the iOS player, and is rotating as expected. The problem is that the app is not responding to orientation changes which occur during video playback, so when the video ends it is at the wrong rotation. [import]uid: 167874 topic_id: 29285 reply_id: 117836[/import]

One further note: I have a function that re-aligns content when the orientation changes. This appears to be being called as normal when the device is rotated during video playback, however the stage is remaining un-rotated until the next orientation change.

This is the function that is working:
local function rotate(event)
if (system.orientation == (“landscapeLeft”)) or (system.orientation == (“landscapeRight”)) then
displayMain.x = 300
displayMain.y = -100
elseif (system.orientation == (“portrait”)) or (system.orientation == (“portraitUpsideDown”)) then
displayMain.x = 0
displayMain.y = 0
end
end
Runtime:addEventListener(“orientation”, rotate) [import]uid: 167874 topic_id: 29285 reply_id: 117845[/import]

How are you displaying the video?
Via [lua]media.show()[/lua] or [lua]native.newVideo()[/lua]? [import]uid: 32256 topic_id: 29285 reply_id: 117913[/import]

I’m using media.playVideo. I just want the default iOS player and, as I understand it, using native.newVideo creates a ‘floating’, movable video object? I looked at media.show but can’t see how it would be used to play video.

Thanks. [import]uid: 167874 topic_id: 29285 reply_id: 117978[/import]

For this, and other reasons, I am now using native rotation, and my listener is picking up the changes correctly during video playback. This might still be worth looking into though. [import]uid: 167874 topic_id: 29285 reply_id: 118044[/import]

My mistake. I meant [lua]media.playVideo()[/lua], not [lua]media.show()[/lua]. Sorry about the confusion.

I’ll bring this issue up with our iOS team, but in the mean time you can work-around this issue by using the [lua]native.newVideo()[/lua] function. You can display it fullscreen as follows…
[lua]local videoView = native.newVideo(0, 0, display.contentWidth, display.contentHeight)
videoView:load(“MyVideo.mp4”)[/lua]

You will have to reposition and resize the video view yourself when an orientation change occurs. A video view has the same properties and functions that all other display objects have, so you can do so via its “x”, “y”, “width”, and “height” properties.

Currently, Android does not support the [lua]native.newVideo()[/lua] function yet, but we plan on adding support later this month. [import]uid: 32256 topic_id: 29285 reply_id: 118071[/import]