コード例 #1
0
 public ScoreWindow(int score, IsPlaying isPlaying, bool lose)
 {
     InitializeComponent();
     Textblock.Text = score.ToString();
     _isPlaying     = isPlaying;
     if (lose)
     {
         Button.Content    = "Закончить";
         SumTextBlock.Text = "Выигрыш";
     }
 }
コード例 #2
0
        public async Task <PlaybackService> InitializeAsync()
        {
            // Initialize Setting
            //Setting.InitializeSettingBinary(RepeatMode, nameof(RepeatMode), MediaRepeatMode.None);
            //Setting.InitializeSetting(EnableShuffle, nameof(EnableShuffle), false);

            Player             = new MediaPlayer();
            _playlistContainer = new PlaylistContainer();

            Setting.Playback.Volume
            .Subscribe(x => Player.Volume = x / 100d);

            Observable.FromEventPattern <TypedEventHandler <MediaPlayer, object>, object>(
                h => Player.MediaEnded += h, h => Player.MediaEnded -= h)
            .Subscribe(async _ =>
            {
                IsPlaying.OnNext(false);

                if (_playlistContainer.RepeatMode == MediaRepeatMode.Track)
                {
                    await PlayAsyncInner(_playlistContainer.CurrentTrack);
                    return;
                }

                if (_playlistContainer.HasNext())
                {
                    await PlayAsyncInner(_playlistContainer.Next());
                }
            });

            Observable.Timer(TimeSpan.Zero, TimeSpan.FromMilliseconds(500))
            .SkipUntil(IsPlaying.DistinctUntilChanged().Where(x => x))
            .TakeUntil(IsPlaying.DistinctUntilChanged().Where(x => !x))
            .Repeat()
            .Subscribe(_ =>
            {
                PlaybackPosition.OnNext(Player.PlaybackSession);
            });

            NewTrackPlayed
            .Do(x => WriteSmtcThumbnail(x.PlaybackItem, x.Track))
            .ObserveOnCoreDispatcher()
            .Subscribe(x =>
            {
                if (_previousTrack != null)
                {
                    _previousTrack.IsPlaying = false;
                }
                x.Track.IsPlaying = true;
                _previousTrack    = x.Track;
            });

            return(await Task.FromResult(this));
        }
