Пример #1
0
 public void OnOpenMedia(string FileName)
 {
     if (FileName != null)
     {
         Console.WriteLine("FileName : " + FileName);
         try
         {
             _player.Source = new Uri(FileName);
             _player.Play();
         }
         catch (Exception)
         {
             MessageBox.Show("Error occured when trying to open media", "Open error", MessageBoxButton.OK, MessageBoxImage.Error);
         }
         if (_media == null)
         {
             _media = Media.CreateMedia(true, FileName, false, ExtensionStatic.GetIconsFromExtension(Path.GetExtension(FileName)));
             _playlist.ListMedia.Add(_media);
         }
         else
         {
             _playlist.ListMedia.Remove(_media);
             _media = Media.CreateMedia(true, FileName, false, ExtensionStatic.GetIconsFromExtension(Path.GetExtension(FileName)));
             _playlist.ListMedia.Add(_media);
         }
     }
 }
        private void AddFromFileCmd()
        {
            OpenFileDialog dlg = new OpenFileDialog();
            bool?          res;

            dlg.Filter = "Playlist Files|*.pls";
            res        = dlg.ShowDialog();
            if (res == true)
            {
                try
                {
                    using (FileStream stream = new FileStream(dlg.FileName, FileMode.Open))
                    {
                        TextReader    reader     = new StreamReader(stream);
                        XmlSerializer serializer = new XmlSerializer(typeof(List <Media>));

                        List <Media> list = (List <Media>)serializer.Deserialize(reader);
                        foreach (Media m in list)
                        {
                            ListMedia.Add(Media.CreateMedia(false, m.FileName, true, ExtensionStatic.GetIconsFromExtension(Path.GetExtension(m.FileName))));
                        }
                    };
                }
                catch (Exception)
                {
                    MessageBox.Show("Error occured when loading playlist" + Environment.NewLine + "Be sure you've correct permissions or you open a well-formated file", "Playlist Error", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            }
        }
Пример #3
0
        private void loadPicturesLibrary()
        {
            try
            {
                using (FileStream stream = new FileStream(@"../../library/pictures.xml", FileMode.OpenOrCreate, FileAccess.Read))
                {
                    TextReader    reader     = new StreamReader(stream);
                    XmlSerializer serializer = new XmlSerializer(typeof(List <PictureMedia>));

                    List <PictureMedia> list = (List <PictureMedia>)serializer.Deserialize(reader);
                    foreach (PictureMedia m in list)
                    {
                        if (m.Title == null)
                        {
                            m.Title = Path.GetFileNameWithoutExtension(m.FileName);
                        }
                        m.Icon = ExtensionStatic.GetIconsFromExtension(Path.GetExtension(m.FileName));
                        if (m.isDisplayable(_search, _typeFilter))
                        {
                            ListPictures.Add(m);
                        }
                    }
                };
            }
            catch (Exception)
            {}
        }
Пример #4
0
        private void loadSongsLibrary()
        {
            try
            {
                using (FileStream stream = new FileStream(@"../../library/songs.xml", FileMode.OpenOrCreate, FileAccess.Read))
                {
                    TextReader    reader     = new StreamReader(stream);
                    XmlSerializer serializer = new XmlSerializer(typeof(List <AudioMedia>));

                    List <AudioMedia> list = (List <AudioMedia>)serializer.Deserialize(reader);
                    foreach (AudioMedia m in list)
                    {
                        if (m.Title == null)
                        {
                            m.Title = Path.GetFileNameWithoutExtension(m.FileName);
                        }
                        System.Console.WriteLine("ddddd-> : " + m.Album);
                        m.Icon = ExtensionStatic.GetIconsFromExtension(Path.GetExtension(m.FileName));
                        if (m.isDisplayable(_search, _typeFilter))
                        {
                            ListSongs.Add(m);
                        }
                    }
                };
            }
            catch (Exception)
            {}
        }
        private void AddCmd()
        {
            OpenFileDialog dialog = new OpenFileDialog();
            bool?          res;

            dialog.Multiselect = true;
            dialog.Filter      = "Video files|*.avi;*.mpg;*.mov;*.asf;*.mkv|Audio files|*.mp3;*.wav;*.wma;*.ogg|Picture Files|*.jpg;*.bmp;*.png|ALL files|*.*";
            res = dialog.ShowDialog();
            if (res == true)
            {
                foreach (string file in dialog.FileNames)
                {
                    ListMedia.Add(Media.CreateMedia(false, file, false, ExtensionStatic.GetIconsFromExtension(Path.GetExtension(file))));
                }
            }
        }
Пример #6
0
        private void addPictureCmd()
        {
            OpenFileDialog dialog = new OpenFileDialog();
            bool?          res;

            dialog.Multiselect = true;
            dialog.Filter      = "Picture Files|*.jpg;*.bmp;*.png";
            res = dialog.ShowDialog();
            if (res == true)
            {
                foreach (string file in dialog.FileNames)
                {
                    PictureMedia tmp = Media.CreateMedia(false, file, false, ExtensionStatic.GetIconsFromExtension(Path.GetExtension(file))) as PictureMedia;

                    if (tmp != null)
                    {
                        ListPictures.Add(tmp);
                    }
                }
            }
            savePictures();
        }
Пример #7
0
        private void addSongCmd()
        {
            OpenFileDialog dialog = new OpenFileDialog();
            bool?          res;

            dialog.Multiselect = true;
            dialog.Filter      = "Audio files|*.mp3;*.wav;*.wma;*.ogg";
            res = dialog.ShowDialog();
            if (res == true)
            {
                foreach (string file in dialog.FileNames)
                {
                    AudioMedia tmp = Media.CreateMedia(false, file, false, ExtensionStatic.GetIconsFromExtension(Path.GetExtension(file))) as AudioMedia;

                    if (tmp != null)
                    {
                        ListSongs.Add(tmp);
                    }
                }
            }
            saveSongs();
        }
Пример #8
0
        private void addVideoCmd()
        {
            OpenFileDialog dialog = new OpenFileDialog();
            bool?          res;

            dialog.Multiselect = true;
            dialog.Filter      = "Video files|*.wmv;*.avi;*.mpg;*.mov;*.asf;*.mkv";
            res = dialog.ShowDialog();
            if (res == true)
            {
                foreach (string file in dialog.FileNames)
                {
                    VideoMedia tmp = Media.CreateMedia(false, file, false, ExtensionStatic.GetIconsFromExtension(Path.GetExtension(file))) as VideoMedia;

                    if (tmp != null)
                    {
                        ListVideos.Add(tmp);
                    }
                }
            }
            saveVideos();
        }
 public void AddFromDrop(string file)
 {
     ListMedia.Add(Media.CreateMedia(false, file, false, ExtensionStatic.GetIconsFromExtension(Path.GetExtension(file))));
 }