-
Notifications
You must be signed in to change notification settings - Fork 17
Audio Tracks
majorsilence edited this page Nov 11, 2014
·
10 revisions
To get a full list of audio tracks use the Discover class.
Discover file = new Discover(@"/path/to/some/video.avi", @"\path\to\mplayer.exe");
file.Execute();
List<int> tracks = file.AudioList;
This will give you a list of audio track ids that can be used with the MPlayer class function SwitchAudioTrack. The example below will get a list of audio tracks in a file. Start playing the file and if the number of audio tracks is greater than 1 it will switch to the second track.
using System;
using LibMPlayerCommon;
class MainClass
{
public static void Main (string[] args)
{
int handle = (int)System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle;
Discover file = new Discover(@"/path/to/some/video.avi", @"\path\to\mplayer.exe");
file.Execute();
List<int> tracks = file.AudioList;
MPlayer _play;
_play = new MPlayer(handle, MplayerBackends.SDL,
@"\path\to\mplayer.exe");
_play.Play(@"/path/to/some/video.avi");
if (tracks.Count > 1)
{
_play.SwitchAudioTrack(tracks[1]);
}
Console.WriteLine ("Press enter to exit...");
System.Console.ReadLine();
}
}
Imports LibMPlayerCommon
Class MainClass
Public Shared Sub Main(args As String())
Dim handle As Integer = CInt(System.Diagnostics.Process.GetCurrentProcess().MainWindowHandle)
Dim file As New Discover("/path/to/some/video.avi", "\path\to\mplayer.exe")
file.Execute()
Dim tracks As List(Of Integer) = file.AudioList
Dim _play As MPlayer
_play = New MPlayer(handle, MplayerBackends.SDL, "\path\to\mplayer.exe")
_play.Play("/path/to/some/video.avi")
If tracks.Count > 1 Then
_play.SwitchAudioTrack(tracks(1))
End If
Console.WriteLine("Press enter to exit...")
System.Console.ReadLine()
End Sub
End Class