Ejemplo n.º 1
0
        public MusicPlayer()
        {
            _windowsMediaPlayer = new WindowsMediaPlayer();

            _windowsMediaPlayer.PlayStateChange += state =>
            {
                if (PlayerStatus == Status.Undefined)
                {
                    return;
                }
                PlayerStatusChanged?.Invoke(this, PlayerStatus);
            };
            _timer          = new Timer();
            _timer.Interval = (int)Interval;
            _timer.Tick    += (sender, e) =>
            {
                ProgressChanged?.Invoke(this, ProgressRaw);

                if (PlayerStatus == Status.Stopped || PlayerStatus == Status.MediaEnded)
                {
                    if (NextTrackSelection != NextTrackSetting.AutoStop)
                    {
                        SelectNextTrack();
                        return;
                    }
                    (sender as Timer)?.Stop();
                }
            };
            _trackList = new List <Track>();

            Volume   = 50;
            Progress = TimeSpan.Zero;
        }
Ejemplo n.º 2
0
    private void OnPlayerStatusChanged(object Sender, ValueChangedEventArgs EventArgs)
    {
        if (EventArgs.Snapshot.Value != null)
        {
            int val = int.Parse(EventArgs.Snapshot.Value.ToString());
            PlayerStatus = (EPlayerStatus)val;
        }
        else
        {
            // Todo: implement initial status sequence
            PlayerStatus = EPlayerStatus.Offline;
        }

        PlayerStatusChanged?.Invoke(PlayerStatus);
    }
Ejemplo n.º 3
0
        public void ChangeStatus(Adventure adventure, AdventureStatus status, object argument = null)
        {
            if (adventure.AdventureLogic.Status != status)
            {
                switch (status)
                {
                case AdventureStatus.Exploration:
                    adventure.AdventureLogic = explorationlogic;
                    break;

                case AdventureStatus.MonsterBattle:
                    if (argument != null)
                    {
                        MonsterBattleLogic battlelogic = new MonsterBattleLogic(context.GetModule <RPGMessageModule>());
                        battlelogic.Add(new PlayerBattleEntity(context, adventure.Player, adventure, battlelogic));
                        battlelogic.Add(new MonsterBattleEntity(context.GetModule <MonsterModule>().GetMonster((string)argument, context.GetModule <PlayerModule>().GetExistingPlayer(adventure.Player).Level), context, adventure, battlelogic));
                        adventure.AdventureLogic = battlelogic;
                    }
                    else
                    {
                        MonsterBattleLogic battlelogic = new MonsterBattleLogic(context.GetModule <RPGMessageModule>());
                        battlelogic.Add(new PlayerBattleEntity(context, adventure.Player, adventure, battlelogic));
                        battlelogic.Add(new MonsterBattleEntity(context.GetModule <MonsterModule>().GetMonster(context.GetModule <PlayerModule>().GetExistingPlayer(adventure.Player).Level), context, adventure, battlelogic));
                        adventure.AdventureLogic = battlelogic;
                    }
                    break;

                case AdventureStatus.SpiritRealm:
                    context.GetModule <EffectModule>().ClearPlayerEffects(adventure.Player);
                    adventure.AdventureLogic = new SpiritRealmLogic(context);
                    break;
                }
                PlayerStatusChanged?.Invoke(adventure.Player, status);
            }
            adventure.Reset();
        }
Ejemplo n.º 4
0
 private void OnPlayerStatusChanged(IPlayerSession session, SessionStatus oldStatus, SessionStatus newStatus)
 {
     PlayerStatusChanged?.Invoke(this, new SessionStatusEventArgs(session, oldStatus, newStatus));
 }
Ejemplo n.º 5
0
 void SetActive(long playerid, bool isactive)
 {
     context.Database.Update <Player>().Set(p => p.IsActive == isactive).Where(p => p.UserID == playerid).Execute();
     PlayerStatusChanged?.Invoke(playerid, isactive);
 }