コード例 #1
0
        private void loadAudioTracksFromMedia()
        {
            Logger.WriteToLog("Loading Audio Outputs and Devices");
            try
            {
                _audioTracks = new ArrayList();
                int    subCount      = VLCLibrary.Instance.audio_get_track_count(_instance.Player.Handle);
                IntPtr p_first_track = VLCLibrary.Instance.audio_get_track_description(_instance.Player.Handle);
                IntPtr p_track       = p_first_track;
                for (int i = 0; i < subCount; i++)
                {
                    VLCLibrary.libvlc_track_description_t desc =
                        (VLCLibrary.libvlc_track_description_t)Marshal.PtrToStructure(p_track,
                                                                                      typeof(VLCLibrary.libvlc_track_description_t));

                    _audioTracks.Add(desc);
                    if (desc.p_next != IntPtr.Zero)
                    {
                        p_track = desc.p_next;
                    }
                }
                VLCLibrary.Instance.track_description_release(p_first_track);
            }
            catch (Exception e)
            {
                Logger.WriteToLog("Error loading audio tracks: " + e.Message);
            }
        }
コード例 #2
0
 public bool ChangeSubtitleTrack(int trackIndex)
 {
     if (trackIndex <= _media.SubtitleTracks.Count - 1)
     {
         VLCLibrary.libvlc_track_description_t subtitleTrack = (VLCLibrary.libvlc_track_description_t)_media.SubtitleTracks[trackIndex];
         VLCLibrary.Instance.video_set_spu(Handle, subtitleTrack.i_id);
         return(true);
     }
     return(false);
 }
コード例 #3
0
        public void SyncMenu()
        {
            // sync the Audio Outputs menu
            ToolStripMenuItem soundDevicesMenuItem = Form1.Instance.soundDevicesToolStripMenuItem;

            for (int i = 0; i < Player.AudioOutputs.Count; i++)
            {
                AudioOutput output = (AudioOutput)Player.AudioOutputs[i];
                if (output.Devices.Count > 0)
                {
                    ToolStripMenuItem mItem = new ToolStripMenuItem();
                    mItem.Name         = output.RawOutput.psz_name;
                    mItem.Text         = output.RawOutput.psz_description;
                    mItem.CheckOnClick = true;
                    mItem.Available    = true;
                    mItem.Enabled      = true;
                    mItem.Click       += new EventHandler(mItem_Click);

                    ArrayList outputDevices = output.Devices;
                    for (int k = 0; k < outputDevices.Count; k++)
                    {
                        ToolStripMenuItem mDeviceItem = new ToolStripMenuItem();
                        mDeviceItem.Name         = ((AudioDevice)outputDevices[k]).deviceId;
                        mDeviceItem.Text         = ((AudioDevice)outputDevices[k]).deviceName;
                        mDeviceItem.Available    = true;
                        mDeviceItem.Enabled      = true;
                        mDeviceItem.CheckOnClick = true;
                        mDeviceItem.Click       += new EventHandler(mDeviceItem_Click);
                        mItem.DropDownItems.Add(mDeviceItem);
                    }
                    soundDevicesMenuItem.DropDownItems.Add(mItem);
                }
            }

            SetCurrentActiveMenuItem(soundDevicesMenuItem, CurrentAudioOutputDeviceId.ToString());

            // sync the Audio Tracks menu
            ToolStripMenuItem audioTracksMenuItem = Form1.Instance.audioTracksToolStripMenuItem;
            ArrayList         _audioTracks        = _player.Media.AudioTracks;

            for (int a = 0; a < _audioTracks.Count; a++)
            {
                VLCLibrary.libvlc_track_description_t audioTrack = (VLCLibrary.libvlc_track_description_t)_audioTracks[a];
                ToolStripMenuItem aItem = new ToolStripMenuItem();
                aItem.Name         = audioTrack.i_id.ToString();
                aItem.Text         = audioTrack.psz_name;
                aItem.CheckOnClick = true;
                aItem.Click       += new EventHandler(aItem_Click);
                audioTracksMenuItem.DropDownItems.Add(aItem);
            }
            SetCurrentActiveMenuItem(audioTracksMenuItem, VLCLibrary.Instance.audio_get_track(_player.Handle).ToString());

            // sync the Subtitles menu
            ToolStripMenuItem subtitlesMenuItem = Form1.Instance.subtitlesToolStripMenuItem;
            ArrayList         _subtitleTracks   = _player.Media.SubtitleTracks;

            for (int j = 0; j < _subtitleTracks.Count; j++)
            {
                VLCLibrary.libvlc_track_description_t subtitleTrack = (VLCLibrary.libvlc_track_description_t)_subtitleTracks[j];
                ToolStripMenuItem subtitleMenu = new ToolStripMenuItem();
                subtitleMenu.Name         = subtitleTrack.i_id.ToString();
                subtitleMenu.Text         = subtitleTrack.psz_name;
                subtitleMenu.CheckOnClick = true;
                subtitleMenu.Click       += new EventHandler(subtitleMenu_Click);
                subtitlesMenuItem.DropDownItems.Add(subtitleMenu);
            }

            if (_subtitleTracks.Count > 0)
            {
                SetCurrentActiveMenuItem(subtitlesMenuItem, CurrentSubtitleTrackId.ToString());
            }

            // sync aspect ratio menu
            ToolStripMenuItem apItem = Form1.Instance.aspectRatioToolStripMenuItem;

            for (int i = 0; i < Player.AspectRatios.Count; i++)
            {
                String            aRatio = (string)Player.AspectRatios[i];
                ToolStripMenuItem mItem  = new ToolStripMenuItem();
                mItem.Name         = i.ToString();
                mItem.Text         = aRatio;
                mItem.CheckOnClick = true;
                mItem.Available    = true;
                mItem.Enabled      = true;
                mItem.Click       += new EventHandler(aspectRatio_Click);
                apItem.DropDownItems.Add(mItem);
            }
            SetCurrentActiveMenuItem(apItem, "0");
        }