Esempio n. 1
0
        /// <summary>
        /// Clears the current playlist, then adds the given file to it. Also,
        /// tries to load the lyrics file if exists.
        /// </summary>
        /// <param name="Filename">The file's name to load.</param>
        /// <returns>True if the file is loaded, false if not.</returns>
        private bool OpenFile(string Filename)
        {
            #region Error checking
            if (!PlaybackFactory.IsSupportedMedia(Filename))
            {
                return(false);
            }
            #endregion

            try {
                ISongInfo SongInfo = new BassSongInfo(Filename);

                this.Playlist.Clear();
                this.Playlist.Add(SongInfo);
                this.Playlist.MoveTo(0);

                return(true);
            }
            catch (Exception e) {
                Trace.TraceWarning("Could not open file: " + e.Message);

                new Toast(App.Name)
                {
                    Title   = "Hoppá...",
                    Content = "Valami miatt nem sikerült a fájlt megnyitni.",
                    Image   = TomiSoft.MP3Player.Properties.Resources.AbstractAlbumArt
                }.Show();

                return(false);
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Adds all files to the playlist that is given as command-line
        /// arguments and starts playing the first one.
        /// </summary>
        private void ProcessCommandLine()
        {
            string[] args = Environment.GetCommandLineArgs();
            foreach (string Filename in args)
            {
                if (PlaybackFactory.IsSupportedMedia(Filename))
                {
                    this.Playlist.Add(new BassSongInfo(Filename));
                }
            }

            this.Playlist.MoveTo(0);
        }
Esempio n. 3
0
        /// <summary>
        /// Adds multiple files to the playlist and starts
        /// playing the first of them.
        /// </summary>
        /// <param name="Filenames">An array containing the files' path</param>
        /// <returns>True if all files are opened successfully, false if not</returns>
        private async Task <bool> OpenFilesAsync(string[] Filenames)
        {
            var SupportedFiles = Filenames.Where(x => PlaybackFactory.IsSupportedMedia(x));

            #region Error checking
            if (SupportedFiles.Count() == 0)
            {
                return(false);
            }
            #endregion

            try {
                this.Playlist.Clear();
                foreach (string Filename in SupportedFiles)
                {
                    if (YoutubeUri.IsValidYoutubeUri(Filename))
                    {
                        this.viewModel.LyricsReader = null;
                        this.viewModel.Lyrics       = "Előkészülünk a letöltéshez...";
                        this.Playlist.Add(await YoutubeSongInfo.GetVideoInfoAsync(Filename));
                    }
                    else
                    {
                        this.Playlist.Add(new BassSongInfo(Filename));
                    }
                }

                this.Playlist.MoveTo(0);
            }
            catch (Exception e) {
                Trace.TraceWarning("Could not open file: " + e.Message);

                new Toast(App.Name)
                {
                    Title   = "Hoppá...",
                    Content = "Valami miatt nem sikerült a fájlokat megnyitni.",
                    Image   = TomiSoft.MP3Player.Properties.Resources.AbstractAlbumArt
                }.Show();

                return(false);
            }

            return(true);
        }
Esempio n. 4
0
        /// <summary>
        /// This method is executed when one or more files were
        /// dropped to the window.
        /// </summary>
        /// <param name="sender">The sender object's instance</param>
        /// <param name="e">Event parameters</param>
        private void Window_Drop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                string[] Files = (string[])e.Data.GetData(DataFormats.FileDrop);
                this.Playlist.Clear();

                foreach (string File in Files)
                {
                    if (PlaybackFactory.IsSupportedMedia(File))
                    {
                        this.Playlist.Add(new BassSongInfo(File));
                    }
                }

                if (this.Playlist.Count > 0)
                {
                    this.Playlist.MoveTo(0);
                }
            }
        }
 public bool IsSupportedMedia(string Source)
 {
     return(PlaybackFactory.IsSupportedMedia(Source));
 }