I need to play audio file from remote server in my app. I could play when I tested with localhost server (using WAMP). When the same file supplied from the server it is not working.. The file has no extension and the content is MP3
String fileUrl = "http://192.168.1.131/myproject/songs/xyz";
String url = "http://myserver/songs/xyz"; //(myserver -> A remote server)
mVideoView.setVideoURI(Uri.parse(fileUrl));
mVideoView.requestFocus();
Also I need to have a better control over player.
Please help...
If you are writing Java programs to play media files, then the first port of call is the MediaPlayer class. Typical code to play a file using the streaming mechanism of MediaPlayer is
Wake Lock Permission - If your player application needs to keep the screen from dimming or the processor from sleeping, or uses the MediaPlayer.setScreenOnWhilePlaying() or MediaPlayer.setWakeMode() methods, you must request this permission.
The answer provided above provides synchronous fetching and playing, meaning currently executing thread will be blocked until prepare() is completed.
prepareAsync() can be used instead to "prepare" the stream asynchronously. You also will need to handle onPrepared() event to start playing.
Add OnPrepared event handler:
Still, apparently there is no way to configure streaming buffer size. Frustrating...