Ejemplo n.º 1
0
        public PlaylistPlayer(HohoemaPlaylist hohoemaPlaylist, PlaylistSettings playlistSettings)
        {
            HohoemaPlaylist  = hohoemaPlaylist;
            PlaylistSettings = playlistSettings;

            _SettingsObserveDisposer = Observable.Merge(
                PlaylistSettings.ObserveProperty(x => x.IsShuffleEnable).ToUnit(),
                PlaylistSettings.ObserveProperty(x => x.RepeatMode).ToUnit(),
                PlaylistSettings.ObserveProperty(x => x.IsReverseModeEnable).ToUnit()
                )
                                       .Subscribe(async _ =>
            {
                using (var releaser = await _PlaylistUpdateLock.LockAsync())
                {
                    _RepeatMode = PlaylistSettings.RepeatMode;

                    ResetRandmizedItems();

                    CurrentIndex = PlaylistSettings.IsShuffleEnable ? 0 : (SourceItems?.IndexOf(Current) ?? 0);

                    RaisePropertyChanged(nameof(CanGoBack));
                    RaisePropertyChanged(nameof(CanGoNext));
                }
            });
        }
Ejemplo n.º 2
0
        public async Task Save()
        {
            await RankingSettings.Save();

            await PlayerSettings.Save();

            await NGSettings.Save();

            await CacheSettings.Save();

            await PlaylistSettings.Save();

            await AppearanceSettings.Save();
        }
Ejemplo n.º 3
0
        public PlaylistPlayer(HohoemaPlaylist hohoemaPlaylist, PlaylistSettings playlistSettings)
        {
            HohoemaPlaylist  = hohoemaPlaylist;
            PlaylistSettings = playlistSettings;

            _SettingsObserveDisposer = Observable.Merge(
                PlaylistSettings.ObserveProperty(x => x.IsShuffleEnable).ToUnit(),
                PlaylistSettings.ObserveProperty(x => x.RepeatMode).ToUnit()
                )
                                       .Subscribe(_ =>
            {
                ResetPlayer();
            });
        }
Ejemplo n.º 4
0
        public HohoemaPlaylist(MediaPlayer mediaPlayer, PlaylistSettings playlistSettings, StorageFolder playlistSaveFolder)
        {
            MediaPlayer         = mediaPlayer;
            PlaylistSettings    = playlistSettings;
            PlaylistsSaveFolder = playlistSaveFolder;
            Player = new PlaylistPlayer(this, playlistSettings);

            Playlists = new ReadOnlyObservableCollection <LocalMylist>(_Playlists);

            var smtc = MediaPlayer.SystemMediaTransportControls;

            smtc.AutoRepeatModeChangeRequested          += Smtc_AutoRepeatModeChangeRequested;
            MediaPlayer.CommandManager.NextReceived     += CommandManager_NextReceived;
            MediaPlayer.CommandManager.PreviousReceived += CommandManager_PreviousReceived;
        }
Ejemplo n.º 5
0
        private void SetupSaveWithPropertyChanged()
        {
            RankingSettings.PropertyChangedAsObservable()
            .Throttle(TimeSpan.FromSeconds(1))
            .Subscribe(e => _ = RankingSettings.Save());

            PlayerSettings.PropertyChangedAsObservable()
            .Throttle(TimeSpan.FromSeconds(1))
            .Subscribe(e => _ = PlayerSettings.Save());

            NGSettings.PropertyChangedAsObservable()
            .Throttle(TimeSpan.FromSeconds(1))
            .Subscribe(e => _ = NGSettings.Save());

            CacheSettings.PropertyChangedAsObservable()
            .Throttle(TimeSpan.FromSeconds(1))
            .Subscribe(e => _ = CacheSettings.Save());

            PlaylistSettings.PropertyChangedAsObservable()
            .Throttle(TimeSpan.FromSeconds(1))
            .Subscribe(e => _ = PlaylistSettings.Save());

            AppearanceSettings.PropertyChangedAsObservable()
            .Throttle(TimeSpan.FromSeconds(1))
            .Subscribe(e => _ = AppearanceSettings.Save());

            ActivityFeedSettings.PropertyChangedAsObservable()
            .Throttle(TimeSpan.FromSeconds(1))
            .Subscribe(e => _ = ActivityFeedSettings.Save());

            new[] {
                PinSettings.PropertyChangedAsObservable().ToUnit(),
                    PinSettings.Pins.CollectionChangedAsObservable().ToUnit(),
                    PinSettings.Pins.ObserveElementPropertyChanged().ToUnit()
            }
            .Merge()
            .Throttle(TimeSpan.FromSeconds(1))
            .Subscribe(pair => _ = PinSettings.Save());
        }
Ejemplo n.º 6
0
        public HohoemaPlaylist(HohoemaApp hohoemaApp, PlaylistSettings playlistSettings, StorageFolder playlistSaveFolder, HohoemaViewManager viewMan)
        {
            HohoemaApp          = hohoemaApp;
            PlaylistSettings    = playlistSettings;
            PlaylistsSaveFolder = playlistSaveFolder;
            Player         = new PlaylistPlayer(this, playlistSettings);
            _SecondaryView = viewMan;

            Playlists = new ReadOnlyObservableCollection <LocalMylist>(_Playlists);

            MakeDefaultPlaylist();
            CurrentPlaylist = DefaultPlaylist;

            if (ApplicationData.Current.LocalSettings.Values.TryGetValue(nameof(PlayerDisplayType), out var showInMainView))
            {
                try
                {
                    _PlayerDisplayType = (bool)showInMainView ? PlayerDisplayType.PrimaryView : PlayerDisplayType.SecondaryView;
                }
                catch { }
            }

            Player.PlayRequested += Player_PlayRequested;
        }