예제 #1
0
        public Player()
        {
            // Initialization (TODO: Make all the stuff configurable, of course)
            Playlist            = new Playlist();
            PlayedHistory       = new List <Song>();
            totalHistory        = new List <Song>();
            Queue               = new List <Song>();
            RandomSettings      = new PlayerRandomSettings(100, true);
            PlaybackState       = TP_PLAYBACKSTATE.Stopped;
            playbackMode        = TP_PLAYBACKMODE.Playlist;
            playbackDirection   = TP_PLAYBACKDIRECTION.Forward;
            PlaybackLoggingMode = TP_PLAYBACKLOG.After80Percent;
            historyPosition     = -1;

            // VLC Initialization
            string[] args = new string[] {
                "--ignore-config",
                @"--plugin-path=C:\Program Files (x86)\VideoLAN\VLC\plugins",
                //,"--vout-filter=deinterlace", "--deinterlace-mode=blend"
            };

            instance = new VlcInstance(args);
            vlc      = null;
            factory  = new MediaPlayerFactory();

            /*vlc = factory.CreatePlayer<IVideoPlayer>();
             * vlc.Events.MediaEnded += new EventHandler(Events_MediaEnded);
             * vlc.Events.TimeChanged += new EventHandler<Declarations.Events.MediaPlayerTimeChanged>(Events_TimeChanged);
             * vlc.Events.PlayerPlaying += new EventHandler(Events_PlayerPlaying);*/
        }
예제 #2
0
        /// <summary>
        /// This function will get you a song to play when you are using a playlist, navigating through history or using the queue.
        /// </summary>
        /// <returns></returns>
        private Song GetNextSong()
        {
            // What are we playing? Is there anything in the queue? Then it has priority. The queue even skips our ultimate filter because
            // it is always user decision. The only exception is we are navigating backwards.
            if (playbackDirection == TP_PLAYBACKDIRECTION.Forward && Queue.Count > 0)
            {
                playbackMode = TP_PLAYBACKMODE.Queue;
                CurrentSong  = Queue[0];
                Queue.RemoveAt(0);
                return(CurrentSong);
            }

            // What are we playing? Songs we already navigated to with Next and Prev? Then play all of them until there are no more before we do anything else.
            // They also skip the filter because if they had not passed the filter they would not be here. Also it would be confusing if navigating back would
            // lack already played songs.
            // The highest element in totalHistory is usually the song that currently plays. If we navigate, the pointer is moved.
            if (historyPosition < totalHistory.Count - 1)
            {
                historyPosition++;
                playbackMode = TP_PLAYBACKMODE.History;
                CurrentSong  = totalHistory[historyPosition];
                return(CurrentSong);
            }

            // Reset the playback mode in case we were navigating before. The mode is important for logging new songs to the history.
            playbackMode = TP_PLAYBACKMODE.Playlist;


            if (Playlist.SongsLeft() && Playlist.Any(delegate(Song needle) { return(AllowSong(needle)); }))
            {
                // If there are any songs left to play from the playlist get a random one that matches our criteria
                while (Playlist.Next() != -1)
                {
                    if (AllowSong(Playlist.Current()))
                    {
                        break;
                    }
                    else
                    {
                        Playlist.Kick();
                    }
                }

                // Set the current song and if necessary raise the PlaylistEnded event.
                CurrentSong = Playlist.Current();
                return(CurrentSong);
            }
            else
            {
                CurrentSong = null;
                return(CurrentSong);
            }
        }
예제 #3
0
        /// <summary>
        /// This function will get you a song to play when you are using a playlist, navigating through history or using the queue.
        /// </summary>
        /// <returns></returns>
        private Song GetNextSong()
        {
            // What are we playing? Is there anything in the queue? Then it has priority. The queue even skips our ultimate filter because
            // it is always user decision. The only exception is we are navigating backwards.
            if (playbackDirection == TP_PLAYBACKDIRECTION.Forward && Queue.Count > 0)
            {
                playbackMode = TP_PLAYBACKMODE.Queue;
                CurrentSong = Queue[0];
                Queue.RemoveAt(0);
                return CurrentSong;
            }

            // What are we playing? Songs we already navigated to with Next and Prev? Then play all of them until there are no more before we do anything else.
            // They also skip the filter because if they had not passed the filter they would not be here. Also it would be confusing if navigating back would
            // lack already played songs.
            // The highest element in totalHistory is usually the song that currently plays. If we navigate, the pointer is moved.
            if (historyPosition < totalHistory.Count - 1)
            {
                historyPosition++;
                playbackMode = TP_PLAYBACKMODE.History;
                CurrentSong = totalHistory[historyPosition];
                return CurrentSong;
            }

            // Reset the playback mode in case we were navigating before. The mode is important for logging new songs to the history.
            playbackMode = TP_PLAYBACKMODE.Playlist;

            if (Playlist.SongsLeft() && Playlist.Any(delegate(Song needle) { return AllowSong(needle); }))
            {
                // If there are any songs left to play from the playlist get a random one that matches our criteria
                while (Playlist.Next() != -1)
                {
                    if (AllowSong(Playlist.Current()))
                        break;
                    else
                        Playlist.Kick();
                }

                // Set the current song and if necessary raise the PlaylistEnded event.
                CurrentSong = Playlist.Current();
                return CurrentSong;
            }
            else
            {
                CurrentSong = null;
                return CurrentSong;
            }
        }
예제 #4
-1
        public Player()
        {
            // Initialization (TODO: Make all the stuff configurable, of course)
            Playlist = new Playlist();
            PlayedHistory = new List<Song>();
            totalHistory = new List<Song>();
            Queue = new List<Song>();
            RandomSettings = new PlayerRandomSettings(100, true);
            PlaybackState = TP_PLAYBACKSTATE.Stopped;
            playbackMode = TP_PLAYBACKMODE.Playlist;
            playbackDirection = TP_PLAYBACKDIRECTION.Forward;
            PlaybackLoggingMode = TP_PLAYBACKLOG.After80Percent;
            historyPosition = -1;

            // VLC Initialization
            string[] args = new string[] {
                "--ignore-config",
                @"--plugin-path=C:\Program Files (x86)\VideoLAN\VLC\plugins",
                //,"--vout-filter=deinterlace", "--deinterlace-mode=blend"
            };

            instance = new VlcInstance(args);
            vlc = null;
            factory = new MediaPlayerFactory();
            /*vlc = factory.CreatePlayer<IVideoPlayer>();
            vlc.Events.MediaEnded += new EventHandler(Events_MediaEnded);
            vlc.Events.TimeChanged += new EventHandler<Declarations.Events.MediaPlayerTimeChanged>(Events_TimeChanged);
            vlc.Events.PlayerPlaying += new EventHandler(Events_PlayerPlaying);*/
        }