mediaplayer play internet mp3 :java.io.FileNotFoundException: No content provider











up vote
0
down vote

favorite












This is my code:



public void playSound(String uri,int flag)
{
Uri uri1=Uri.parse(uri);
ContestVoteFragment fragment = (ContestVoteFragment) fragments.get(0);
if (fragment.playSound(flag))
{
if (mediaPlayer==null)
{
mediaPlayer=new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
try {
mediaPlayer.setDataSource(uri);
mediaPlayer.prepare();
} catch (IOException e) {
e.printStackTrace();
}
mediaPlayer.start();

}else {
mediaPlayer.stop();
mediaPlayer.reset();
mediaPlayer.release();
mediaPlayer=new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
try {
mediaPlayer.setDataSource(uri);
mediaPlayer.prepare();
} catch (IOException e) {
e.printStackTrace();
}
mediaPlayer.start();
}
}else {
if (mediaPlayer!=null)
{
if (mediaPlayer.isPlaying())
{
mediaPlayer.stop();
}
}
}
}
}


But when i play a internet mp3 ,the error message is Couldn't open http://p9snltngh.bkt.clouddn.com/Fs3M3Cq_Mkex9AsunJt57N22JQp2: java.io.FileNotFoundException: No content provider
i can’t understand because “http://p9snltngh.bkt.clouddn.com/FhEbUwGYcmQbXIVMVzd0GyPypDVC”this uri can play










share|improve this question






















  • Both the links did not open in Chrome.
    – Ümañg ßürmån
    Nov 8 at 6:37










  • I can open in Chrome….
    – Chord Chen
    Nov 8 at 6:41










  • It opened in Mozilla though.
    – Ümañg ßürmån
    Nov 8 at 6:44










  • Is URI a string?
    – Ümañg ßürmån
    Nov 8 at 6:47










  • Yes, is a string
    – Chord Chen
    Nov 8 at 6:48















up vote
0
down vote

favorite












This is my code:



public void playSound(String uri,int flag)
{
Uri uri1=Uri.parse(uri);
ContestVoteFragment fragment = (ContestVoteFragment) fragments.get(0);
if (fragment.playSound(flag))
{
if (mediaPlayer==null)
{
mediaPlayer=new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
try {
mediaPlayer.setDataSource(uri);
mediaPlayer.prepare();
} catch (IOException e) {
e.printStackTrace();
}
mediaPlayer.start();

}else {
mediaPlayer.stop();
mediaPlayer.reset();
mediaPlayer.release();
mediaPlayer=new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
try {
mediaPlayer.setDataSource(uri);
mediaPlayer.prepare();
} catch (IOException e) {
e.printStackTrace();
}
mediaPlayer.start();
}
}else {
if (mediaPlayer!=null)
{
if (mediaPlayer.isPlaying())
{
mediaPlayer.stop();
}
}
}
}
}


But when i play a internet mp3 ,the error message is Couldn't open http://p9snltngh.bkt.clouddn.com/Fs3M3Cq_Mkex9AsunJt57N22JQp2: java.io.FileNotFoundException: No content provider
i can’t understand because “http://p9snltngh.bkt.clouddn.com/FhEbUwGYcmQbXIVMVzd0GyPypDVC”this uri can play










share|improve this question






















  • Both the links did not open in Chrome.
    – Ümañg ßürmån
    Nov 8 at 6:37










  • I can open in Chrome….
    – Chord Chen
    Nov 8 at 6:41










  • It opened in Mozilla though.
    – Ümañg ßürmån
    Nov 8 at 6:44










  • Is URI a string?
    – Ümañg ßürmån
    Nov 8 at 6:47










  • Yes, is a string
    – Chord Chen
    Nov 8 at 6:48













up vote
0
down vote

favorite









up vote
0
down vote

favorite











This is my code:



