Esempio n. 1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="PlaylistViewModel" /> class.
        /// </summary>
        /// <param name="publicTransport">The public transport.</param>
        /// <param name="playlistService">The playlist service.</param>
        /// <param name="dispatcher">The dispatcher.</param>
        /// <param name="playerService">The audio player service.</param>
        /// <param name="fileInfoBuilder">The fileInfoBuilder.</param>
        /// <param name="configurationManager">The configuration manager.</param>
        /// <param name="globalHotkeyService">The global hotkey service.</param>
        /// <param name="windowManager">The window manager.</param>
        /// <param name="searchView">The search view.</param>
        public PlaylistViewModel(IPublicTransport publicTransport,
                                 IPlaylistService playlistService,
                                 IDispatcher dispatcher,
                                 IPlayerService playerService,
                                 IInfoBuilder <StorableTaggedFile> fileInfoBuilder,
                                 IConfigurationManager configurationManager,
                                 IGlobalHotkeyService globalHotkeyService,
                                 IWindowManager windowManager,
                                 ISearchView searchView)
        {
            this.publicTransport = Guard.IsNull(() => publicTransport);
            Guard.IsNull(() => configurationManager);
            this.dispatcher          = Guard.IsNull(() => dispatcher);
            this.fileInfoBuilder     = Guard.IsNull(() => fileInfoBuilder);
            this.globalHotkeyService = Guard.IsNull(() => globalHotkeyService);
            this.windowManager       = Guard.IsNull(() => windowManager);
            this.searchView          = Guard.IsNull(() => searchView);
            publicTransport.ApplicationEventBus.Subscribe <PlaylistUpdatedEvent>(OnPlaylistUpdated);
            publicTransport.ApplicationEventBus.Subscribe <TrackChangedEvent>(OnTrackChanged);
            searchHotkey = configurationManager.GetValue("Search", new HotkeyDescriptor(ModifierKeys.Control | ModifierKeys.Alt, Key.J),
                                                         KnownConfigSections.GlobalHotkeys);
            searchHotkey.ValueChanged += SearchHotkeyOnValueChanged;
            globalHotkeyService.RegisterHotkey(searchHotkey.Value, OnSearch);
            searchView.PlayFile += SearchViewOnPlayFile;
            Files = new List <FileItem>(playlistService.Files.Select(x => new FileItem(x)));
            var currenTrack = playerService.CurrentTrackAsReadonly;

            if (null == currenTrack)
            {
                return;
            }
            SetPlayingFile(playlistService.Files.Find(x => x.Filename == currenTrack.Name));
        }
Esempio n. 2
0
 /// <summary>
 /// Initializes a new instance of the <see cref="ComponentBase" /> class.
 /// </summary>
 /// <param name="logger">The logger.</param>
 /// <param name="playlistService">The playlist service.</param>
 /// <param name="player">The player.</param>
 /// <param name="publicTransport">The public transport.</param>
 /// <param name="configurationManager">The configuration manager.</param>
 /// <param name="hotkeyService">The hotkey service.</param>
 public NonManagingPlayerService(ILogger logger,
                                 IPlaylistService playlistService,
                                 IAudioPlayer player,
                                 IPublicTransport publicTransport,
                                 IConfigurationManager configurationManager,
                                 IGlobalHotkeyService hotkeyService)
     : base(logger)
 {
     playlistService.Guard("playlistService");
     player.Guard("player");
     publicTransport.Guard("publicTransport");
     configurationManager.Guard("configurationManager");
     state = PlayingState.Stopped;
     this.playlistService      = playlistService;
     this.player               = player;
     this.publicTransport      = publicTransport;
     this.configurationManager = configurationManager;
     this.hotkeyService        = hotkeyService;
     publicTransport.ApplicationEventBus.Subscribe <PlaylistUpdatedEvent>(OnPlaylistUpdated);
     publicTransport.ApplicationEventBus.Subscribe <ShuffleChangedEvent>(OnShuffleChanged);
     prebufferSongs                 = configurationManager.GetValue("PlayerService.PrebufferSongs", 2);
     PlayNextThreshold              = configurationManager.GetValue("PlayerService.PlayNextThreshnoldMs", 500d);
     TrackInterchangeCrossfadeTime  = configurationManager.GetValue("PlayerService.TrackInterchangeCrossfadeTimeMs", 500d);
     TrackInterchangeCrossFadeSteps = configurationManager.GetValue("PlayerService.TrackInterchangeCrossfadeSteps", 50);
     maxBackStack = configurationManager.GetValue("PlayerService.MaxBackStack", 2000);
     preBuffered  = new List <TrackContainer>(prebufferSongs.Value);
     backStack    = new List <TrackContainer>(maxBackStack.Value);
     RegisterHotkeys();
 }
