Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

My URL contains number medial related URLs which we have to play in media player. When i am passing my any media url with extension .mp3 or .mp4. it plays but whn i am passing any url that holds list of URLs then it is not playing in medi payer. Please tell me how can i resolve this issue ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
171 views
Welcome To Ask or Share your Answers For Others

1 Answer

this will help you:

private void PlayOnlineUrl() {  
            String url = "http://www.gaana.mp3"; // your URL here  
            MediaPlayer mediaPlayer = new MediaPlayer();  
            mediaPlayer.setAudioStreamType(AudioManager.STREAM_MUSIC);  
            try {  
                 mediaPlayer.setDataSource(url);  
            } catch (IllegalArgumentException e) {  
                 e.printStackTrace();  
            } catch (SecurityException e) {  
                 e.printStackTrace();  
            } catch (IllegalStateException e) {  
                 e.printStackTrace();  
            } catch (IOException e) {  
                 e.printStackTrace();  
            }  
            mediaPlayer.prepareAsync();  
            // You can show progress dialog here untill it prepared to play  
            mediaPlayer.setOnPreparedListener(new OnPreparedListener() {  
                 @Override  
                 public void onPrepared(MediaPlayer mp) {  
                      // Now dismis progress dialog, Media palyer will start playing  
                      mp.start();  
                 }  
            });  
            mediaPlayer.setOnErrorListener(new OnErrorListener() {  
                 @Override  
                 public boolean onError(MediaPlayer mp, int what, int extra) {  
                      // dissmiss progress bar here. It will come here when  
                      // MediaPlayer  
                      // is not able to play file. You can show error message to user  
                      return false;  
                 }  
            });  
       } 

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...