Change Audio Track?
#1
I have some TV Shows that have multiple Audio Tacks (German and English).
When I watch these series, I always want to have the English audio, but when I have friends over I would like to simply switch the default language to German.

Since there doesn't seem to be an add-on for that, I'd like to write one.
But I'm wondering if that's even possible. I would probably need a callback function that is called every time a video is played, a function to get a list or count of all audio tracks of the video and a function that I can use to select the audio track.

I hope someone with some experience here can help me. Smile

Best regards,
forivon
Reply
#2
Huh
Ability to select an audio or a subs track from multiple audio or subtitles tracks is a standard XBMC functionality.
Reply
#3
Yeah, but when you are going to watch 10 episodes of a tv series, then you don't really want to select the right audio track every time a new episode starts.
That's why I want to write the add on.

The add-on should simply have an option to always select audio track #x or maybe even an option to automatically detect the languages and select the one you configure it to.
Reply
#4
http://mirrors.xbmc.org/docs/python-docs...dioStreams

I think that you would want a service that toggles between two languages when an addon is run.

It could detect when the player starts:
http://mirrors.xbmc.org/docs/python-docs...ackStarted

And determine which audio track to play and then set it:
http://mirrors.xbmc.org/docs/python-docs...udioStream
Reply
#5
I've never written anything in python before, but would that run as an add-on?

Code:
import xbmc
myPlayer = xbmc.Player();

language = "english"

def onPlayBackResumed():
    OnPlay();
    return

def onPlayBackSeekChapter():
    OnPlay();
    return

def onPlayBackStarted():
    OnPlay();
    return

def OnPlay():
    myPlayer.getAvailableAudioStreams()
    i = 0;
    for audioStream in list:
        i += 1
        print audioStream
        if language in audioStream:
            myPlayer.setAudioStream(i)
            break
    return

Is there some kind of quick manual that would tell me how I can run the script in XBMC? I really don't feel like learning the whole system for such a little add-on.
Reply
#6
No, I dont think that would run, but its the right instincts.

I have some movies that always have subtitles when they start and always have the wrong audio track playing as well.

So I created this service to always turn subtitles off when something is playing and to switch to the first 'eng' audio track (if one exists).

https://github.com/KODeKarnage/service.english.only

It should give you the idea of the structure you need.

Otherwise there is the wiki. Though that is a little hit and miss.
Reply
#7
Thanks! This will probably help a lot!
Though I'm a bit confused. What is it with the global var check_audio? Couldn't we handle this inside the callback function?
This way we could spare the main function and the while loop which is constantly running. Or is this really necessary?
Reply
#8
The while loop has to be constantly running to pick up the OnPlaybackStarted.

The global variable is a quick hack. Smile
Reply
#9
Maybe I'm missing something here, but XBMC has settings to set default languages for audio and subs, provided that audio and subs tracks have proper language tags.
Reply
#10
Where are these settings? I couldn't find them by searching manually and I even googled for it and found nothing...

edit: I could find the subtitle options and there was an option to set the default DVD region, I also found general language/region settings under Appearence, but all these options do not affect the audio stream chosen by XBMC...
Reply
#11
(2014-06-27, 08:58)forivon Wrote: Where are these settings? I couldn't find them by searching manually and I even googled for it and found nothing...

I also found general language/region settings under Appearence, but all these options do not affect the audio stream chosen by XBMC...

I guess, you haven't switched your settings to 'Expert' level.
Reply
#12
I have set them to the highest level.
Reply
#13
Where did you find the option and what exactly was the name?
Do you even use the default skin?
Reply
#14
hello?
Reply

Logout Mark Read Team Forum Stats Members Help
Change Audio Track?0