Esempio n. 3
0
 /// <summary>
 /// </summary>
 /// <param name="playlistService">The playlist service.</param>
 /// <param name="player">The player.</param>
 /// <param name="publicTransport">The public transport.</param>
 /// <param name="configurationManager">The configuration manager.</param>
 /// <param name="hotkeyService">The hotkey service.</param>
 public NonManagingPlayerService(IPlaylistService playlistService,
                                 IAudioPlayer player,
                                 IPublicTransport publicTransport,
                                 IConfigurationManager configurationManager,
                                 IGlobalHotkeyService hotkeyService)
 {
     state = PlayingState.Stopped;
     this.playlistService      = Guard.IsNull(() => playlistService);
     this.player               = Guard.IsNull(() => player);
     this.publicTransport      = Guard.IsNull(() => publicTransport);
     this.configurationManager = Guard.IsNull(() => configurationManager);
     this.hotkeyService        = Guard.IsNull(() => hotkeyService);
     Subscribe();
     prebufferSongs                 = configurationManager.GetValue("PrebufferSongs", 2, "PlayerService");
     PlayNextThreshold              = configurationManager.GetValue("PlayNextThreshnoldMs", 500d, "PlayerService");
     TrackInterchangeCrossfadeTime  = configurationManager.GetValue("TrackInterchangeCrossfadeTimeMs", 500d, "PlayerService");
     TrackInterchangeCrossFadeSteps = configurationManager.GetValue("TrackInterchangeCrossfadeSteps", 50, "PlayerService");
     maxBackStack              = configurationManager.GetValue("MaxBackStack", 2000, "PlayerService");
     LastPlayed                = configurationManager.GetValue("PlayerService.LastPlayed", Guid.Empty, KnownConfigSections.Hidden);
     LastPlayedOffset          = configurationManager.GetValue("PlayerService.LastPlayedOffset", 0d, KnownConfigSections.Hidden);
     VolumeValue               = configurationManager.GetValue("PlayerService.Volume", 1f, KnownConfigSections.Hidden);
     preBuffered               = new List <TrackContainer>(prebufferSongs.Value);
     backStack                 = new List <TrackContainer>(maxBackStack.Value);
     VolumeValue.ValueChanged += VolumeValueOnValueChanged;
     RegisterHotkeys();
     LoadLastPlayed();
     UpdateState();
     SendProgress();
 }
Esempio n. 4
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PlayerService" /> class.
 /// </summary>
 /// <param name="playlistService">The playlist service.</param>
 /// <param name="player">The player.</param>
 /// <param name="threadManager">The thread manager service.</param>
 /// <param name="publicTransport">The public transport.</param>
 /// <param name="configurationManager">The configuration manager.</param>
 /// <param name="hotkeyService">The hotkey service.</param>
 public PlayerService(IPlaylistService playlistService,
                      IAudioPlayer player,
                      IThreadManager threadManager,
                      IPublicTransport publicTransport,
                      IConfigurationManager configurationManager,
                      IGlobalHotkeyService hotkeyService)
     : base(playlistService, player, publicTransport, configurationManager, hotkeyService)
 {
     threadManager.Guard("threadManagerService");
     managerThread = threadManager.StartNew(Manage);
     tokenSource   = new CancellationTokenSource();
     token         = tokenSource.Token;
 }
Esempio n. 5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PlaylistViewModel" /> class.
 /// </summary>
 /// <param name="publicTransport">The public transport.</param>
 /// <param name="playlistService">The playlist service.</param>
 /// <param name="dispatcher">The dispatcher.</param>
 /// <param name="playerService">The audio player service.</param>
 /// <param name="builder">The builder.</param>
 /// <param name="configurationManager">The configuration manager.</param>
 /// <param name="globalHotkeyService">The global hotkey service.</param>
 /// <param name="windowManager">The window manager.</param>
 /// <param name="searchView">The search view.</param>
 /// <param name="serializerService">The serializer service.</param>
 /// <param name="logger">The logger.</param>
 public PlaylistViewModel(IPublicTransport publicTransport,
                          IPlaylistService playlistService,
                          IDispatcher dispatcher,
                          IPlayerService playerService,
                          IInfoBuilder <StorableTaggedFile> builder,
                          IConfigurationManager configurationManager,
                          IGlobalHotkeyService globalHotkeyService,
                          IWindowManager windowManager,
                          ISearchView searchView,
                          ISerializerService serializerService,
                          ILogger logger)
     : base(logger)
 {
     publicTransport.Guard("publicTransport");
     playlistService.Guard("playlistService");
     dispatcher.Guard("dispatcher");
     playerService.Guard("playerService");
     builder.Guard("builder");
     configurationManager.Guard("configurationManager");
     globalHotkeyService.Guard("globalHotkeyService");
     windowManager.Guard("windowManager");
     searchView.Guard("searchView");
     serializerService.Guard("serializerService");
     this.playlistService     = playlistService;
     this.dispatcher          = dispatcher;
     this.playerService       = playerService;
     this.builder             = builder;
     this.globalHotkeyService = globalHotkeyService;
     this.windowManager       = windowManager;
     this.searchView          = searchView;
     publicTransport.ApplicationEventBus.Subscribe <PlaylistUpdatedEvent>(OnPlaylistUpdated);
     publicTransport.ApplicationEventBus.Subscribe <TrackChangedEvent>(OnTrackChanged);
     searchHotkey = configurationManager.GetValue("Search", new HotkeyDescriptor(ModifierKeys.Control | ModifierKeys.Alt, Key.J),
                                                  KnownConfigSections.GlobalHotkeys);
     searchHotkey.ValueChanged += SearchHotkeyOnValueChanged;
     globalHotkeyService.RegisterHotkey(searchHotkey.Value, OnSearch);
     //globalHotkeyService.RegisterHotkey(new HotkeyDescriptor(ModifierKeys.None, Key.A), () => MessageBox.Show("Stuff"));
     searchView.PlayFile += SearchViewOnPlayFile;
     Files = new List <FileItem>(playlistService.Files.Select(x => new FileItem(x)));
 }