Hi all,
i want to create a media player which plays the mp3 files from server. i hav only idea of it but unaware from implementation. what i have to done for this please tell me.what is the logic for it.
Hi all,
i want to create a media player which plays the mp3 files from server. i hav only idea of it but unaware from implementation. what i have to done for this please tell me.what is the logic for it.
Hi,
You just want to play the file from server itself on your handset...right...not want to download..right
For this you have to follow these steps,
1.You must have the location of mp3 file...URL of the file,
2.Open the HTTP connection against that URL,
3.Create the player instance in order to play the file,
4.Play the file using the player instance,
Mark one more thing that call all the life cycle methods before you actually play the file,
First you read these lines..very much helpful,
http://www.devx.com/wireless/Article/20911/1954
http://today.java.net/pub/a/today/2005/09/27/j2me4.html
Then below is the code in order to play the file,
public void run()
{
try
{
String url = "http://server/audio.mp3";
HttpConnection conn = (HttpConnection)Connector.open(url,
Connector.READ_WRITE);
InputStream is = conn.openInputStream();
player = Manager.createPlayer(is,"audio/mpeg");
player.realize();
// get volume control for player and set volume to max
vc = (VolumeControl) player.getControl("VolumeControl");
if(vc != null)
{
vc.setLevel(100);
}
player.prefetch();
player.start();
}
catch(Exception e)
{}
}
I hope these lines can help you in any means,
Thanks
Thanks with Regards,
R a j - The K e r n e l
Join Delhi-NCR Nokia Developer's Community,