Hi:
Im trying to have a video as splash screen of my apps (Android). My video size is the same size specified in my config.lua and my scale is zoomStretch. Im facing the following issues:
1- Im using media.playVideo(…) And I can not make my video stretch to the screen dimensions, right now Im having black bars in right and left sides of my screen. Any idea on how to do this?
2- I read about using native newVideo, in some forums I read things like I can not use it on android, but actually Im using it in android (nexus 7, moto g, xperia z), but Im aware that this doesnt work in all android devices. The problem Im having now is with the position, Im trying to position the video in the center but I have not achieved that yet and Im using display.contentCenterX and display.contentCenterY as coordinates. If I can fix the position issue I think I can make it work, because I can change the size of the video to make it a little bigger than the screen and make disappear those black bars.
Please any help to fix these issues will be really appreciated, my main problem is to achiveve a full screen video without black bars on the side, I really want to have a video as splash screen.
Video doesn’t stretch like you can images.
I already figured that out, is my first time working with videos, but any solution about the positioning. My current solution is to make the video bigger than the screen, but the positioning is not working good in android.
I’d center it.
Like I told you in my first post, Im using display.contentCenterX and display.contentCenterY, and the content its not being centered.
Can you post a screen shot of what you’re getting? Your config.lua would also be helpful to see.
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.
Video doesn’t stretch like you can images.
I already figured that out, is my first time working with videos, but any solution about the positioning. My current solution is to make the video bigger than the screen, but the positioning is not working good in android.
I’d center it.
Like I told you in my first post, Im using display.contentCenterX and display.contentCenterY, and the content its not being centered.
Can you post a screen shot of what you’re getting? Your config.lua would also be helpful to see.