• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

PLAY several players simulaneouly ?

 
Ould Nadif
Ranch Hand
Posts: 184
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Eduardo Marques
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Ranch Hand
Posts: 231
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It may happen that your device does not support simultaneous players though
 
Ould Nadif
Ranch Hand
Posts: 184
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic