Пример #1
0
        public bool ChangeDevice(int index)
        {
            try
            {
                if (p_Devices.Count == 0) return false;
                if (index < 0 || index > p_Devices.Count - 1) index = 0;

                COM.IWMPAudioRenderConfig ac = p_WMP as COM.IWMPAudioRenderConfig;
                if (ac != null)
                {
                    ac.put_audioOutputDevice(p_Devices[index].ID);
                    p_CurrentDevice = p_Devices[index];
                    return true;
                }
                //p_SoundEngine = new ISoundEngine(SoundOutputDriver.AutoDetect, SoundEngineOptionFlag.DefaultOptions, p_Devices[index].ID);
            }
            catch { }

            return false;
        }
Пример #2
0
        public void Dispose()
        {
            Global.Settings.PlayMode = (int)p_PlayMode;

            //if (p_WebClient != null) p_WebClient.Dispose();
            p_StreamTitle = string.Empty;
            if (p_Shoutcast != null) p_Shoutcast.Dispose();
            p_DefaultDevice = null;
            p_CurrentDevice = null;
            p_Devices.Clear();
            p_Timer2.Dispose();
            p_Timer.Dispose();
            p_PlayMode = PlayModes.None;
            DisposeMediaPlayer();
            DisposeID3();
        }
Пример #3
0
        public MediaPlayer()
        {
            try
            {
                p_ID3 = new UltraID3();

                p_WMP = new WindowsMediaPlayer();
                p_WMP.MediaError += new _WMPOCXEvents_MediaErrorEventHandler(p_WMP_MediaError);
                p_WMP.PlayStateChange += new _WMPOCXEvents_PlayStateChangeEventHandler(p_WMP_PlayStateChange);
                p_WMP.settings.autoStart = false;
                p_WMP.settings.enableErrorDialogs = false;
                p_WMP.uiMode = "invisible";
                //p_SoundEngine = new ISoundEngine(SoundOutputDriver.AutoDetect, SoundEngineOptionFlag.DefaultOptions);
                //p_Sound = null;

                Volume = Global.Settings.Volume;
                PlayMode = (PlayModes)Global.Settings.PlayMode;

                p_Timer = new Timer();
                p_Timer.Interval = 1000;
                p_Timer.Tick += new EventHandler(p_Timer_Tick);

                p_Timer2 = new Timer();
                p_Timer2.Interval = 100;
                p_Timer2.Tick += new EventHandler(p_Timer2_Tick);

                p_StreamTimer = new Timer();
                p_StreamTimer.Interval = 30000;
                p_StreamTimer.Tick += new EventHandler(p_StreamTimer_Tick);

                p_Devices = new List<COM.MMDevice>();
                p_Shoutcast = null;
                p_StreamTitle = string.Empty;
                //p_WebClient = null;

                COM.MMDeviceEnumerator devEnum = new COM.MMDeviceEnumerator();
                COM.MMDeviceCollection devCollection = devEnum.EnumerateAudioEndPoints(COM.EDataFlow.eRender, COM.EDeviceState.DEVICE_STATE_ACTIVE);

                p_CurrentDevice = devEnum.GetDefaultAudioEndpoint(COM.EDataFlow.eRender, COM.ERole.eMultimedia);
                p_DefaultDevice = p_CurrentDevice;

                p_Devices.Add(p_DefaultDevice);

                for (int i = 0; i < devCollection.Count; i++)
                {
                    if (devCollection[i].ID != p_DefaultDevice.ID) p_Devices.Add(devCollection[i]);
                }
            }
            catch { }
        }