Android Audio does not play a problem

Source: Internet
Author: User

============ 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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.