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
android
|
show 1 more comment
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
android
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
IsURI
a string?
– Ümañg ßürmån
Nov 8 at 6:47
Yes, is a string
– Chord Chen
Nov 8 at 6:48
|
show 1 more comment
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
android
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
android
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
IsURI
a string?
– Ümañg ßürmån
Nov 8 at 6:47
Yes, is a string
– Chord Chen
Nov 8 at 6:48
|
show 1 more comment
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
IsURI
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
|
show 1 more comment
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 :)
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
add a comment |
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.
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
add a comment |
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 :)
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
add a comment |
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 :)
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
add a comment |
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 :)
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 :)
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
add a comment |
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
add a comment |
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.
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
add a comment |
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.
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
add a comment |
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.
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.
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
add a comment |
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
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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