Example #1
0
        private async Task <object> Restart()
        {
            _audioEngine.Stop();
            _audioEngine.Start();

            await _settingsService.SetSettingAsync(Globals.SettingKeys.IsEngineRunning, true).ConfigureAwait(false);

            return(true);
        }
Example #2
0
        private dynamic ImportConfiguration(ModulesExportDto dto)
        {
            var state = _audioEngine.IsRunning;

            try
            {
                if (state)
                {
                    _audioEngine.Stop();
                }

                if (dto?.Modules == null)
                {
                    return(false);
                }

                if (!_connectionService.Truncate())
                {
                    _logger.Error("Could not truncate the connections table.");
                    return(false);
                }

                if (!_moduleService.Truncate())
                {
                    _logger.Error("Could not truncate the modules table.");
                    return(false);
                }

                var moduleIdMap = new Dictionary <long, long>();

                foreach (var moduleDto in dto.Modules)
                {
                    var oldId = moduleDto.Id;
                    _moduleService.Insert(moduleDto);
                    moduleIdMap.Add(oldId, moduleDto.Id);
                }

                foreach (var connectionDto in dto.Connections)
                {
                    if (moduleIdMap.TryGetValue(connectionDto.SourceId, out var newSourceId) &&
                        moduleIdMap.TryGetValue(connectionDto.TargetId, out var newTargetId))
                    {
                        connectionDto.SourceId = newSourceId;
                        connectionDto.TargetId = newTargetId;
                        _connectionService.Insert(connectionDto);
                    }
                }

                return(true);
            }
            finally
            {
                if (state)
                {
                    _audioEngine.Start();
                }
            }
        }
 private void SongFinished(object sender, RoutedEventArgs e)
 {
     if (Playlist.IsPossibleToChangeTrack(1))
     {
         Playlist.CurrentIndex = Playlist.CurrentIndex + 1;
         _audioEngine.Load(Playlist.CurrrentFile);
         _audioEngine.Play();
     }
     else
     {
         _audioEngine.Stop();
     }
 }
Example #4
0
        public Task StopAsync(CancellationToken cancellationToken)
        {
            Logger.Info("Stopping service");

            _updateTimer.Stop();

            _apiClient.Disconnect();
            _apiServer.Stop();
            _engine.Stop();

            _plugins.Clear();

            _containerProvider.Dispose();

            Logger.Info("Service stopped");

            return(Task.CompletedTask);
        }