private void loadAudioOutputs()
 {
     try
     {
         _audioOutputs = new ArrayList();
         IntPtr pOutputs = VLCLibrary.Instance.audio_output_list_get(_instance.Handle);
         if (pOutputs != IntPtr.Zero)
         {
             VLCLibrary.libvlc_audio_output_t output;
             do
             {
                 output = (VLCLibrary.libvlc_audio_output_t)Marshal.PtrToStructure(pOutputs, typeof(VLCLibrary.libvlc_audio_output_t));
                 AudioOutput aOutput      = new AudioOutput(output);
                 int         mdeviceCount = VLCLibrary.Instance.audio_output_device_count(_instance.Handle, output.psz_name);
                 if (mdeviceCount > 0)
                 {
                     for (int k = 0; k < mdeviceCount; k++)
                     {
                         AudioDevice device = new AudioDevice();
                         IntPtr      pId    = VLCLibrary.Instance.audio_output_device_id(_instance.Handle, output.psz_name, k);
                         device.deviceId = Marshal.PtrToStringAnsi(pId);
                         IntPtr pLongName = VLCLibrary.Instance.audio_output_device_longname(_instance.Handle, output.psz_name, k);
                         device.deviceName = Marshal.PtrToStringAnsi(pLongName);
                         aOutput.AddDevice(device);
                     }
                     _audioOutputs.Add(aOutput);
                 }
                 pOutputs = output.p_next;
             } while (output.p_next != IntPtr.Zero);
         }
         VLCLibrary.Instance.audio_output_list_release(pOutputs);
     }
     catch (Exception e)
     {
         Logger.WriteToLog("Error during loading Audio Outputs: " + e.Message);
     }
 }
 private void loadAudioOutputs()
 {
     try
     {
         _audioOutputs = new ArrayList();
         IntPtr pOutputs = VLCLibrary.Instance.audio_output_list_get(_instance.Handle);
         if (pOutputs != IntPtr.Zero)
         {
             VLCLibrary.libvlc_audio_output_t output;
             do
             {
                 output = (VLCLibrary.libvlc_audio_output_t)Marshal.PtrToStructure(pOutputs, typeof(VLCLibrary.libvlc_audio_output_t));
                 AudioOutput aOutput = new AudioOutput(output);
                 int mdeviceCount = VLCLibrary.Instance.audio_output_device_count(_instance.Handle, output.psz_name);
                 if (mdeviceCount > 0)
                 {
                     for (int k = 0; k < mdeviceCount; k++)
                     {
                         AudioDevice device = new AudioDevice();
                         IntPtr pId = VLCLibrary.Instance.audio_output_device_id(_instance.Handle, output.psz_name, k);
                         device.deviceId = Marshal.PtrToStringAnsi(pId);
                         IntPtr pLongName = VLCLibrary.Instance.audio_output_device_longname(_instance.Handle, output.psz_name, k);
                         device.deviceName = Marshal.PtrToStringAnsi(pLongName);
                         aOutput.AddDevice(device);
                     }
                     _audioOutputs.Add(aOutput);
                 }
                 pOutputs = output.p_next;
             } while (output.p_next != IntPtr.Zero);
         }
         VLCLibrary.Instance.audio_output_list_release(pOutputs);
     }
     catch (Exception e)
     {
         Logger.WriteToLog("Error during loading Audio Outputs: " + e.Message);
     }
 }
예제 #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");
        }