Skip to main content

PrimaryAudioControl

2 replies [Last post]
dirkjansen
Offline
Joined: 2008-03-21

Hello,

I'm having some problems with my JMF player instance on my bd-j disc. the disc contains several playlists, of which some have only one audio stream, some have two audio streams with German & English audio, and some have two streams with stereo & dolby.
so I want the video to change to the correct stream when selecting a playlist, e.g. when the audio is set to English instead of German (standard) or dolby instead of stereo (standard). I'm currently using two methods for this:

public void setAudioLanguage(String lang) {
if (primaryAudioControl != null) {
String[] languages = primaryAudioControl.listAvailableLanguages();
try {
// if the current playlist features more than one audio stream & the language variable is set to "german"
if (languages.length > 1 && lang == "ger") {
primaryAudioControl.selectLanguage("deu");
} else if (languages.length > 1 && lang == "eng"){
primaryAudioControl.selectLanguage("eng");
}
} catch (LanguageNotAvailableException e) {
} catch (NotAuthorizedException e) {
}
}
}

public void setDolby(boolean dolby) {
if (primaryAudioControl != null) {
int[] audioStreamIDs = primaryAudioControl.listAvailableStreamNumbers();
String[] languages = primaryAudioControl.listAvailableLanguages();
try {
// the "languages" array length has to be 1 to be sure there is only one language and the second audio stream isn't an English one but a dolby stream
if (audioStreamIDs.length > 1 && languages.length == 1 && dolby) {
primaryAudioControl.selectStreamNumber(audioStreamIDs[1]);
}
} catch (StreamNotAvailableException e) {
}
}
}

the problem is, the setDolby() method doesn't seem to work at all, when I'm using it, the whole BD-J application even seems to halt while the video keeps playing (I'm currently testing with Cyberlink PowerDVD).
The setAudioLanguage() method seems to work fine, up to the point when I'm selecting a video that hasn't any English stream, then the next video which should have an English stream automatically starts with the first (German) audio stream, although the language variable is still set to "English".
Is it possible that the listAvailableLanguages() method for PrimaryAudioControl lists the languages not only for the current playlist but for all available playlists? Then the error would make sense in some way... but how can I find out if the current playlist has two audio streams? I assume the listAvailableStreamNumbers() also does not only list the stream numbers of the current playlist but of all playlists.
Or do i have to get a new PrimaryAudioControl instance every time the JMF player changes its playlist? Or am I making some stupid mistake with the arrays "audioStreamIDs" and "languages"?
The setAudioLanguage() and setDolby() methods are called within a selectPlaylist() method, right after player.start().

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
stanavzan
Offline
Joined: 2006-11-07

Hi Dirk,

A disclaimer: I haven't done this in practice, so I'm looking at this purely from the specification point of view,

JMF controls can be quite sensitive to two facts: whether the video is currently playing, and where exactly within the current video you are at the moment. Basically, the approach that is more or less guaranteed to work from the specification point of view would be to start a new video, to wait for StartEvent to be delivered, and only then to query available languages and audio stream numbers, perform selection etc. Perhaps, you could try this out and see if it helps.

Best regards,
Stan

dirkjansen
Offline
Joined: 2008-03-21

Hi Stan,

hey thanks, the one with the StartEvent seems to help! Previously i used setDolby() and setAudioLanguage() right after player.start(), and that seemed to be the problem. Now i'm using the methods when my ControllerListener for the player receives a StartEvent and it works.
Regards,

Dirk