File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Java Micro Edition and the fly likes PLAY several players simulaneouly ? Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Mobile » Java Micro Edition
Reply Bookmark "PLAY several players simulaneouly ?" Watch "PLAY several players simulaneouly ?" New topic
Author

PLAY several players simulaneouly ?

Ould Nadif
Ranch Hand

Joined: Jan 21, 2004
Posts: 184
Hi all,

I would like play severals songs simulaneous. I could play both individually.

How can i do to play severals simulaneouly.
I tried that code but it failed:

Player pMIDI, pMP3;
InputStream isMIDI,isMP3;

isMIDI = getClass().getResourceAsStream("/test.mid");
isMP3 = getClass().getResourceAsStream("/test.mp3");

pMIDI = Manager.createPlayer(isMIDI,"audio/midi");
pMP3 = Manager.createPlayer(isMP3,"audio/mpeg");


pMIDI .start();
pMP3.start();

OULD NADIF


We are ones that build the world, thus build it well.
Eduardo Marques
Ranch Hand

Joined: Feb 19, 2005
Posts: 231
You must set the same TimeBase for the two players.

It is not guaranteed that this works for all devices/media types, but give it a try:

You may obtain the system timebase using:
Timebase b = Manager.getSystemTimeBase();

and set it for the players using Player.setTimeBase().
You must set the same TimeBase for all Players you wish to synchronize.


Eduardo Marques
Get ready for your SCMAD certification at J2MECertificate.com - See what all the buzz is about ...
Eduardo Marques
Ranch Hand

Joined: Feb 19, 2005
Posts: 231
It may happen that your device does not support simultaneous players though
Ould Nadif
Ranch Hand

Joined: Jan 21, 2004
Posts: 184
Hi all,

Thanks you for your reply.

By the way I tried your code. I seems that it doesn't work:Maybe somethings are missing:

I tried with 6680 Nokia and V600i of sony Ericsson. Both it doesn't work.


try{

isMIDI = getClass().getResourceAsStream("/test2.mid");
isMP3 = getClass().getResourceAsStream("/test.mp3");


pMIDI = Manager.createPlayer(isMIDI,"audio/midi");
b = Manager.getSystemTimeBase();
pMIDI.setTimeBase(b);

pMP3 = Manager.createPlayer(isMP3,"audio/mpeg");
pMP3.setTimeBase(b);

pMIDI.start();
pMP3.start();



} catch (Exception ioe) {
System.out.println( "Pb avec le stockage");
ioe.printStackTrace();
}

Thanks in advance for your help.

OULD NADIF
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: PLAY several players simulaneouly ?
 
Similar Threads
Playing Amr
MIDlet Audio Doesn't Work
unable to playback .mp3 file in WTK
AUDIO PLAYERS
Play sound .aac