toggle or switch audio tracks

This forum is about all development around libVLC.
anhlunnhaque
Blank Cone
Blank Cone
Posts: 18
Joined: 01 Sep 2006 21:36

toggle or switch audio tracks

Postby anhlunnhaque » 09 Sep 2010 23:35

Hello,

I am a newbie in VLC and C#. But I would like to create a custom media player using C# and libVLC.net. I got this great project from here: viewtopic.php?f=32&t=58438 and after testing, debugging and trying to understands some of the code. I have a question and hope that somebody could help me.

I want to create a button click event that when I click it..I toggle or switch the audio from audio 1 to audio 2. Or from audio 2 to audio 1. Does anybody has the snippet code that I can use to play with? Ultimately, I want to set the player to play the audio stream that I specify. But at this moment. I'll just work a little at a time.

Thank you and greatly appreciated for your help...

XilasZ
Developer
Developer
Posts: 189
Joined: 16 Jun 2009 20:35

Re: toggle or switch audio tracks

Postby XilasZ » 16 Sep 2010 18:12

I don't know about the wrapper libVLC.net because i use another one, but on the vlc side, you need to play with libvlc_audio_set_track, libvlc_audio_get_track and libvlc_audio_get_track_description.

You can check the source code of my program here if you want (a mediaplayer dedicated to tv from my internet provider, but it can also play any media file, and it can switch audio/video/subtitle tracks on the fly) : http://sourceforge.net/projects/fritivi/
it still use libvlc 1.0.5, i did not take the time to update to 1.1.x.

More specifically, you'll find how i deal with audio tracks here : http://fritivi.git.sourceforge.net/git/ ... d5;hb=HEAD

anhlunnhaque
Blank Cone
Blank Cone
Posts: 18
Joined: 01 Sep 2006 21:36

Re: toggle or switch audio tracks

Postby anhlunnhaque » 16 Sep 2010 21:40

XilasZ...thank you for the info..I'll definitely look at the source code to learn more about vlc..thanks again..

Edit: How do i get the source code for your project? I downloaded it..and it's an .exe.

XilasZ
Developer
Developer
Posts: 189
Joined: 16 Jun 2009 20:35

Re: toggle or switch audio tracks

Postby XilasZ » 17 Sep 2010 16:28

you can browse the whole source code here : http://fritivi.git.sourceforge.net/git/ ... ivi;a=tree
There is also a snapshot link in the left of the header of the page, if you want a tarball.

mangokm40
Cone that earned his stripes
Cone that earned his stripes
Posts: 130
Joined: 20 May 2010 20:00

Re: toggle or switch audio tracks

Postby mangokm40 » 17 Sep 2010 20:43

Here's a basic function that will scroll through the audio tracks:

Code: Select all

libvlc_media_player_t* vlcPlayer; bool SetNextAudioTrack(bool previous) { int total = libvlc_audio_get_track_count(vlcPlayer); if (total == 0) return false; int current = libvlc_audio_get_track(vlcPlayer); current = previous ? current - 1 : current + 1; if (current < 0) current = total - 1; else if (current == total) current = 0; return libvlc_audio_set_track(vlcPlayer, current) == 0; }
It's in C, but I hope it helps you.


Return to “Development around libVLC”

Who is online

Users browsing this forum: No registered users and 12 guests