public void playSound(String uri,int flag)
{
Uri uri1=Uri.parse(uri);
ContestVoteFragment fragment = (ContestVoteFragment) fragments.get(0);
if (fragment.playSound(flag))
{
if (mediaPlayer==null)
{
mediaPlayer=new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
try {
mediaPlayer.setDataSource(uri);
mediaPlayer.prepare();
} catch (IOException e) {
e.printStackTrace();
}
mediaPlayer.start();

}else {
mediaPlayer.stop();
mediaPlayer.reset();
mediaPlayer.release();
mediaPlayer=new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
try {
mediaPlayer.setDataSource(uri);
mediaPlayer.prepare();
} catch (IOException e) {
e.printStackTrace();
}
mediaPlayer.start();
}
}else {
if (mediaPlayer!=null)
{
if (mediaPlayer.isPlaying())
{
mediaPlayer.stop();
}
}
}
}
}


But when i play a internet mp3 ,the error message is Couldn't open http://p9snltngh.bkt.clouddn.com/Fs3M3Cq_Mkex9AsunJt57N22JQp2: java.io.FileNotFoundException: No content provider
i can’t understand because “http://p9snltngh.bkt.clouddn.com/FhEbUwGYcmQbXIVMVzd0GyPypDVC”this uri can play










share|improve this question













This is my code:



public void playSound(String uri,int flag)
{
Uri uri1=Uri.parse(uri);
ContestVoteFragment fragment = (ContestVoteFragment) fragments.get(0);
if (fragment.playSound(flag))
{
if (mediaPlayer==null)
{
mediaPlayer=new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
try {
mediaPlayer.setDataSource(uri);
mediaPlayer.prepare();
} catch (IOException e) {
e.printStackTrace();
}
mediaPlayer.start();

}else {
mediaPlayer.stop();
mediaPlayer.reset();
mediaPlayer.release();
mediaPlayer=new MediaPlayer();
mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);
try {
mediaPlayer.setDataSource(uri);
mediaPlayer.prepare();
} catch (IOException e) {
e.printStackTrace();
}
mediaPlayer.start();
}
}else {
if (mediaPlayer!=null)
{
if (mediaPlayer.isPlaying())
{
mediaPlayer.stop();
}
}
}
}
}


But when i play a internet mp3 ,the error message is Couldn't open http://p9snltngh.bkt.clouddn.com/Fs3M3Cq_Mkex9AsunJt57N22JQp2: java.io.FileNotFoundException: No content provider
i can’t understand because “http://p9snltngh.bkt.clouddn.com/FhEbUwGYcmQbXIVMVzd0GyPypDVC”this uri can play







android






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 8 at 6:30









Chord Chen

262




262












  • Both the links did not open in Chrome.
    – Ümañg ßürmån
    Nov 8 at 6:37










  • I can open in Chrome….
    – Chord Chen
    Nov 8 at 6:41










  • It opened in Mozilla though.
    – Ümañg ßürmån
    Nov 8 at 6:44










  • Is URI a string?
    – Ümañg ßürmån
    Nov 8 at 6:47










  • Yes, is a string
    – Chord Chen
    Nov 8 at 6:48


















  • Both the links did not open in Chrome.
    – Ümañg ßürmån
    Nov 8 at 6:37










  • I can open in Chrome….
    – Chord Chen
    Nov 8 at 6:41










  • It opened in Mozilla though.
    – Ümañg ßürmån
    Nov 8 at 6:44










  • Is URI a string?
    – Ümañg ßürmån
    Nov 8 at 6:47










  • Yes, is a string
    – Chord Chen
    Nov 8 at 6:48
















Both the links did not open in Chrome.
– Ümañg ßürmån
Nov 8 at 6:37




Both the links did not open in Chrome.
– Ümañg ßürmån
Nov 8 at 6:37












I can open in Chrome….
– Chord Chen
Nov 8 at 6:41




I can open in Chrome….
– Chord Chen
Nov 8 at 6:41












It opened in Mozilla though.
– Ümañg ßürmån
Nov 8 at 6:44




It opened in Mozilla though.
– Ümañg ßürmån
Nov 8 at 6:44












Is URI a string?
– Ümañg ßürmån
Nov 8 at 6:47




Is URI a string?
– Ümañg ßürmån
Nov 8 at 6:47












Yes, is a string
– Chord Chen
Nov 8 at 6:48




