Stream an audio .pls in android

前端 未结 4 1430
刺人心
刺人心 2021-01-06 09:16

I\'m making an radio like application that uses streaming. Here i need to stream the audio from a link (http://somedomain/some.pls).

I have created

4条回答
  •  悲哀的现实
    2021-01-06 09:46

    Mediaplayer api from android supports streaming a .pls file, but the API is not best option & the documentation is not well. The life cycle diagram given in the official documentation gives valuable information but may be confusing at a first glance.

    A sample code snippet:

    MediaPlayer mp;
    mp=MediaPlayer.create(getApplicationContext(),Uri.parse(url))
    Example url of  .pls file http://50.xx.xxx.xx:xx40/)
    
    mp.start();
    mp.pause();
    mp.release() (or mp.reset() as applicable)
    

    http://developer.android.com/reference/android/media/MediaPlayer.html#create(android.content.Context, android.net.Uri)

    There are listeners/callback available with MediaPlayer api but it is really problematic to a App developer working on audio streaming.

    The static constructor used in the code snippet is suggested/better approach to create the media object with URI (like http url with host and port.) But the call back functions can't be used by developer because the prepare is called by the constructor itself.

    The created object can be played/stopped in a asyn thread (AsyncTask api).

    The android official documentation does not give any 'get method' to get the status of the mediaplayer.

    I welcome android app developers to talk on this;

    and I wish frame work developers provide more accurate documentation - how much it supports or what's importance & vision of Google Inc and Android framework development team on Mediaplayer API for audio streaming with urls.

    If some need help from me or share their experience let's please talk on MediaPlayer api for audio streaming @ http://stackoverflow.com or android developers blog (android-developers.blogspot.com).

    Regards Sree Ramakrishna Program Manager & Android developer @ New Mek Solutions,Hyderabad.

提交回复
热议问题