示例#1
0
        public void Run()
        {
            Running = true;
            Thread.Sleep(50);
            _waveIn = new WasapiLoopbackCapture();

            _waveIn.DataAvailable    += WaveIn_DataAvailable;
            _waveIn.RecordingStopped += WaveIn_RecordingStopped;

            _writer = GetFileWriter(_waveIn);

            if (_writer == null)
            {
                return;
            }

            _waveIn.StartRecording();
            _form.WriteIntoConsole(string.Format(FrmEspionSpotify.Rm.GetString($"logRecording") ?? "{0}", _fileManager.BuildFileName(_userSettings.OutputPath, false)));

            while (Running)
            {
                Thread.Sleep(50);
            }

            _waveIn.StopRecording();
        }
示例#2
0
        public void Run()
        {
            Running = true;
            WaveIn  = new WasapiLoopbackCapture();

            WaveIn.DataAvailable    += waveIn_DataAvailable;
            WaveIn.RecordingStopped += waveIn_RecordingStopped;

            Writer = GetFileWriter(WaveIn);

            if (Writer == null)
            {
                if (!Directory.Exists(_path))
                {
                    _form.WriteIntoConsole(FrmEspionSpotify.Rm.GetString($"logInvalidOutput"));
                    return;
                }
                _form.WriteIntoConsole(FrmEspionSpotify.Rm.GetString($"logWriterIsNull"));
                return;
            }

            WaveIn.StartRecording();
            _form.WriteIntoConsole(string.Format(FrmEspionSpotify.Rm.GetString($"logRecording") ?? "{0}", BuildFileName(_path, false)));

            while (Running)
            {
                Thread.Sleep(30);
            }
            WaveIn.StopRecording();
        }
示例#3
0
        private void OnTrackChanged(object sender, TrackChangeEventArgs e)
        {
            if (RecorderUpAndRunning && IsOldSong)
            {
                _sound.SleepWhileTheSongEnds();
            }

            var newTrack = e.NewTrack;

            if (newTrack == null)
            {
                return;
            }

            var newSong = new Song(newTrack);

            if (_currentSong.Equals(newSong))
            {
                _form.UpdateIconSpotify(_isPlaying, RecorderUpAndRunning);
                return;
            }

            _currentSong   = newSong;
            _lastKnownSong = new Song();

            _form.UpdatePlayingTitle(SongTitle);

            if (AdPlaying)
            {
                _form.WriteIntoConsole(FrmEspionSpotify.Rm.GetString($"logAdPlaying"));
            }

            _sound.SetSpotifyToMute(AdPlaying);
        }
示例#4
0
        private async Task RunSpotifyConnect()
        {
            if (!SpotifyConnect.IsSpotifyInstalled())
            {
                return;
            }

            if (!SpotifyConnect.IsSpotifyRunning())
            {
                _form.WriteIntoConsole(FrmEspionSpotify.Rm.GetString($"logSpotifyConnecting"));
                await SpotifyConnect.Run();
            }

            Running = true;
        }
示例#5
0
        private void OnTrackChanged(object sender, TrackChangeEventArgs e)
        {
            if (RecorderUpAndRunning && IsOldSong)
            {
                _sound.SleepWhileTheSongEnds();
            }

            if (!IsNewTrack(e.NewTrack))
            {
                return;
            }

            if (AdPlaying)
            {
                _form.WriteIntoConsole(FrmEspionSpotify.Rm.GetString($"logAdPlaying"));
            }

            RecordSpotify();
        }
示例#6
0
        private async Task RunSpotifyConnect()
        {
            if (SpotifyConnect.IsSpotifyInstalled() && !SpotifyConnect.IsSpotifyRunning())
            {
                _form.WriteIntoConsole(FrmEspionSpotify.Rm.GetString($"logSpotifyConnecting"));
            }

            SpotifyConnect.Run();

            _userSettings.SpotifyAudioSession = new AudioSessions.SpotifyAudioSession();
            await _userSettings.SpotifyAudioSession.WaitSpotifyAudioSessionToStart();

            Spotify = new SpotifyHandler(_userSettings.SpotifyAudioSession)
            {
                ListenForEvents = true
            };
            Spotify.OnPlayStateChange += OnPlayStateChanged;
            Spotify.OnTrackChange     += OnTrackChanged;
            Spotify.OnTrackTimeChange += OnTrackTimeChanged;

            _currentTrack = Spotify.GetTrack();
        }