Exemple #1
0
        public PlaylistTask(ILogger logger, IAudioPlayer audioPlayer, IVideoPlayer videoPlayer, TaskItem item, TimeSpan delay, Func <TaskItem> getPreviousItem, Func <TaskItem> getNextItem)
            : base(logger, item)
        {
            if (audioPlayer == null)
            {
                throw new ArgumentNullException("audioPlayer");
            }
            if (getPreviousItem == null)
            {
                throw new ArgumentNullException("getPreviousItem");
            }
            if (getNextItem == null)
            {
                throw new ArgumentNullException("getNextItem");
            }

            this.audioPlayer     = audioPlayer;
            this.videoPlayer     = videoPlayer;
            this.delay           = delay;
            this.getPreviousItem = getPreviousItem;
            this.getNextItem     = getNextItem;

            videoPlayer.AddEndedCallback(() => CurrentStreamEnded());
            videoPlayer.AddPlayedCallback(() => PlayCurrentStream());
            videoPlayer.AddPausedCallback(() => PauseCurrentStream());
            videoPlayer.AddPausedCallback(() => PauseVideo());
            videoPlayer.AddResumedCallback(() => ResumeCurrentStream());
            videoPlayer.AddResumedCallback(() => ResumeVideo());
            videoPlayer.AddStoppedCallback(() => StopCurrentStream());
            videoPlayer.AddStoppedCallback(() => StopVideo());
            videoPlayer.AddPreviousItemCallback(() => PreviousItem());
            videoPlayer.AddNextItemCallback(() => NextItem());

            AddCancelledCallback(() => StopCurrentStream());
            AddPausedCallback(() => PauseCurrentStream());
            AddResumedCallback(() => ResumeCurrentStream());
            AddStoppedCallback(() => StopCurrentStream());

            this.timer     = new Timer(200);
            timer.Elapsed += new ElapsedEventHandler(timer_Elapsed);
            timer.Start();
        }