Yes, is a string
– Chord Chen
Nov 8 at 6:48












2 Answers
2






active

oldest

votes

















up vote
0
down vote













both links are working



public void playSound(String uri){
MediaPlayer mediaPlayer = new MediaPlayer();
try {
mediaPlayer.setDataSource(uri);
mediaPlayer.prepare();
mediaPlayer.start();
} catch (IOException e) {
e.printStackTrace();
}
}


happy coding :)






share|improve this answer





















  • I need it can play different uri...
    – Chord Chen
    Nov 8 at 6:52










  • yes you can change uri and play
    – Dinithe Pieris
    Nov 8 at 7:13


















up vote
0
down vote













Solution: You need to parse your String URI into the URI class. So,



Instead of:



 try {
mediaPlayer.setDataSource(uri);
mediaPlayer.prepare();
} catch (IOException e) {
e.printStackTrace();
}


Try like this:



 try {
mediaPlayer.setDataSource(this, Uri.parse(uri));
mediaPlayer.prepare();
} catch (IOException e) {
e.printStackTrace();
}


Please comment if any issues.






share|improve this answer





















  • OMG!thank you so much! it’s work!
    – Chord Chen
    Nov 8 at 7:04










  • @ChordChen I'm Glad it helped, I would appreciate if you can Upvote and Accept the solution, please :)
    – Ümañg ßürmån
    Nov 8 at 12:19











Your Answer






StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");

StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});

function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});


}
});














draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53202525%2fmediaplayer-play-internet-mp3-java-io-filenotfoundexception-no-content-provide%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes








up vote
0
down vote













both links are working



public void playSound(String uri){
MediaPlayer mediaPlayer = new MediaPlayer();
try {
mediaPlayer.setDataSource(uri);
mediaPlayer.prepare();
mediaPlayer.start();
} catch (IOException e) {
e.printStackTrace();
}
}


happy coding :)






share|improve this answer





















  • I need it can play different uri...
    – Chord Chen
    Nov 8 at 6:52










  • yes you can change uri and play
    – Dinithe Pieris
    Nov 8 at 7:13















up vote
0
down vote













both links are working



public void playSound(String uri){
MediaPlayer mediaPlayer = new MediaPlayer();
try {
mediaPlayer.setDataSource(uri);
mediaPlayer.prepare();
mediaPlayer.start();
} catch (IOException e) {
e.printStackTrace();
}
}


happy coding :)






share|improve this answer





















  • I need it can play different uri...
    – Chord Chen
    Nov 8 at 6:52










  • yes you can change uri and play
    – Dinithe Pieris
    Nov 8 at 7:13













up vote
0
down vote










up vote
0
down vote









both links are working



public void playSound(String uri){
MediaPlayer mediaPlayer = new MediaPlayer();
try {
mediaPlayer.setDataSource(uri);
mediaPlayer.prepare();
mediaPlayer.start();
} catch (IOException e) {
e.printStackTrace();
}
}


happy coding :)






share|improve this answer












both links are working



public void playSound(String uri){
MediaPlayer mediaPlayer = new MediaPlayer();
try {
mediaPlayer.setDataSource(uri);
mediaPlayer.prepare();
mediaPlayer.start();
} catch (IOException e) {
e.printStackTrace();
}
}


happy coding :)







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 8 at 6:46









Dinithe Pieris

77611635




77611635












  • I need it can play different uri...
    – Chord Chen
    Nov 8 at 6:52










  • yes you can change uri and play
    – Dinithe Pieris
    Nov 8 at 7:13


















  • I need it can play different uri...
    – Chord Chen
    Nov 8 at 6:52










  • yes you can change uri and play
    – Dinithe Pieris
    Nov 8 at 7:13
















I need it can play different uri...
– Chord Chen
Nov 8 at 6:52




I need it can play different uri...
– Chord Chen
Nov 8 at 6:52












yes you can change uri and play
– Dinithe Pieris
Nov 8 at 7:13




yes you can change uri and play
– Dinithe Pieris
Nov 8 at 7:13












up vote
0
down vote













Solution: You need to parse your String URI into the URI class. So,



