============ Problem Description ============
public boolean playmusic (int listposition) {//playbtn.setbackgroundresource (r.drawable.play_selector); Mp3info mp3info = Mp3infos.get (listposition);//musictitle.settext (Mp3info.gettitle ());/*intent Intent = new Intent ( This.getactivity (), Playerservice.class), Intent.setaction ("Com.wyj.media.MUSIC_SERVICE"); Intent.putextra (" Listposition ", listposition); Intent.putextra (" url ", Mp3info.geturl ()); Intent.putextra (" MSG ", AppConstant.PlayerMsg.PLAY_MSG); this.getactivity (). StartService (intent); */path=mp3info.geturl (); try {//INITLRC ( ); Mediaplayer.reset ();//restore the parameters to the initial state mediaplayer.setdatasource (path); Mediaplayer.prepare (); Buffer Mediaplayer.start (); Start play} catch (Exception e) {e.printstacktrace ();} LOG.D (TAG, "Method Playmusic () has been called!"); LOG.D (TAG, "The path of this song is:" +path); return true;}
I do not know if there is a problem with this code, after testing, this method will be called when the song entry is clicked, but there is no music to play, ask you to guide the maze
============ Solution 1============
There is no problem with the method call order of music playback, check that the path to the music file is correct, and see the log that was printed when the music was played (what is the catch exception?). )
============ Solution 2============
Support 1 floor, put log in catch, print E.
============ Solution 3============
MediaPlayer not materialized.
============ Solution 4============
MediaPlayer not materialized ~ ...
Android Audio does not play a problem