Play Video on Android

Dear Joshua, 

on the Sony xperia sola (android phone) the return to app on complete function doesn’t work. the movie freezes on the last frame and does not return to the app. I m also testing on a Google Nexus S there it works fine.

The back button also doesnt work, the movie freezes, when you press it, and stays in front of the app. You can only hear the app continue behind the frozen frame.

I m afraid this is the case on many androids…

I start the movie with:

media.playVideo( “movie1.mp4”, system.ResourceDirectory, false, onCompleteHandler)

we get this stack-trace alot:

java.lang.NullPointerException at com.ansca.corona.VideoActivity$1.onCompletion(VideoActivity.java:48) at android.widget.VideoView$3.onCompletion(VideoView.java:345) at android.media.MediaPlayer$EventHandler.handleMessage(MediaPlayer.java:1528) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4447) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) at dalvik.system.NativeStart.main(Native Method)

To create the mp4’s we used MediaEncoder with this settings:

H.264 Android Phone & Tablet - 480p 25 640\*480, 25 fps, Progressive VBR, 2 pass, Target 0.50 Mbps, Max 0.80 Mbps AAC, 128 kbps, 44 kHz, Stereo  

Dear Joshua, 

on the Sony xperia sola (android phone) the return to app on complete function doesn’t work. the movie freezes on the last frame and does not return to the app. I m also testing on a Google Nexus S there it works fine.

The back button also doesnt work, the movie freezes, when you press it, and stays in front of the app. You can only hear the app continue behind the frozen frame.

I m afraid this is the case on many androids…

I start the movie with:

media.playVideo( “movie1.mp4”, system.ResourceDirectory, false, onCompleteHandler)

we get this stack-trace alot:

java.lang.NullPointerException at com.ansca.corona.VideoActivity$1.onCompletion(VideoActivity.java:48) at android.widget.VideoView$3.onCompletion(VideoView.java:345) at android.media.MediaPlayer$EventHandler.handleMessage(MediaPlayer.java:1528) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:137) at android.app.ActivityThread.main(ActivityThread.java:4447) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551) at dalvik.system.NativeStart.main(Native Method)

To create the mp4’s we used MediaEncoder with this settings:

H.264 Android Phone & Tablet - 480p 25 640\*480, 25 fps, Progressive VBR, 2 pass, Target 0.50 Mbps, Max 0.80 Mbps AAC, 128 kbps, 44 kHz, Stereo  

Joshua,

I’m having madmulti’s same problem. My application uses media.playVideo, and it works fine on iOS and OSX Simulator. But when I run it on Android, I’m getting exactly the same problem.

java.lang.NullPointerException

at com.ansca.corona.VideoActivity$1.onCompletion(VideoActivity.java:48)
at android.widget.VideoView$3.onCompletion(VideoView.java:345)
at android.media.MediaPlayer$EventHandler.handleMessage(MediaPlayer.java:1528)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4447)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)

I get my videos from the Documents directory.

But when I run an application that uses video from the Resources Directory, it runs without any problem on Android… it’s really trick…

I need help to solve this issue. I read something about a problem with VideoView class on Android 2.2. (http://stackoverflow.com/questions/7510440/oncompletion-of-mediaplayer-on-android-device-and-resizing-video).

Any help?!

Thanks.

Solved. I had used the native.requestExit() in a function on Android, when I called the video. Thanks.

Joshua,

I’m having madmulti’s same problem. My application uses media.playVideo, and it works fine on iOS and OSX Simulator. But when I run it on Android, I’m getting exactly the same problem.

java.lang.NullPointerException

at com.ansca.corona.VideoActivity$1.onCompletion(VideoActivity.java:48)
at android.widget.VideoView$3.onCompletion(VideoView.java:345)
at android.media.MediaPlayer$EventHandler.handleMessage(MediaPlayer.java:1528)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4447)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
at dalvik.system.NativeStart.main(Native Method)

I get my videos from the Documents directory.

But when I run an application that uses video from the Resources Directory, it runs without any problem on Android… it’s really trick…

I need help to solve this issue. I read something about a problem with VideoView class on Android 2.2. (http://stackoverflow.com/questions/7510440/oncompletion-of-mediaplayer-on-android-device-and-resizing-video).

Any help?!

Thanks.

Solved. I had used the native.requestExit() in a function on Android, when I called the video. Thanks.

Hi, i am having some troubles to play youtube video using media.playVideo. When app runs screen became black and no video is played. Any advice??Thanks

Hi, i am having some troubles to play youtube video using media.playVideo. When app runs screen became black and no video is played. Any advice??Thanks