Instead of:



 try {
mediaPlayer.setDataSource(uri);
mediaPlayer.prepare();
} catch (IOException e) {
e.printStackTrace();
}


Try like this:



 try {
mediaPlayer.setDataSource(this, Uri.parse(uri));
mediaPlayer.prepare();
} catch (IOException e) {
e.printStackTrace();
}


Please comment if any issues.






share|improve this answer





















  • OMG!thank you so much! it’s work!
    – Chord Chen
    Nov 8 at 7:04










  • @ChordChen I'm Glad it helped, I would appreciate if you can Upvote and Accept the solution, please :)
    – Ümañg ßürmån
    Nov 8 at 12:19















up vote
0
down vote













Solution: You need to parse your String URI into the URI class. So,



Instead of:



 try {
mediaPlayer.setDataSource(uri);
mediaPlayer.prepare();
} catch (IOException e) {
e.printStackTrace();
}


Try like this:



 try {
mediaPlayer.setDataSource(this, Uri.parse(uri));
mediaPlayer.prepare();
} catch (IOException e) {
e.printStackTrace();
}


Please comment if any issues.






share|improve this answer





















  • OMG!thank you so much! it’s work!
    – Chord Chen
    Nov 8 at 7:04










  • @ChordChen I'm Glad it helped, I would appreciate if you can Upvote and Accept the solution, please :)
    – Ümañg ßürmån
    Nov 8 at 12:19













up vote
0
down vote










up vote
0
down vote









Solution: You need to parse your String URI into the URI class. So,



Instead of:



 try {
mediaPlayer.setDataSource(uri);
mediaPlayer.prepare();
} catch (IOException e) {
e.printStackTrace();
}


Try like this:



 try {
mediaPlayer.setDataSource(this, Uri.parse(uri));
mediaPlayer.prepare();
} catch (IOException e) {
e.printStackTrace();
}


Please comment if any issues.






share|improve this answer












Solution: You need to parse your String URI into the URI class. So,



Instead of:



 try {
mediaPlayer.setDataSource(uri);
mediaPlayer.prepare();
} catch (IOException e) {
e.printStackTrace();
}


Try like this:



 try {
mediaPlayer.setDataSource(this, Uri.parse(uri));
mediaPlayer.prepare();
} catch (IOException e) {
e.printStackTrace();
}


Please comment if any issues.







share|improve this answer












share|improve this answer



share|improve this answer










answered Nov 8 at 6:52









Ümañg ßürmån

2,9483829




2,9483829












  • OMG!thank you so much! it’s work!
    – Chord Chen
    Nov 8 at 7:04










  • @ChordChen I'm Glad it helped, I would appreciate if you can Upvote and Accept the solution, please :)
    – Ümañg ßürmån
    Nov 8 at 12:19


















  • OMG!thank you so much! it’s work!
    – Chord Chen
    Nov 8 at 7:04










  • @ChordChen I'm Glad it helped, I would appreciate if you can Upvote and Accept the solution, please :)
    – Ümañg ßürmån
    Nov 8 at 12:19
















OMG!thank you so much! it’s work!
– Chord Chen
Nov 8 at 7:04




OMG!thank you so much! it’s work!
– Chord Chen
Nov 8 at 7:04












@ChordChen I'm Glad it helped, I would appreciate if you can Upvote and Accept the solution, please :)
– Ümañg ßürmån
Nov 8 at 12:19




@ChordChen I'm Glad it helped, I would appreciate if you can Upvote and Accept the solution, please :)
– Ümañg ßürmån
Nov 8 at 12:19


















draft saved

draft discarded




















































Thanks for contributing an answer to Stack Overflow!


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.





Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


Please pay close attention to the following guidance:


  • Please be sure to answer the question. Provide details and share your research!

But avoid



  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.


To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53202525%2fmediaplayer-play-internet-mp3-java-io-filenotfoundexception-no-content-provide%23new-answer', 'question_page');
}
);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown







這個網誌中的熱門文章

Xamarin.form Move up view when keyboard appear

Post-Redirect-Get with Spring WebFlux and Thymeleaf

Anylogic : not able to use stopDelay()