コード例 #1
0
        public PlayerControlViewModel(PlayersViewModel parent, Player player)
        {
            _parent = parent;
            _player = player;

            ViewModelHelper.BindNotifyChanged(_player, this,
                (sender, e) => RaisePropertyChanged(e.PropertyName));

            ViewModelHelper.BindNotifyChanged(_player.RecordDescription, this,
                (sender, e) => RaisePropertyChanged(e.PropertyName));

            // IsPlayingの状態が変わったら、PlayCommand/StopCommandの有効無効を切り替える
            Observable.FromEventPattern<PropertyChangedEventArgs>(_player, "PropertyChanged")
                .Where(e => e.EventArgs.PropertyName == "IsPlaying" || e.EventArgs.PropertyName == "IsPausing")
                .Subscribe(_ => {
                    _PlayCommand.RaiseCanExecuteChanged();
                    _PauseCommand.RaiseCanExecuteChanged();
                    _StopCommand.RaiseCanExecuteChanged();
                });

            Observable.FromEventPattern<PropertyChangedEventArgs>(_player, "PropertyChanged")
                .Where(e => e.EventArgs.PropertyName == "IsAlive")
                .Subscribe(_ => _ReinitializeCommand.RaiseCanExecuteChanged());

            Observable.FromEventPattern<ErrorInfoEventArgs>(_player, "ErrorRaised")
                .Subscribe(e => Messenger.Raise(new InformationMessage(e.EventArgs.Message, "エラー", "ShowError")));
        }
コード例 #2
0
ファイル: PlayerTest.cs プロジェクト: zoetrope/RtStorage
        public void キャンセルするテスト()
        {
            var description = new RecordDescription()
            {
                CreatedDateTime = DateTime.Now,
                TimeSpan = 17460,
                NamingName = "localhost:2809/ConsoleIn0.rtc",
                ComponentType = "ConsoleIn",
                PortName = "ConsoleIn0.out",
                DataType = "IDL:RTC/TimedLong:1.0",
                SumSize = 228,
                Count = 19,
                IsLittleEndian = 1,
                IndexFileName = "TestData002.index",
                DataFileName = "TestData002.data",
            };

            var player = new Player(description, "127.0.0.1:2809/SampleIn0.rtc", "SampleIn0.in");

            player.IsNotNull();

            player.IsAlive.Is(true);

            player.Start();

            player.IsAlive.Is(true);
            player.IsPlaying.Is(true);

            _observer.Take(3)
                .Do(x => Console.WriteLine(x[8]))
                .Timeout(TimeSpan.FromSeconds(30))
                .ToEnumerable().ToList();

            player.Stop();

            player.IsAlive.Is(true);
            player.IsPlaying.Is(false);
        }
コード例 #3
0
 public void RemovePlayer(Player player)
 {
     _players.Remove(player);
 }
コード例 #4
0
ファイル: PlayerTest.cs プロジェクト: zoetrope/RtStorage
        public void 初期化のテスト()
        {
            var description = new RecordDescription()
            {
                CreatedDateTime = DateTime.Now,
                TimeSpan = 1661,
                NamingName = "127.0.0.1:2809/ConsoleOut0.rtc",
                ComponentType = "SampleOut",
                PortName = "SampleOut0.out",
                DataType = "IDL:RTC/TimedLong:1.0",
                SumSize = 1200,
                Count = 100,
                IsLittleEndian = 1,
                IndexFileName = "TestData001.index",
                DataFileName = "TestData001.data",
            };

            var player = new Player(description, "127.0.0.1:2809/SampleIn0.rtc", "SampleIn0.in");

            player.IsNotNull();

            player.IsAlive.Is(true);
        }
コード例 #5
0
ファイル: PlayerTest.cs プロジェクト: zoetrope/RtStorage
        public void ファイルを再生するテスト()
        {
            var description = new RecordDescription()
            {
                CreatedDateTime = DateTime.Now,
                TimeSpan = 1661,
                NamingName = "127.0.0.1:2809/ConsoleOut0.rtc",
                ComponentType = "SampleOut",
                PortName = "SampleOut0.out",
                DataType = "IDL:RTC/TimedLong:1.0",
                SumSize = 1200,
                Count = 100,
                IsLittleEndian = 1,
                IndexFileName = "TestData001.index",
                DataFileName = "TestData001.data",
            };

            var player = new Player(description, "127.0.0.1:2809/SampleIn0.rtc", "SampleIn0.in");

            player.IsNotNull();

            player.IsAlive.Is(true);

            player.Start();

            player.IsAlive.Is(true);

            // 100回putされるまで待つ。10秒以内に完了しなかったらTimeoutException
            var data = _observer.Take(100)
                .Timeout(TimeSpan.FromSeconds(10))
                .ToEnumerable().ToList();

            data.Count().Is(100);

            player.Stop();

            player.IsAlive.Is(true);
        }