Switching Audio
Hi,
I've been reading through the book of the http://www.interactivetvweb.org web site, but I'm don't really get how to switch audio streams.
My application has a couple of different audio streams (one for each language) and I want to swap between them. Am I right in thinking that I'm supposed to be using the JMF API's to set the source?
So far I've obtained my default Player object and constructed a "dvb://x.y.z." locator object to point at my audio stream. By how to I associate the two?
I could use the javax.media.Manager.createDataSource(), but I can't pass the "dvb://x.y.z" sting into the constructor because I get a malformedURL exception. The book implied that the other constructor (using a MediaLocator) is not the sort of thing I should be playing with...
I'm confused :-(
[834 byte] By [
zeb2a] at [2007-10-2 1:35:32]

hy,
I did never implement it, but I think the way to go is to use
javax.tv.media.MediaSelectControl.
Something like (after you have got a player):
import java.tv.media.*;
MediaSelectControl languageControl = (MediaSelectControl) player.getControl("MediaSelectControl");
languageControl.replace(Locator fromComponent, Locator toComponent) ;
Where fromComponent is to orinigal language locator (dvb://x.y.a, and toComponent is the new locator dvb://x.y.b)
I hope this works :), can you give feedback if it (doesn't) work?
TDRa at 2007-7-15 18:58:46 >

Hi TDR,
That's for the info - Once I get my locators sorted out it worked perfectly :-)
Just for my own curiosity, When a service is specified in the form
dvb://<onID>.<tsID>.<sID>[.<ctag>&[<ctag>]]
What does the final &<ctag> get used for?
Thanks!
zeb4a at 2007-7-15 18:58:46 >

The final &ctag is the same as the former one : it's a component tag.
As the locator is formed as: dvb://onid.tsid.sid.ctag1&ctag2
That means you want to get two components which their component tag name are tag1 and tag2.
Tha'ts my opion.; ) Hope it's useful for you.
Cool - does that mean I should be able to switch the audio and video at the same time wit some thing like:
import java.tv.media.*;
String s = "dvb://12.34.56.<Audio Tag>&<Video Tag>;
Locator x = LocatorFactory.getInstance().createLocator( s );
MediaSelectControl languageControl = (MediaSelectControl) player.getControl( "MediaSelectControl" );
languageControl.select( x ) ;
Z
zeb5a at 2007-7-15 18:58:46 >

Hello, I'm trying to switch between 2 audios stream. Here is part of the code I've tried. It doesn't work and I don't know if the locators are corrects.
media_loc_audio203 = new MediaLocator("dvb://1.3.1.203"); //203 is the PID for audio1
media_loc_audio204 = new MediaLocator("dvb://1.3.1.204"); //204 is yhe PID fo audio2
public void cambiarAudio()
{
DataSource datos = null;
try
{
//creamos la fuente de datos
datos = javax.media.Manager.createDataSource(media_loc_audio203);
//conectamos la fuente de datos con el lugar especificado por el locator
datos.connect();
//comenzamos la transferencia de datos desde el DataSource hacia el Player
datos.start();
player = javax.media.Manager.createPlayer(datos);
player.start();
if(player != null)
{
MediaSelectControl languageControl = (MediaSelectControl) player.getControl("MediaSelectControl");
//convertimos el MediaLocator media_loc_audio203 en Locator loc_audio203 porque
//es el tipo que usa MediaSelectControl
String string203 = media_loc_audio203.toExternalForm();
try
{
loc_audio203 = LocatorFactory.getInstance().createLocator(string203);
}
catch (MalformedLocatorException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
//convertimos el MediaLocator media_loc_audio204 en Locator loc_audio204 porque
//es el tipo que usa MediaSelectControl
String string204 = media_loc_audio204.toExternalForm();
try
{
loc_audio204 = LocatorFactory.getInstance().createLocator(string204);
}
catch (MalformedLocatorException e)
{
// TODO Auto-generated catch block
e.printStackTrace();
}
languageControl.replace(loc_audio203,loc_audio204) ;
}
}
Could anybody help me?
Thanks