我有一个main.lua,它告诉我的应用去另一个场景(intro.lua),这是一个视频播放,视频播放后,我想去第三个场景,这是我的游戏菜单(menu.lua)。
问题是我的Android应用在视频完成时停止了。它没有进入“菜单”场景。
我的代码如下:
我的主要内容:
local storyboard = require( "storyboard" )
local scene = storyboard.newScene()
system.setIdleTimer( false )
display.setStatusBar( display.HiddenStatusBar )
yourName=""
labName=""
titleName=""
rememberMusic=1
rememberSound=1
remeberMusicSlider=300
remeberSoundSlider=300
sndMusic = audio.loadStream ( "Audio/ambient.mp3" )
sndClick = audio.loadStream ( "Audio/click.mp3" )
storyboard.gotoScene("intro")
return scene
我的视频介绍:
local storyboard = require( "storyboard" )
local scene = storyboard.newScene()
system.setIdleTimer( false )
display.setStatusBar( display.HiddenStatusBar )
local onComplete = function()
storyboard.gotoScene("menu")
end
media.playVideo( "videos/logo.mp4", false, onComplete )
return scene
我的menu.lua很大,我不能在这里发布。但它没有问题。如果我从main.lua中调用它,它的效果很好。如果我从我的intro.lua(没有视频)中调用它,它的效果很好。
但如果我打电话(如上面的代码中所述),视频完成后,应用就会停止。
任何人都知道发生了什么事?
Eclipse的错误:
07-05 17:52:22.111: W/dalvikvm(448): threadid=1: thread exiting with uncaught exception (group=0x410f5930)
07-05 17:52:22.121: E/AndroidRuntime(448): FATAL EXCEPTION: main
07-05 17:52:22.121: E/AndroidRuntime(448): java.lang.NullPointerException
07-05 17:52:22.121: E/AndroidRuntime(448): at com.ansca.corona.VideoActivity$1.onCompletion(VideoActivity.java:48)
07-05 17:52:22.121: E/AndroidRuntime(448): at android.widget.VideoView$3.onCompletion(VideoView.java:361)
07-05 17:52:22.121: E/AndroidRuntime(448): at android.media.MediaPlayer$EventHandler.handleMessage(MediaPlayer.java:1980)
07-05 17:52:22.121: E/AndroidRuntime(448): at android.os.Handler.dispatchMessage(Handler.java:99)
07-05 17:52:22.121: E/AndroidRuntime(448): at android.os.Looper.loop(Looper.java:137)
07-05 17:52:22.121: E/AndroidRuntime(448): at android.app.ActivityThread.main(ActivityThread.java:5041)
07-05 17:52:22.121: E/AndroidRuntime(448): at java.lang.reflect.Method.invokeNative(Native Method)
07-05 17:52:22.121: E/AndroidRuntime(448): at java.lang.reflect.Method.invoke(Method.java:511)
07-05 17:52:22.121: E/AndroidRuntime(448): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
07-05 17:52:22.121: E/AndroidRuntime(448): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
07-05 17:52:22.121: E/AndroidRuntime(448): at dalvik.system.NativeStart.main(Native Method)
07-05 17:52:22.131: W/ActivityManager(478): Force finishing activity com.demigod.biolab/com.ansca.corona.VideoActivity
07-05 17:52:22.271: D/dalvikvm(478): GC_FOR_ALLOC freed 708K, 29% free 17351K/24288K, paused 110ms, total 112ms
07-05 17:52:22.791: W/ActivityManager(478): Activity pause timeout for ActivityRecord{41e855c0 u0 com.demigod.biolab/com.ansca.corona.VideoActivity}
07-05 17:52:22.981: I/hwcomposer(125): Setting interactive mode: On
07-05 17:52:32.291: W/ActivityManager(478): Launch timeout has expired, giving up wake lock!
07-05 17:52:32.801: W/ActivityManager(478): Activity idle timeout for ActivityRecord{41ccb8d8 u0 com.demigod.biolab/com.ansca.corona.CoronaActivity}
答案 0 :(得分:0)
尝试在转到下一个场景之前删除视频
local myVideo
local onComplete = function()
--remove your video here
myVideo:removeSelf()
storyboard.gotoScene("menu")
end
myVideo = media.playVideo( "videos/logo.mp4", false, onComplete )
或者您使用不受支持的格式尝试访问此链接 http://docs.coronalabs.com/api/library/media/playVideo.html