Exemplo n.º 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);*/
        }
Exemplo n.º 2
0
        private void PlaySong(Song song)
        {
            // If the song is null there is nothing to play
            if (song == null)
            {
                if (PlaylistEnded != null)
                {
                    PlaylistEnded();
                }
                return;
            }

            // As soon as we are trying to play any song we are moving forward again.
            playbackDirection = TP_PLAYBACKDIRECTION.Forward;

            string temp = FindAudiofile(song);

            if (temp == "" || temp == null)
            {
                throw new Exception("Zu diesem Song wurde kein Audiofile gefunden.");
            }
            else if (System.IO.File.Exists(temp))
            {
                Stop();

                // This is the point where the song is actually played for real.
                //IMedia media = factory.CreateMedia<IMedia>(temp);
                //factory.CreatePlayer<IAudioPlayer>().Open(media);
                VlcMedia media = new VlcMedia(instance, temp);
                CurrentSong = song;
                if (vlc == null)
                {
                    vlc = new VlcMediaPlayer(media);
                }
                else
                {
                    vlc.Media = media;
                }
                vlc.Play();
                PlaybackState = TP_PLAYBACKSTATE.Playing;
                // If we are not already navigating, log the song to the navigation history so it is available in case the user starts skipping
                if (playbackMode == TP_PLAYBACKMODE.Playlist)
                {
                    totalHistory.Add(song);
                    historyPosition++;
                }
            }
            else
            {
                //TODO: Automatically re-scan
                throw new System.IO.FileNotFoundException("Die Datei des abzuspielenden Songs wurde nicht gefunden. Möglicherweise muss die Bibliothek aktualisiert werden.", temp);
            }
        }