Video Playback (black) after finishing

This is hard to debug because the simulator does not do videoplayback. So I have to compile the app and sideload the game (connect to PC and drag the APK to the device)

It plays the video fine, but the screen stays black (when I am expecting it to go to the menu screen). So I don’t know if I am generating an error or what.

I am not 100% committed to using the code below, so please feel free to direct me to a method that might be better.

[code]module(…,package.seeall)

function new()
local screen = display.newGroup()
local physics = require(‘physics’)
local storyboard = require “storyboard”

media.playVideo( “myvideo.mp4”, true, onComplete )

local onComplete = function(event)
print( “video session ended” )
changeScene(“main_menu”)

end

return screen
end
[/code]

Not sure what to do. [import]uid: 132937 topic_id: 37114 reply_id: 67114[/import]

Hi @ElectricDisk,
Is this your entire code, or are there several parts not included in the post?

On thing I see is you’ve declared the “onComplete” function as a local function AFTER your “new()” function. Thus, Lua doesn’t know what that is. Try scoping this properly, with the local function above “new()”. Also, I would suggest you change the name from “onComplete” to something else… I’m not sure that term is exactly “reserved” but just to be safe, change it to something like “onVideoComplete”.

Also, you call the “changeScene” function, but I don’t see it posted. I imagine it’s somewhere in your code, but make sure (again) that it’s properly scoped if you have defined it as a local function.

EDIT: excuse me, I meant to say, place the local “onComplete” function above where you call the “media.*” call, so it’s scoped properly.

Hope this helps,
Brent [import]uid: 200026 topic_id: 37114 reply_id: 145506[/import]

Hi @ElectricDisk,
Is this your entire code, or are there several parts not included in the post?

On thing I see is you’ve declared the “onComplete” function as a local function AFTER your “new()” function. Thus, Lua doesn’t know what that is. Try scoping this properly, with the local function above “new()”. Also, I would suggest you change the name from “onComplete” to something else… I’m not sure that term is exactly “reserved” but just to be safe, change it to something like “onVideoComplete”.

Also, you call the “changeScene” function, but I don’t see it posted. I imagine it’s somewhere in your code, but make sure (again) that it’s properly scoped if you have defined it as a local function.

EDIT: excuse me, I meant to say, place the local “onComplete” function above where you call the “media.*” call, so it’s scoped properly.

Hope this helps,
Brent [import]uid: 200026 topic_id: 37114 reply_id: 145506[/import]