I am using the media player on my app, but sometimes the app crashes, not always, and I Put log d. My code to know what is the problem and what I get here:
03-17 15: 50: 17.942: D / MER (16 9 7): Vendici photo 03-17 15: 50: 17.942: D / MER (16 9 7): Perifix Lexoose 03-17 15: 50: 17.942: D / Honey Mrinda (16 9 7): Honey Mrinda 03-17 15: 50: 17.942: D / Mound O (16 9 7): Mringa O 03- 17 15: 50: 17.942: D / PerPIQET (16 9 7): Epoxy Lexoose 03-17 15: 50: 17.942: W / Dalyvikam (16 9 7): Thread = 1 : Thread with no exception (Group = 0x40 F 9 F) 03-17 15: 50: 17.952: E / Android Random (16 9 7): d The exception: the main 03-17 15: 50: 17.952: E / Android Rentaim (16 9 7): java.lang.NullPointerException 03-17 15: 50: 17.952: E / Androidrentaim (16907): com.albstudents.flakki. Gjeegjeza.Play.Lexoje (Play.java:390) 03-17 15: 50: 17.952: e / Androidrentaim (16 9 7): on com.albstudents.flakki.Gjeegjeza.Play.mer (Play.java:137) 03 -17 15: 50: 17.952: E / Android Runtime (16 9 7): $ 1 (Com.albstudents.flakki.Gjeegjeza.Play.access) $ 1 (Play.java:105) 03-17 15: 50: 17.952: E / Androidrentaim (16 9 7): 03-17 $ MyCounter.onFinish (Play.java.303) on com.albstudents.flakki.Gjeegjeza.play 15: 50: 17.952: e / Android Rentaim (16 9 7): Android. Countdown timer $ 1.handleMessage (CountDownTimer.java:118) 03-17 15: 50: 17.952: E / Android Random (16 9 7): Android.OS. Handler Dispect Message (Handler. Java: 99) 03-17 15: 50: 17.952: E / Android Random (16 9 7): Android.OS Lopper On Loop (Looper.java:137) 03-17 15: 50: 17.952: E / Android Random (16 9 7): Android. App Aktivtitredkmain (Gtividhitredkxavaatti 24) 03-17 15: 50: 17.952: E / Androidrentaim (16 9 7): .lang.reflect.Method.invokeNative (Native Method Java) 03-17 15: 50: 17.952: e / Android Rentaim (16 9 7): at java.lang.reflect.Method.invoke (method. Java 0511) 03-17 15: 50: 17.952: e / Android Rentaim (16 9 7): com.android.internal .os.ZygoteInit $ MethodAndArgsCaller.run (ZygoteInit.java:817) 03-17 15: 50: 17.952: e / Androidrentaim (16907): co MkandroidkinternalkoskZygoteInitkmain (Jhigoteintkjawa Titi 84) 03-17 15: 50: 17.952: E / Android Random (16 9 7): Dalwik. System On the netstart.mine (the default method)
the code happens when there is an error ...
Private Zero Lexoza () {Log D. ("Marda O", "Menda O"); Try {Log D. ("PERPIQET", "Perpetual Lexoose"); // error here is PlayM (FolderiS); } Hold (invalid record exception E) {message box ("Merpele", E. messages (.) ToString (), e.get (.) ToString ()); E.printStackTrace (); } Hold (Invalid State Exception e) {Message Box ("Merplete 1", E. Messages). ToString (), E.Gate (.) ToString ()); E.printStackTrace (); } Grip (IOE EXPRESS E) {Message Box ("Merple 2", EZET Message (). Toasting (), E.Gate (Coz.). Toasting ()); E.printStackTrace (); }}
PlayM code is:
Public Zero Playmay (string folder) removes illegal useless conclusions, illegalstate exception, IOException {AssetFileDescriptor = this. GetAssets () .openFd (folder + "/ Leximi.mp3"); Long start = descriptor .getStartOffset (); Long end = descriptor Tags (); MediaPlayer.setAudioStreamType (AudioManager.STREAM_MUSIC); Mediaplayer.setDataSource (descriptor.getFileDescriptor (), start, end); MediaPlayer.prepare (); MediaPlayer.start (); }
and repeatedly clicks the player, but when I call PlayerClicks:
releaseMediaPlayer (); Mediaplayer = new media player ();
and the release media player code is:
Private Zero Release Media Player (if {mediaplayer! = Null} {if (mediaplayer.isplaying ()) {MediaPlayer.stop (); } Mediaplayer.release (); Mediaplayer = null; Thanks .. Any help would be greatly appreciated ..
I got the solution ... The problem was, when I want to play a sound, I always declare a media player ...
mediaplayer .release (); Mediaplayer = null; Mediaplayer = new media player ();
No, I only use it:
mediaPlayer.reset (); MediaPlayer.setAudioStreamType (AudioManager.STREAM_MUSIC); Mediaplayer.setDataSource (descriptor.getFileDescriptor (), start, end); MediaPlayer.prepare (); MediaPlayer.start ();
No comments:
Post a Comment