MediaPlayer.setDataSource Exception: NullPointerException Cause: Java.io.File.fixSlashes (filename)

I have a box and an app that plays videos from a file on an SD card. The application is launched when the mobile device is loaded. When the device reboots, the app waits for the SD card to be mounted, then it will navigate to the file path on the SD card and try to play the file using the MediaPlayer api. But the app crashes with downstream logs. The app works fine if the user starts the app manually while the device is running rather than booting.

09-22 18:53:39.700: W/System.err(1302): java.lang.NullPointerException
09-22 18:53:39.700: W/System.err(1302):     at java.io.File.fixSlashes(File.java:185)
09-22 18:53:39.700: W/System.err(1302):     at java.io.File.<init>(File.java:134)
09-22 18:53:39.700: W/System.err(1302):     at com.sherbet.taxi.FullVideoActivity.setUpVideoFrom(FullVideoActivity.java:225)
09-22 18:53:39.700: W/System.err(1302):     at com.sherbet.taxi.FullVideoActivity.onCreate(FullVideoActivity.java:112)
09-22 18:53:39.700: W/System.err(1302):     at android.app.Activity.performCreate(Activity.java:5008)
09-22 18:53:39.700: W/System.err(1302):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
09-22 18:53:39.700: W/System.err(1302):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2035)
09-22 18:53:39.700: W/System.err(1302):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2096)
09-22 18:53:39.700: W/System.err(1302):     at android.app.ActivityThread.access$600(ActivityThread.java:138)
09-22 18:53:39.700: W/System.err(1302):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1207)
09-22 18:53:39.700: W/System.err(1302):     at android.os.Handler.dispatchMessage(Handler.java:99)
09-22 18:53:39.700: W/System.err(1302):     at android.os.Looper.loop(Looper.java:213)
09-22 18:53:39.700: W/System.err(1302):     at android.app.ActivityThread.main(ActivityThread.java:4787)
09-22 18:53:39.700: W/System.err(1302):     at java.lang.reflect.Method.invokeNative(Native Method)
09-22 18:53:39.700: W/System.err(1302):     at java.lang.reflect.Method.invoke(Method.java:511)
09-22 18:53:39.700: W/System.err(1302):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
09-22 18:53:39.700: W/System.err(1302):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
09-22 18:53:39.700: W/System.err(1302):     at dalvik.system.NativeStart.main(Native Method)
09-22 18:53:39.730: E/MediaPlayer(1302): error (1, -2147483648)
09-22 18:53:39.830: E/MediaPlayer(1302): prepareAsync called in state 1
09-22 18:53:39.830: W/System.err(1302): java.lang.IllegalStateException
09-22 18:53:39.830: W/System.err(1302):     at android.media.MediaPlayer.prepare(Native Method)
09-22 18:53:39.830: W/System.err(1302):     at com.sherbet.taxi.FullVideoActivity.play(FullVideoActivity.java:187)
09-22 18:53:39.830: W/System.err(1302):     at com.sherbet.taxi.FullVideoActivity.surfaceChanged(FullVideoActivity.java:354)
09-22 18:53:39.830: W/System.err(1302):     at android.view.SurfaceView.updateWindow(SurfaceView.java:558)
09-22 18:53:39.840: W/System.err(1302):     at android.view.SurfaceView.access$000(SurfaceView.java:85)
09-22 18:53:39.840: W/System.err(1302):     at android.view.SurfaceView$3.onPreDraw(SurfaceView.java:173)
09-22 18:53:39.840: W/System.err(1302):     at android.view.ViewTreeObserver.dispatchOnPreDraw(ViewTreeObserver.java:671)
09-22 18:53:39.840: W/System.err(1302):     at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1828)
09-22 18:53:39.840: W/System.err(1302):     at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1004)
09-22 18:53:39.840: W/System.err(1302):     at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:4223)
09-22 18:53:39.840: W/System.err(1302):     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:725)
09-22 18:53:39.840: W/System.err(1302):     at android.view.Choreographer.doCallbacks(Choreographer.java:555)
09-22 18:53:39.840: W/System.err(1302):     at android.view.Choreographer.doFrame(Choreographer.java:525)
09-22 18:53:39.840: W/System.err(1302):     at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:711)
09-22 18:53:39.840: W/System.err(1302):     at android.os.Handler.handleCallback(Handler.java:615)
09-22 18:53:39.850: W/System.err(1302):     at android.os.Handler.dispatchMessage(Handler.java:92)
09-22 18:53:39.850: W/System.err(1302):     at android.os.Looper.loop(Looper.java:213)
09-22 18:53:39.850: W/System.err(1302):     at android.app.ActivityThread.main(ActivityThread.java:4787)
09-22 18:53:39.850: W/System.err(1302):     at java.lang.reflect.Method.invokeNative(Native Method)
09-22 18:53:39.850: W/System.err(1302):     at java.lang.reflect.Method.invoke(Method.java:511)
09-22 18:53:39.850: W/System.err(1302):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
09-22 18:53:39.850: W/System.err(1302):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
09-22 18:53:39.850: W/System.err(1302):     at dalvik.system.NativeStart.main(Native Method)
09-22 18:53:39.860: E/MediaPlayer(1302): Error (1,-2147483648)

      

Code:

File file = new File(videoUrl);
file.setReadable(true, false);
Utils.ShowLogMsg("filepath: " + file.getAbsolutePath()
                + " exists: " + file.exists());
FileInputStream inputStream = new FileInputStream(file);
FileDescriptor fd = inputStream.getFD();
Utils.ShowLogMsg("file length: " + file.length());
**

mPlayer.setDataSource(fd, 0, file.length());
        inputStream.close();

**

      

The application runs on the highlighted line of code. Can anyone help me to solve this problem.

Thank you Ishan Jain

+3
android file-io file-descriptor media-player android-sdcard


source to share


No one has answered this question yet

Check out similar questions:

140
Failed to create app com.android.tools.fd.runtime.BootstrapApplication?
ten
Play local m3u8 file on android display showing setDataSourceFD failed: status = 0x80000000
five
Android ANR / Crash on version 4.4
five
The power of video video is closed on Micromax Canvas magnus
1
How to resolve obsolete ones?
1
Android camera can't connect to service
0
RuntimeException: Unable to connect to camera service?
0
android locationlistener return null value
0
Error hiding the canvas game
-4
java.lang.NumberFormatException: for input line: "21:30"



All Articles
Loading...
X
Show
Funny
Dev
Pics