Playing video as splash screen on android

Hi Rob, this is my config.lua

application = { content = { width = 480, height = 800, scale = "zoomStretch", fps = 30, }, }

This is my main.lua

local h = 400 local w = 240 local x = display.contentCenterX local y = display.contentCenterY local video = native.newVideo( x, y, w, h ) video:load( "video.mp4") -- play video video:play()

Here are the screen shots, the first is from the main.lua above and the second from same main.lua but with this change

local h = 400 local w = 240

The second image looks like the video is centered, but no, the distances to left and right edges of the screen differ in like 29 pixels.

Thanks in advance.

We generally don’t recommend using zoomStretch.  Just for fun it with zoomEven instead.  You might want to put:

xAlign = “center”,

yAlight = “center”,

in your config.lua as well.

zoomStretch tries to distort your content to make ti fit.    Also is your video a vertical video?

We recommend using “letterbox” as the scaling mode.  Using zoomEven will cause part of your content area to bleed off the screen if the aspect ratio of the device doesn’t fit exactly.

Thanks Rob, the letterbox scaling fixed the positioning issue. Is there any way the scaling mode can be changed programatically, because I have a very specific layout in my app, I know zoomStretch will distort the content, but in this app I have no way to add content in the black areas.

Also I still dont know why Im having issues with the positioning when Im using as scale zoomStretch.

Without knowing more about your layout system, have you looked at:

http://coronalabs.com/blog/2012/12/04/the-ultimate-config-lua-file/

http://coronalabs.com/blog/2013/09/10/modernizing-the-config-lua/

It’s best to read them in order, as the 2nd one assumes you understand the principles from the 1st one?

They use letterbox to perfectly fit the device.  It creates some interesting layout challenges which is some way are easier, and others more complicated.  You can also used a fixed area with letterbox, but you have to use oversized background images to fill the screen regardless of the shape and you have to use display.actualContentWidth and display.actualContentHeight to find the bottom right corner.  0, 0 won’t be guaranteed to be at the top left either.

Thaks Rob, I will look into those two articles to find a solution.

Hi rob, I got the video working now as a splash screen. 

Thanks a lot for helping.

I also figured out how to have my layout on letterbox scale mode.

I just have a final question. How to know in which devices native.newVideo works?? What Im trying to do is play the video in the devices that it can be played, and in the rest I will use a splash screen.

I was reading the documentation and I just found an event listener, but I dont want to appear an android native dialog, when the video cant be played, I want to handle that totally.

Thanks in advance 

I didn’t see any thing in the docs that listed what devices it doesn’t work on.  I don’t know of  away to detect video support.

Rob

Thanks Rob, I will look into it. I will post here any founds I think it might help other people. 

Is there any way to have media.playVideo fullscreen on Android, iPhone 4 and 5, and the iPad? On the iPhone 5 I get black bars on top and bottom and on the iPad I get the black bars on the sides.

1.) My video files are in my project folders (local). They are 384x610, so larger than the screens width and height.

2.) It is Portrait only orientation.

3.) I have all launch files in the resource directory.

4.) When I played the video remotely, I didn’t have this problem… It takes to long to load for the game I’m creating though.

Here is my config.lua: 

–calculate the aspect ratio of the device:

local aspectRatio = display.pixelHeight / display.pixelWidth

application = {

   content = {

      width = aspectRatio > 1.5 and 320 or math.ceil( 480 / aspectRatio ),

      height = aspectRatio < 1.5 and 480 or math.ceil( 320 * aspectRatio ),

      scale = “letterBox”,

      fps = 30,

      imageSuffix = {

         ["@2x"] = 1.5,

         ["@4x"] = 3.0,

      },

   },

Is there any way to have media.playVideo fullscreen on Android, iPhone 4 and 5, and the iPad? On the iPhone 5 I get black bars on top and bottom and on the iPad I get the black bars on the sides.

1.) My video files are in my project folders (local). They are 384x610, so larger than the screens width and height.

2.) It is Portrait only orientation.

3.) I have all launch files in the resource directory.

4.) When I played the video remotely, I didn’t have this problem… It takes to long to load for the game I’m creating though.

Here is my config.lua: 

–calculate the aspect ratio of the device:

local aspectRatio = display.pixelHeight / display.pixelWidth

application = {

   content = {

      width = aspectRatio > 1.5 and 320 or math.ceil( 480 / aspectRatio ),

      height = aspectRatio < 1.5 and 480 or math.ceil( 320 * aspectRatio ),

      scale = “letterBox”,

      fps = 30,

      imageSuffix = {

         ["@2x"] = 1.5,

         ["@4x"] = 3.0,

      },

   },