When I use the MediaPlayer in Android to play a song provided by the network URI , there is a problem as above, the problem is solved because there is no corresponding play permission caused . WORKAROUND: You need to add such a piece of code in androidmanifest.xml to get the play permission to access your manifest file.
<uses-permission android:name= "Android.permission.INTERNET"/>
Network playback The code for the song provided by the specified URL is as follows:
/*
* Network resources
*/
MediaPlayerMediaplayer=new MediaPlayer ();
String path= "Http://music.baidu.com/data/music/file?Link=http://yinyueshiting.baidu.com/data2/music/3566287/29237101437253261128.mp3?xcode=fc3ef977c9fa9bdf4394f800f7f2550e&song_id=2923710 ";
Mediaplayer.setdatasource (path);Set up a data source for MediaPlayer
Mediaplayer.prepare ();Ready to play
Mediaplayer.start ();Start playback
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Java.io.IOException:setDataSource failed.: Resolution of status=0x80000000 problems