Exemplo n.º 1
0
        private void GetAudioSessionControl()
        {
            object result;

            Marshal.ThrowExceptionForHR(_RealClient.GetService(ref IID_IAudioSessionControl, out result));
            _audioSessionControl = new AudioSessionControl(result as IAudioSessionControl2);
        }
Exemplo n.º 2
0
        /* added -> */
        public IEnumerator <AudioSessionControl> GetEnumerator()
        {
            int count = Count;

            for (int i = 0; i < count; i++)
            {
                AudioSessionControl session = this[i];
                if (session == null)
                {
                    yield break;
                }
                yield return(session);
            }
        }
Exemplo n.º 3
0
        /*
         * Retreives the current 'now playing' item by parsing Spotify's window title.
         */
        public void UpdateNowPlaying()
        {
            if (!controller.isListening()) return;
            Process[] processes = Process.GetProcessesByName("spotify"); // we need to refresh the spotify process each time, because spotify tends to change process id when hiding/unhiding.
            if (processes.Length > 0)
            {

                foreach (Process process in processes)
                {
                    spotProc = process;
                    spotifyASC = controller.getSpotifyAudioSession(spotProc.Id);
                    if (spotifyASC != null)
                    {
                        break;
                    }
                }

                if (spotifyASC == null)
                {
                    controller.addLog("ERROR: couldn't find the necessary spotify process to attach to");
                    return;
                }

                String[] theItem = spotProc.MainWindowTitle.Split('-');
                if (theItem.Length >= 2)
                {
                    String title = theItem[1].Trim();
                    String artist = theItem[0].Trim();
                    controller.addLog("Artist: " + artist + ", Title: " + theItem[1]);
                    currSong = new Song(artist, title);
                    lastItem = spotProc.MainWindowTitle;
                }
                else
                {
                    currSong = null;
                    controller.addLog("WARN: couldn't parse the artist/title from the raw window title.");
                }
            }
            else
            {
                controller.addLog("ERROR: expected to find multiple spotify processes, found one or none");
            }
        }
Exemplo n.º 4
0
 private void SwitchSession(AudioSessionControl s, bool p)
 {
     s.SimpleAudioVolume.Mute = p;
 }
Exemplo n.º 5
0
 private void GetAudioSessionControl()
 {
     object result;
     Marshal.ThrowExceptionForHR(_RealClient.GetService(ref IID_IAudioSessionControl, out result));
     _audioSessionControl = new AudioSessionControl(result as IAudioSessionControl2);
 }
Exemplo n.º 6
0
 public AudioSessionEvents(AudioSessionControl sessionControl)
 {
     _sessionControl = sessionControl;
 }
Exemplo n.º 7
0
 public AudioSessionEvents(AudioSessionControl sessionControl)
 {
     _sessionControl = sessionControl;
 }