コード例 #3
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (Title != null ? Title.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Artist != null ? Artist.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (Album != null ? Album.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (BitmapRepresentation != null ? BitmapRepresentation.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ IsPlaying.GetHashCode();
         hashCode = (hashCode * 397) ^ DurationSpan.GetHashCode();
         hashCode = (hashCode * 397) ^ CurrentPosition.GetHashCode();
         return(hashCode);
     }
 }
コード例 #4
0
        private static async Task PlayAsyncInner(TrackViewModel track)
        {
            var mpi = await CreateMediaPlaybackItemAsync(track);

            Player.Source = mpi;
            Player.Play();

            NewTrackPlayed.OnNext(new TrackMixed
            {
                Track        = track,
                PlaybackItem = mpi,
            });
            IsPlaying.OnNext(true);
        }
コード例 #5
0
        public SkillReplayControlViewModel()
        {
            replayer = new SkillPlayer(this);

            var config = SkillReplayConfig.Instance;

            Language      = new ReactiveProperty <string>(config.Language);
            TextFFLogsURL = new ReactiveProperty <string>(config.FFLogsURL);
            NumberPort    = new ReactiveProperty <int>(config.Port);
            AutoReplay    = new ReactiveProperty <int>(config.AutoReplay);
            AutoStop      = new ReactiveProperty <int>(config.AutoStop);
            AutoStopTime  = new ReactiveProperty <int>(config.AutoStopTime);
            LanguageList  = config.LanguageList;

            TextPlayButton = IsPlaying.Select(play => play ? "停止" : "再生").ToReactiveProperty();
            OverlayURL     = NumberPort.Select(port => $"https://rawrington.github.io/SkillDisplay/?HOST_PORT=ws://127.0.0.1:{port}/").ToReactiveProperty();


            var IsBusy = new[] { IsLoading, IsPlaying }.CombineLatest(a => a.Any(x => x));

            HasEvent = CurrentFight.CombineLatest(CurrentFriendly, CheckEvents).ToReactiveProperty();

            FriendlyList = OriginalFriendlyList.CombineLatest(CurrentFight, (list, fight) =>
            {
                if (fight != null)
                {
                    string key = $".{fight.id}.";
                    return(list.Where(friend => friend.fights.Contains(key) && friend.type != "LimitBreak").ToList());
                }
                else
                {
                    return(new List <Friendly>());
                }
            }).ToReactiveProperty();

            FriendlyList.Subscribe(list =>
            {
                if (!list.Contains(CurrentFriendly.Value))
                {
                    CurrentFriendly.Value = null;
                }
            });

            CommandLoadFights = IsBusy.Select(b => !b).ToReactiveCommand();
            CommandLoadFights.Subscribe(LoadFights);

            CommandLoadSkill = CurrentFight.CombineLatest(CurrentFriendly, IsBusy, (fight, friend, busy) =>
            {
                if (busy)
                {
                    return(false);
                }
                if (fight == null)
                {
                    return(false);
                }
                if (friend == null)
                {
                    return(false);
                }
                return(true);
            }).ToReactiveCommand();
            CommandLoadSkill.Subscribe(LoadEvents);

            CommandReplay = HasEvent.ToReactiveCommand();
            CommandReplay.Subscribe(Replay);

            TextFFLogsURL.Subscribe(url =>
            {
                config.FFLogsURL = url;
                config.Save();
            });
            NumberPort.Subscribe(port =>
            {
                config.Port = port;
                config.Save();
            });
            AutoReplay.Subscribe(autoreplay =>
            {
                config.AutoReplay = autoreplay;
                config.Save();
            });
            AutoStop.Subscribe(autostop =>
            {
                config.AutoStop = autostop;
                config.Save();
            });
            AutoStopTime.Subscribe(autostoptime =>
            {
                config.AutoStopTime = autostoptime;
                config.Save();
            });

            Language.Subscribe(lang =>
            {
                config.Language = lang;
                config.Save();
            });

            PlayStopTagList = IsPlaying.Select(x => x ? "Stop" : "Play").ToReactiveProperty();
        }
コード例 #6
0
        public static void Resume()
        {
            Player.Play();

            IsPlaying.OnNext(true);
        }
コード例 #7
0
        public static void Pause()
        {
            Player.Pause();

            IsPlaying.OnNext(false);
        }
コード例 #8
0
        /// <summary>
        /// Serialises the notification.
        /// </summary>
        /// <returns>
        /// The notification serialized as a byte array.
        /// </returns>
        public byte[] SerialiseNotification()
        {
            // Due to a Json.Net bug serialising int[] we construct this message manually
            string playlistString = string.Empty;

            if ((Playlist != null) && (Playlist.Length > 0))
            {
                foreach (int audioFileId in Playlist)
                {
                    playlistString += (!string.IsNullOrEmpty(playlistString) ? ", " : string.Empty) + audioFileId;
                }
            }
            string json = "{\"PlaylistPosition\":" + PlaylistPosition + ", \"Playlist\":[" + playlistString + "], \"IsPaused\":" + IsPaused.ToString().ToLower() + ", \"IsPlaying\":" + IsPlaying.ToString().ToLower() + ", \"Position\":" + Position + ", \"Duration\":" + Duration + ", \"IsRepeatAll\":" + IsRepeatAll.ToString().ToLower() + ", \"IsShuffle\":" + IsShuffle.ToString().ToLower() + ", \"CanMoveNext\":" + CanMoveNext.ToString().ToLower() + ", \"CanMovePrevious\":" + CanMovePrevious.ToString().ToLower() + "}";

            return(System.Text.Encoding.UTF8.GetBytes(json));
        }