Change Audio Stream in VideoLan DotNet for WPF

大城市里の小女人 提交于 2019-12-12 02:49:44

问题


We're using VideoLan DotNet for WPF to play DVD movies in our WPF application. Some movies have multiple audio stream. (for example in multiple languages) How can we choose the desired audio stream?
While searching VideoLan's Wiki, I found this:

[Browsable(false)]
        [DesignerSerializationVisibility(DesignerSerializationVisibility.Hidden)]
        public int AudioTrack
        {
            get
            {
                return this.nativeVlc.GetVlcObjectInt(ObjectType.VLC_OBJECT_INPUT, "audio-es", -1);
            }
            set
            {
                this.nativeVlc.SetVlcObjectInt(ObjectType.VLC_OBJECT_INPUT, "audio-es", value);
            }
        }

But I can't find the same property in the project I'm using (Vlc.DotNet)
So how can I detect how many audio streams exist and choose one?


回答1:


I found out how to do so (mediaPlayer is an instance of VlcControl):
We can count audio streams using mediaPlayer.AudioProperties.TrackCount and select the index using mediaPlayer.AudioProperties.Track.
Now is there any way to get their description? (They usually have a name such as "English")




回答2:


i'm using VLC control in Windows form and my code for work

private void karaokeToolStripMenuItem_Click(object sender, EventArgs e)
        {
             // MessageBox.Show(axVLCPlugin21.audio.count.ToString(), "audio track");
            if (axVLCPlugin21.audio.track == 1)
            {
                try
                {
                    axVLCPlugin21.audio.track = 2;
                }
                catch (Exception ex)
                {
                    // show Exception here by messageBox or other
                    //if there are exceptions, the file has only one track
                }

            }

                else
                    axVLCPlugin21.audio.track = 1;            
        }  

I hope to help you.



来源:https://stackoverflow.com/questions/24466265/change-audio-stream-in-videolan-dotnet-for-wpf

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!