Exemplo n.º 1
0
 private void CheckVideoDataForErrors(string fullPath, string previewUrl, IWMPMedia vidoInfo, string fileName)
 {
     if (string.IsNullOrEmpty(fullPath) || string.IsNullOrEmpty(previewUrl) || vidoInfo == null || string.IsNullOrEmpty(fileName))
     {
         throw new ArgumentException("The Video data contains errors");
     }
 }
Exemplo n.º 2
0
        public void mc()
        {
            next = player.newMedia(Application.StartupPath + "\\Resources\\0.mp3");
            player.currentPlaylist.appendItem(next);
            next = player.newMedia(Application.StartupPath + "\\Resources\\1.mp3");
            player.currentPlaylist.appendItem(next);
            next = player.newMedia(Application.StartupPath + "\\Resources\\2.mp3");
            player.currentPlaylist.appendItem(next);
            next = player.newMedia(Application.StartupPath + "\\Resources\\3.mp3");
            player.currentPlaylist.appendItem(next);
            next = player.newMedia(Application.StartupPath + "\\Resources\\4.mp3");
            player.currentPlaylist.appendItem(next);
            next = player.newMedia(Application.StartupPath + "\\Resources\\5.mp3");
            player.currentPlaylist.appendItem(next);
            next = player.newMedia(Application.StartupPath + "\\Resources\\6.mp3");
            player.currentPlaylist.appendItem(next);
            next = player.newMedia(Application.StartupPath + "\\Resources\\7.mp3");
            player.currentPlaylist.appendItem(next);
            next = player.newMedia(Application.StartupPath + "\\Resources\\8.mp3");
            player.currentPlaylist.appendItem(next);
            next = player.newMedia(Application.StartupPath + "\\Resources\\9.mp3");
            player.currentPlaylist.appendItem(next);
            next = player.newMedia(Application.StartupPath + "\\Resources\\10.mp3");
            player.currentPlaylist.appendItem(next);
            next = player.newMedia(Application.StartupPath + "\\Resources\\11.mp3");
            player.currentPlaylist.appendItem(next);

            player.settings.autoStart = true;
            player.controls.play();
        }
Exemplo n.º 3
0
 private void zamanFarki(int x)
 {
     if (x == 0)
     {
         StreamReader sr = new StreamReader(veriYoluTxt.Text.ToString());
         while (sr.ReadLine() != null)
         {
             if (sr.ReadLine() != "AccX;AccY;AccZ;GraX;GraY;GraZ;LAX;LAY;LAZ;GyroX;GyroY;GyroZ;Time2" && sr.ReadLine() != "AccX;AccY;AccZ;GraX;GraY;GraZ;LAX;LAY;LAZ;GyroX;GyroY;GyroZ;Time2;")
             {
                 ilkD = sr.ReadLine().Split(';');
                 ilk  = ilkD[ilkD.Length - 1];
                 break;
             }
         }
         son  = File.ReadLines(veriYoluTxt.Text.ToString()).Last();
         sonD = son.Split(';');
         son  = sonD[sonD.Length - 1];
         TimeSpan tilk = TimeSpan.Parse(ilk);
         TimeSpan tson = TimeSpan.Parse(son);
         fark = tson - tilk;
     }
     else if (x == 1)
     {
         WindowsMediaPlayer wmp       = new WindowsMediaPlayerClass();
         IWMPMedia          mediainfo = wmp.newMedia(videoTxt.Text.ToString());
         string             sonV      = "00:" + mediainfo.durationString;
         TimeSpan           tsv       = TimeSpan.Parse(sonV);
         TimeSpan           sonFark   = fark - tsv;
         farkk = Convert.ToInt16(sonFark.TotalSeconds);
     }
 }
        private void openFileToolStripMenuItem_Click(object sender, EventArgs e)
        {
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "Media Files|*.mpg;*.avi;*.wma;*.mov;" + "*.wav;*.mp2;*.mp3|All Files|*.*";
            try
            {
                if (ofd.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    string songName = Path.GetFileName(ofd.FileName);
                    path = ofd.FileName;
                    IWMPMedia media = xWMP.newMedia(path);
                    xWMP.URL = path;

                    listView1.Items.Clear();
                    addItemToListView(songName, lbl_totalDuration.Text = media.durationString, path);
                }
            }
            catch (ArgumentException ex)
            {
                MessageBox.Show(ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message.ToString(), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 5
0
        public void Ekle(string yol, params string[] dosya_Turu) //Dosya dizinini dışardan alarak dosya bilgilerini tablolara ekler.
        {
            mediaL = wmp_Listele.newMedia(yol);                  //media dosyası tanımlanıyor.
            string sanatci, album, tur;

            //Medyanın sanatçı bilgisi boşsa, Bilinmeyen Sanatçı görünecek.
            if (mediaL.getItemInfo("Author") == "")
            {
                sanatci = "Bilinmeyen Sanatçı";
            }
            else
            {
                sanatci = mediaL.getItemInfo("Author");
            }
            //Medyanın albüm bilgisi boşsa, Bilinmeyen Albüm görünecek.
            if (mediaL.getItemInfo("Album") == "")
            {
                album = "Bilinmeyen Albüm";
            }
            else
            {
                album = mediaL.getItemInfo("Album");
            }

            tur = Path.GetExtension(mediaL.sourceURL);

            //Bilgiler DataTable satırına ekleniyor.
            table1.Rows.Add(mediaL.name, mediaL.sourceURL, mediaL.durationString, album, sanatci, tur);
        }
Exemplo n.º 6
0
        public bool UpdatePlayingTrack()
        {
            if (wmp.currentMedia == null)
            {
                return(false);
            }

            string    cTrackID  = string.Empty;
            string    cArtist   = string.Empty;
            string    cAlbum    = string.Empty;
            string    cName     = string.Empty;
            string    cGenre    = string.Empty;
            int       cDuration = 0;
            int       cPosition = 0;
            IWMPMedia current   = wmp.currentMedia;

            try { cTrackID = current.getItemInfo(Attributes.TrackID); }
            catch { }
            try { cArtist = current.getItemInfo(Attributes.Artist); }
            catch { }
            try { cAlbum = current.getItemInfo(Attributes.Album); }
            catch { }
            try { cName = current.getItemInfo(Attributes.Name); }
            catch { }
            try { cGenre = current.getItemInfo(Attributes.Genre); }
            catch { }
            try { cDuration = (int)Double.Parse(current.getItemInfo(Attributes.Duration)); }
            catch { }
            try { cPosition = (int)wmp.controls.currentPosition; }
            catch { }
            PlayingTrack = new TrackInfo(cName, cArtist, cAlbum, cGenre, cTrackID, cDuration, cPosition);


            return(true);
        }
Exemplo n.º 7
0
        //Update playing
        void updatePlaylist(IWMPMedia media)
        {
            ListViewItem lvi;
            int          i = 0;

            for (; i < wp.currentPlaylist.count; i++)
            {
                if (media.sourceURL.Equals(wp.currentPlaylist.Item[i].sourceURL))
                {
                    break;
                }
            }
            for (int j = 0; j < lvPlaylist.Items.Count; j++)
            {
                if (j == i)
                {
                    lvi = lvPlaylist.Items[j];
                    lvi.SubItems[0].Text = "-->";
                }
                else
                {
                    lvi = lvPlaylist.Items[j];
                    lvi.SubItems[0].Text = "";
                }
                lbPlaying.Text      = "Playing : " + media.name;
                hScrollBar1.Value   = 0;
                hScrollBar1.Maximum = Convert.ToInt16(media.duration);
                lbCurrDuration.Text = setDuration();
            }
        }
Exemplo n.º 8
0
        public int addSongs(IWMPPlaylist playlist)
        {
            ArrayList items = new ArrayList();

            for (int j = 0; j < playlist.count; j++)
            {
                IWMPMedia song = playlist.get_Item(j);
                if (song != null)
                {
                    Song item;
                    if (!stats_only)
                    {
                        item = new Song(song);
                    }
                    else
                    {
                        item = new Song(song.name);
                    }
                    if (song.name != null && !song.name.Equals("") && !items.Contains(item))
                    {
                        items.Add(item);
                    }
                }
            }
            items.TrimToSize();
            if (!stats_only)
            {
                songs = items;
            }
            return(items.Count);
        }
Exemplo n.º 9
0
        private void button7_Click(object sender, EventArgs e)
        {
            string temp;

            temp = playMusicList.FocusedItem.SubItems[0].Text;
            if (temp.IndexOf(musicName[timeCount]) != -1)
            {
                MessageBox.Show("현재 재생중인 곡은 삭제할 수 없습니다.");
            }
            else
            {
                int index = playMusicList.FocusedItem.Index;
                playMusicList.Items.RemoveAt(index);
                Media = (IWMPMedia)MediaSaver.GetValue(index);
                PlayList.removeItem(Media);

                for (int i = index; i < maxCount - 1 - index; i++)
                {
                    musicName[i] = musicName[i + 1];
                    timeMax[i]   = timeMax[i + 1];
                    MediaSaver.SetValue((IWMPMedia)MediaSaver.GetValue(i + 1), i);
                }
                maxCount--;
                if (timeCount > index)
                {
                    timeCount--;
                }
                label5.Text = "재생 : " + musicName[timeCount];
            }
        }
Exemplo n.º 10
0
        private void updateControls()
        {
            int maxLenght = 25;

            media = engine.currentMedia;
            if (media.getItemInfo("Artist").Count() > maxLenght)
            {
                lb_artistName.Text = media.getItemInfo("Artist").Substring(0, maxLenght) + "...";
            }
            else
            {
                lb_artistName.Text = media.getItemInfo("Artist");
            }
            if (media.getItemInfo("Title").Count() > maxLenght)
            {
                lb_trackTitle.Text = media.getItemInfo("Title").Substring(0, maxLenght) + "...";
            }
            else
            {
                lb_trackTitle.Text = media.getItemInfo("Title");
            }
            if (media.getItemInfo("Album").Count() > maxLenght)
            {
                lb_albumName.Text = media.getItemInfo("Album").Substring(0, maxLenght) + "...";
            }
            else
            {
                lb_albumName.Text = media.getItemInfo("Album");
            }

            CoverArt.Image = Library.createTrack(media.sourceURL).CoverHighRes;
            Logic.Controller controller = Controller.getController();

            ts = new DateTime();
        }
Exemplo n.º 11
0
        public PlaylistModel(String query)
        {
            res = new List <string>();
            WindowsMediaPlayer wmpInstance = new WindowsMediaPlayer();
            IWMPPlaylist       lib         = wmpInstance.mediaCollection.getByAttribute("MediaType", "audio");

            for (var i = 0; i < lib.count; i++)
            {
                IWMPMedia item   = lib.get_Item(i);
                string    artist = item.getItemInfo("WM/AlbumArtist") + " ";
                string    album  = item.getItemInfo("WM/AlbumTitle") + " ";
                string    title  = item.getItemInfo("Title");
                if (query != "" && query != null)
                {
                    if (artist.Contains(query) || album.Contains(query) || title.Contains(query))
                    {
                        res.Add(artist + album + title);
                    }
                }
                else
                {
                    res.Add(artist + album + title);
                }
            }
        }
Exemplo n.º 12
0
 public Album(string name, IWMPPlaylist playlist)
 {
     album = name;
     if (playlist != null)
     {
         int count = 0;
         if (playlist.count > 1)
         {
             count = 2;
         }
         else
         {
             count = 1;
         }
         for (int j = 0; j < count; j++)
         {
             IWMPMedia item = playlist.get_Item(j);
             if (item != null)
             {
                 album_artist = item.getItemInfo("WM/AlbumArtist");
                 year         = item.getItemInfo("WM/OriginalReleaseYear");
                 if (year.Equals("") || year.Length < 4)
                 {
                     year = item.getItemInfo("WM/Year");
                 }
                 if (!genres.Contains(item.getItemInfo("WM/Genre")))
                 {
                     genres.Add(item.getItemInfo("WM/Genre"));
                 }
             }
         }
     }
 }
Exemplo n.º 13
0
        public CurrentState(RemotedWindowsMediaPlayer remotePlayer)
        {
            IWMPMedia    current_item = remotePlayer.getCurrentMediaItem();
            IWMPPlaylist playlist     = remotePlayer.getNowPlaying();
            int          index        = -1;

            if (playlist != null && playlist.count > 0)
            {
                for (int j = 0; j < playlist.count; j++)
                {
                    IWMPMedia item = playlist.get_Item(j);
                    if (item != null && item.get_isIdentical(current_item))
                    {
                        index = j;
                    }
                }
            }
            if (index >= 0)
            {
                current_track = new PlaylistTrack(index, current_item);
            }
            shuffle_mode = remotePlayer.isShuffleModeEnabled();
            play_state   = getTruncatedPlayState(remotePlayer.getPlayState());
            VolumeCmd volumeCmd = new VolumeCmd();

            volume   = volumeCmd.getVolume();
            is_muted = volumeCmd.isMuted();
        }
Exemplo n.º 14
0
        // Open filedialog to allow user to add multiple files to the playlist
        private void BtnAddMedia_Click(object sender, EventArgs e)
        {
            if (LstLibrary.SelectedIndex != -1)
            {
                if (openFileDialog.ShowDialog() == DialogResult.OK)
                {
                    try
                    {
                        string[] files = openFileDialog.FileNames;
                        foreach (string file in files)
                        {
                            // use IWMPMedia interface to extract media details
                            IWMPMedia iwmp = wmPlayer.newMedia(file);
                            // add the new Media object to playlist
                            selectedPlaylist.Add(new Media(file)
                            {
                                Title    = iwmp.name,
                                Duration = iwmp.duration,
                                Artist   = iwmp.getItemInfo("Author")
                            });
                        }
                    } catch (Exception ex)
                    {
                        MessageBox.Show(ex.Message);
                    }

                    // update playlist listbox
                    UpdatePlaylist();
                }
            }
        }
Exemplo n.º 15
0
 public TimeSpan?GetDuration(string filePath)
 {
     try
     {
         using (ShellObject shell = ShellObject.FromParsingName(filePath))
         {
             IShellProperty prop  = shell.Properties.System.Media.Duration;
             var            value = prop.ValueAsObject;
             return(TimeSpan.FromTicks((long)(ulong)value));
             // Duration will be formatted as 00:44:08
             //string duration = prop.FormatForDisplay(PropertyDescriptionFormatOptions.None);
         }
     }
     catch (Exception e)
     {
         Debug.WriteLine(e);
         try
         {
             IWMPMedia mediainfo = _wmp.newMedia(filePath);
             var       duration  = mediainfo.duration;
             if (duration < double.Epsilon)
             {
                 return(null);
             }
             return(TimeSpan.FromSeconds(duration));
         }
         catch (Exception e2)
         {
             Debug.WriteLine(e);
             return(null);
         }
         return(null);
     }
 }
Exemplo n.º 16
0
 public Audio(IWMPMedia media)
 {
     Media     = media;
     Name      = Path.GetFileNameWithoutExtension(Media.sourceURL);
     Duration  = Media.duration;
     SourceUrl = Media.sourceURL;
 }
Exemplo n.º 17
0
        public Double Duration(String file)
        {
            WindowsMediaPlayer wmp       = new WindowsMediaPlayerClass();
            IWMPMedia          mediainfo = wmp.newMedia(file);

            return(mediainfo.duration);
        }
Exemplo n.º 18
0
 public frmProperties(IWMPMedia media)
 {
     InitializeComponent();
     myMp3.Read(media.sourceURL);
     this.Text = "Properties - " + media.name;
     fi        = new FileInfo(media.sourceURL);
     //File name
     setItem("File name", fi.Name, 0);
     //Folder name
     setItem("Folder name", fi.DirectoryName, 0);
     //File path
     setItem("File Path", fi.FullName, 0);
     //Size
     setItem("Size", String.Format("{0:0.00}", fi.Length * 0.000001) + " MB " + "(" + fi.Length.ToString("### ### ### ###") + " bytes)", 0);
     //Last moddified
     setItem("Last moddified", fi.LastWriteTimeUtc.ToString(), 0);
     //Duration
     setItem("Duration", media.durationString + " (" + media.duration.ToString() + " samples)", 1);
     //Bitrate
     setItem("Bitrate", Convert.ToInt32(media.getItemInfo("BitRate")) / 1000 + " kbps", 1);
     //Title
     setItem("Title", media.getItemInfo("title"), 1);
     //Genre
     setItem("Genre", myMp3.Genre, 1);
     //Album
     setItem("Album", media.getItemInfo("album"), 1);
     //Artist
     setItem("Artist", media.getItemInfo("artist"), 1);
     //Copyright
     setItem("Copyright", media.getItemInfo("copyright"), 1);
     //Track number
     setItem("Track number", myMp3.TrackNum.ToString(), 1);
     //MD5
     setItem("Audio MD5", GetMD5HashFromFile(media.sourceURL), 1);
 }
Exemplo n.º 19
0
        static Double getDuration(string file)
        {
            WindowsMediaPlayer wmp       = new WindowsMediaPlayer();
            IWMPMedia          mediainfo = wmp.newMedia(file);

            return(mediainfo.duration);
        }
Exemplo n.º 20
0
        private void buildDictionary()
        {
            // Create playlists to hold Dictionary and message
            dictionary = Player.newPlaylist("Dictionary", null);

            playlist = Player.newPlaylist("ATIS", null);

            // For every word in enum words, create a corresponding IWMPMedia object

            int length = Enum.GetNames(typeof(words)).Length;

            for (int i = 0; i < length; i++)
            {
                words  word = (words)i;
                string addr = @"Resources\" + word.ToString() + ".wav";
                if (File.Exists(addr))
                {
                    IWMPMedia clip = Player.newMedia(addr);
                    clip.name = word.ToString();
                    dictionary.appendItem(clip);
                }
                else
                {
                    MessageBox.Show("Could not find the file " + addr);
                    break;
                }
            }
            Player.settings.setMode("loop", true);
            Player.settings.autoStart = false;
        }
Exemplo n.º 21
0
        }//void

        public void parcala()
        {
            VideoFileReader reader = new VideoFileReader();
            IWMPMedia       saniye = axWindowsMediaPlayer1.newMedia(ofdVideoYukle.FileName);

            videoFrameList.Clear();

            reader.Open(ofdVideoYukle.FileName);
            this._TotalFrameCount = (int)saniye.duration * reader.FrameRate;
            this._VideoFPS        = reader.FrameRate;
            progressBar1.Maximum  = this._TotalFrameCount;
            FrameSayisi           = _TotalFrameCount;
            for (int i = 0; i < this._TotalFrameCount; i++)
            {
                Bitmap videoFrame = reader.ReadVideoFrame();
                string yol        = "C://Users//BegovicTeam//Desktop//video sıkıştırma//frameparcalanmis//" + "image" + i + ".mpeg";
                convertMpeg(videoFrame, yol);
                progressBar1.Value += 1;
            }
            reader.Close();
            reader.Dispose();

            birlestir();

            frameParcala.Abort();
        }
Exemplo n.º 22
0
 /// <summary>
 /// 添加播放内容
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void 添加ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     try
     {
         DialogResult result = openFileDialog.ShowDialog();
         if (result == DialogResult.OK)
         {
             if (Path.GetExtension(openFileDialog.FileName).ToLower() == ".ppt" || Path.GetExtension(openFileDialog.FileName).ToLower() == ".pptx")
             {
                 this.AddFile(openFileDialog.FileName);
             }
             else
             {
                 this.AddFile(openFileDialog.FileName);
             }
             if (playList.SelectedIndex != -1 && !isBrowPPT)
             {
                 IWMPMedia curntMedia = mediaPlayer.currentPlaylist.get_Item(playList.SelectedIndex);
                 mediaPlayer.Ctlcontrols.playItem(curntMedia);
             }
         }
     }
     catch (Exception error)
     {
         ExceptionHandler.Handle(error);
     }
 }
Exemplo n.º 23
0
        private void prevButton_Click(object sender, EventArgs e)
        {
            if (musicfile.Count == 0)
            {
                return;
            }

            if (axWindowsMediaPlayer1.currentMedia == null)
            {
                return;
            }

            if (playlistListbox.SelectedIndex == 0)
            {
                IWMPMedia media = axWindowsMediaPlayer1.currentPlaylist.Item[playlistListbox.Items.Count - 1];
                axWindowsMediaPlayer1.Ctlcontrols.playItem(media);
                return;
            }

            axWindowsMediaPlayer1.Ctlcontrols.previous();

            if (checkStatusPlayMusic == false)
            {
                checkMusicPaused = true;
            }

            musicNameLabel.Text = "Music: " + axWindowsMediaPlayer1.currentMedia.name;
        }
Exemplo n.º 24
0
        public static int Duration(string file)
        {
            WindowsMediaPlayer wmp       = new WindowsMediaPlayerClass();
            IWMPMedia          mediainfo = wmp.newMedia(file);

            return((int)mediainfo.duration);
        }
Exemplo n.º 25
0
        public static Track CreateTrack(IWMPMedia item)
        {
            var mediatype = item.getItemInfo("MediaType");
            if (!mediatype.Equals("audio")) return null;

            var track = new Track {Title = item.name};

            ushort index;
            if (ushort.TryParse(item.getItemInfo("WM/TrackNumber"),out index)) track.TrackNo = index;

            track.Artist = item.getItemInfo("Author");
            track.AlbumArtist = item.getItemInfo("WM/AlbumArtist");
            if (IsEmpty(track.AlbumArtist)&&!IsEmpty(track.Artist)) track.AlbumArtist = track.Artist;
            if (IsEmpty(track.Artist)&&!IsEmpty(track.AlbumArtist)) track.Artist = track.AlbumArtist;
            track.Album = item.getItemInfo("WM/AlbumTitle");
            if (IsEmpty(track.Album)) track.Album = "Unknown";
            track.Duration = item.duration;
            track.URL = item.sourceURL;

            if (IsEmpty(track.Title)||IsEmpty(track.Artist)||IsEmpty(track.AlbumArtist)||IsEmpty(track.Album))
            {
                Console.WriteLine("Found empty string");
            }

            return track;
        }
Exemplo n.º 26
0
        public List <RPMusicSong> GetAllSongs()
        {
            if (!Settings.Default.EnableMusicLibrary)
            {
                return(new List <RPMusicSong>());
            }

            WindowsMediaPlayer WMPlayer = new WindowsMediaPlayer();
            List <RPMusicSong> output   = new List <RPMusicSong>();

            // Find all songs
            IWMPPlaylist pl = WMPlayer.mediaCollection.getByAttribute("MediaType", "Audio");

            for (int s = 0; s < pl.count; s++)
            {
                IWMPMedia song = pl.get_Item(s);

                RPMusicSong RPsong = CreateRPMusicSongFromIWMPMediaSong(song);
                if (RPsong != null)
                {
                    output.Add(RPsong);
                }
            }

            WMPlayer.close();
            return(output);
        }
Exemplo n.º 27
0
        public double GetLength(String file)
        {
            WindowsMediaPlayer wmp       = new WindowsMediaPlayer();
            IWMPMedia          mediainfo = wmp.newMedia(file);

            return(mediainfo.duration);
        }
Exemplo n.º 28
0
        public RPMusicSong CreateRPMusicSongFromIWMPMediaSong(IWMPMedia song)
        {
            string FN = song.sourceURL;
            if (!File.Exists(FN)) return null;

            RPMusicSong RPsong = new RPMusicSong();
            RPsong.ArtistID = song.getItemInfo("Author");
            //RPsong.FileName = song.sourceURL;
            RPsong.ID = song.getItemInfo("TrackingID");
            string userRating = song.getItemInfo("UserRating");
            int intRating;
            if (int.TryParse(userRating, out intRating))
                RPsong.UserRating = intRating;
            RPsong.Title = song.getItemInfo("Title");
            RPsong.Duration = (long)song.duration;

            // Just store extension for now so client knows what type of music file this is
            RPsong.FileExtension = Path.GetExtension(FN);
            FileInfo fi = new FileInfo(FN);
            RPsong.FileSizeBytes = fi.Length;

            int intTrackNumber;
            string strTrackNumber = song.getItemInfo("WM/TrackNumber");

            if ((! string.IsNullOrEmpty(strTrackNumber)) && (int.TryParse(strTrackNumber, out intTrackNumber)))
                RPsong.TrackNumber = intTrackNumber;
            return RPsong;
        }
Exemplo n.º 29
0
 public Track(IWMPMedia media)
 {
     Media       = media;
     SRC         = media.sourceURL;
     Title       = Path.GetFileNameWithoutExtension(SRC);
     DurationRaw = media.duration;
 }
Exemplo n.º 30
0
        private void addButton_Click(object sender, EventArgs e)
        {
            if (filePath.Text.ToString() == "")
            {
                MessageBox.Show("Please select a valid file");
                return;
            }

            WindowsMediaPlayer wmp       = new WindowsMediaPlayer();
            IWMPMedia          mediainfo = wmp.newMedia(audioFilePath);
            int minutes = (int)mediainfo.duration / 60;
            int seconds = (int)mediainfo.duration % 60;

            string time;

            if (seconds < 10)
            {
                time = minutes.ToString() + ":0" + seconds.ToString();
            }
            else
            {
                time = minutes.ToString() + ":" + seconds.ToString();
            }

            audioList.Items.Add(new ListViewItem(new String[] { id.ToString(), audioName, time }));
            id++;
        }
Exemplo n.º 31
0
        private void buildPlaylist()
        {
            blankPlaylist();

            // For every number in the msgList, look up the corresponding word in enum words
            // if there is no IWMPMedia object with that name, create one and add it to the new playlist
            // else just add the one that already exists
            foreach (int number in msgList)
            {
                IWMPMedia clip;
                words     word  = (words)number;
                IWMPMedia dword = dictionary.get_Item(number);
                if (dword.name == word.ToString())
                {
                    playlist.appendItem(dword);
                }
                else
                {
                    string addr = @"Resources\" + word.ToString() + ".wav";
                    clip      = Player.newMedia(addr);
                    clip.name = word.ToString();
                    playlist.appendItem(clip);
                }
            }
            Player.currentPlaylist = playlist;
        }
Exemplo n.º 32
0
        public void incrementTrackPlaycount(string track, string album, string artist, int playCount)
        {
            translate(ref artist, ref album);
            IWMPPlaylist list = collection.getByAttribute("WM/AlbumTitle", album);

            for (int i = 0; i < list.count; ++i)
            {
                IWMPMedia item = list.get_Item(i);
                if (
                    (track.ToLower() == item.getItemInfo("Title").ToLower())
                    &&
                    (artist.ToLower() == item.getItemInfo("WM/AlbumArtist").ToLower())
                    &&
                    (album.ToLower() == item.getItemInfo("WM/AlbumTitle").ToLower())
                    )
                {
                    string pc = item.getItemInfo("UserPlayCount");
                    int    p  = int.Parse(pc) + playCount;
                    //item.setItemInfo("UserPlayCount", p.ToString());
                    Console.WriteLine("Updating: {0} {1} {2}", track, album, p);

                    return;
                }
            }
            Console.WriteLine("Not found: {0} {1} {2}", track, album, artist);
            skipOrRename(artist, album, track, playCount);
        }
Exemplo n.º 33
0
 /// <summary>
 /// Create a new song from the given media object
 /// </summary>
 /// <param name="iWmpMedia">The media object that represents the song</param>
 public WmpSong(IWMPMedia iWmpMedia)
 {
     this.Media = iWmpMedia;
     this.Title = iWmpMedia.getItemInfo(Wmp.WMTitle);
     this.Artist = iWmpMedia.getItemInfo(Wmp.WMAuthor);
     this.Album = iWmpMedia.getItemInfo(Wmp.WMAlbumTitle);
     this.Genre = iWmpMedia.getItemInfo(Wmp.WMGenre);
 }
        private string GetArtist(IWMPMedia mediaItem)
        {
            string artist = mediaItem.getItemInfoByAtom(albumArtistIndex);
            if (string.IsNullOrEmpty(artist) || artist == "VARIOUS ARTISTS")
            {
                artist = mediaItem.getItemInfoByAtom(authorIndex);
            }

            return artist;
        }
Exemplo n.º 35
0
 public MediaItem(IWMPMedia media)
 {
     if (media != null)
     {
         album = media.getItemInfo("WM/AlbumTitle");
         album_artist = media.getItemInfo("WM/AlbumArtist");
         song = media.getItemInfo("Title");
         song_artist = media.getItemInfo("Author");
         number = media.getItemInfo("WM/TrackNumber");
         duration = media.durationString;
     }
 }
Exemplo n.º 36
0
        private void axWindowsMediaPlayer1_Enter(object sender, EventArgs e)
        {
            axWindowsMediaPlayer1.PlayStateChange += new AxWMPLib._WMPOCXEvents_PlayStateChangeEventHandler(wplayer_PlayStateChange);

            playList = axWindowsMediaPlayer1.playlistCollection.newPlaylist("ExpectoPatronumVideos");
            preMovie = axWindowsMediaPlayer1.newMedia(PRE_MOVIE);
            playList.appendItem(preMovie);
            loopMovie = axWindowsMediaPlayer1.newMedia(LOOP_MOVIE);
            //playList.appendItem(loopMovie);
            postMovie = axWindowsMediaPlayer1.newMedia(POST_MOVIE);

            axWindowsMediaPlayer1.currentPlaylist = playList;
        }
Exemplo n.º 37
0
        private void axWindowsMediaPlayer1_Enter(object sender, EventArgs e)
        {
            axWindowsMediaPlayer1.PlayStateChange += new AxWMPLib._WMPOCXEvents_PlayStateChangeEventHandler(wplayer_PlayStateChange);
            //axWindowsMediaPlayer1.URL = @"C:\Users\CLARISSA RAMOS\Documents\GitHub\wiiwandz\HarryParty\media\videos\arania_exumai_pre.mp4";
            //axWindowsMediaPlayer1.settings.autoStart = false;
            //axWindowsMediaPlayer1.Ctlcontrols.play();
            playList = axWindowsMediaPlayer1.playlistCollection.newPlaylist("ExpectoPatronumVideos");
            preMovie = axWindowsMediaPlayer1.newMedia(PRE_MOVIE);
            playList.appendItem(preMovie);
            loopMovie = axWindowsMediaPlayer1.newMedia(LOOP_MOVIE);
            //playList.appendItem(loopMovie);
            postMovie = axWindowsMediaPlayer1.newMedia(POST_MOVIE);

            axWindowsMediaPlayer1.currentPlaylist = playList;
            //WMPLib.IWMPMedia3 preFile = (WMPLib.IWMPMedia3)axWindowsMediaPlayer1.mediaCollection.getAll().get_Item(0);
            //axWindowsMediaPlayer1.currentMedia = preFile;
        }
Exemplo n.º 38
0
        private static WmpMedia GetItem(IWMPMedia media)
        {
            var displayArtist = media.getItemInfo("DisplayArtist");
            var album = media.getItemInfo("Album");
            var title = media.getItemInfo("Title");
            var userRating = media.getItemInfo("UserRating");
            var acquisitionTime = media.getItemInfo("AcquisitionTime");
            var userPlayCount = media.getItemInfo("UserPlayCount");
            var userLastPlayedTime = media.getItemInfo("UserLastPlayedTime");
            var wmGenre = media.getItemInfo("WM/Genre");
            var sourceUrl = media.getItemInfo("SourceURL");
            var duration = media.getItemInfo("Duration");
            var bitrate = media.getItemInfo("Bitrate");

            return new WmpMedia(displayArtist, album, title, userRating, acquisitionTime, userPlayCount,
                                userLastPlayedTime, wmGenre, sourceUrl, duration, bitrate);
        }
Exemplo n.º 39
0
        /// <summary>
        /// in this form, we will use the list, and class from the main form to add more songs to the playlist and listbox
        /// this form will add, delete, and be able to pick songs to play from the listbox when a user double clicks a selected index or box inside the listbox
        /// also, in the main form, we will check how many songs there are in the playlist and update everytime a song is added or deleted
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        /// look at the IWMP Customslider interface/class sometime
        private void addToPlaylistBTN_Click(object sender, EventArgs e)
        {
            main = new Form1();//initialised for use inside this function

            main.pickASong.Filter = "MP3 Files|*.mp3";//filtering out the open dialog
            main.pickASong.Multiselect = true;
            if (main.pickASong.ShowDialog() == DialogResult.OK)
            {
                foreach (string url in main.pickASong.FileNames)//to select multiple files to add in a playlist
                {

                    this.media = main.p.newMedia(url);
                    Form1.currentPlaylist.Add(media);

                    playListBox1.Items.Add(media.name);
                }
            }
        }
Exemplo n.º 40
0
 public Track(IWMPMedia item)
     : base(item)
 {
     track_number = item.getItemInfo("WM/TrackNumber");
 }
Exemplo n.º 41
0
 public void appendItem(IWMPMedia pIWMPMedia)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 42
0
 public void addTrack(IWMPMedia item)
 {
     Track track = new Track(item);
     if (!genre.Contains(track.genre)) genre.Add(track.genre);
     year = track.year;
     album_artist = item.getItemInfo("WM/AlbumArtist");
     tracks.Add(track);
 }
Exemplo n.º 43
0
        private void Form1_Load(object sender, EventArgs e)
        {
            imgCerrar.Visible = false;
            mute.Visible = false;
            habilitarDragDrop();
            obtenerValoresAleatorios(); // Relleno el arrays de valores de los atributos con números aleatorios.
            deshabilitarHabilidades(); // Para que no se puedan marcar si no hay personaje seleccionado.
            lblHabilidadesPorSelec.Text = Constantes.HAB_POR_SELEC + habPorSelect;
            resetFlechasAtributos();
            // Oculto todos los elementos para emular un menú de carga.
            ocultarPaginaNewPersonaje();
            panelVistaPersonaje.Visible = false;
            menuSeleccion.Visible = false;
            ocultarModoEdicion();
            album.importarPjs();
            actualizarFlechasDesplazamiento();
            if (!album.vacio()) {
                imgAlbum.BackgroundImage = Properties.Resources.album;
                imgAlbum.Enabled = true;
            } else
                imgAlbum.Enabled = false;

            this.Cursor = new Cursor(cursor); // Cambio el cursor.
            playlist = reproductor.playlistCollection.newPlaylist("myplaylist"); // Creo la lista.
            media = reproductor.newMedia(System.IO.Path.GetFullPath(@"songGOT.mp3")); // Agrego canción a media.
            playlist.appendItem(media); // agrego canción a la lista.
            media = reproductor.newMedia(System.IO.Path.GetFullPath(@"songMGS2.mp3"));
            playlist.appendItem(media);
            media = reproductor.newMedia(System.IO.Path.GetFullPath(@"songLR.mp3"));
            playlist.appendItem(media);
            media = reproductor.newMedia(System.IO.Path.GetFullPath(@"songAR1.mp3"));
            playlist.appendItem(media);
            reproductor.currentPlaylist = playlist; // asigno la lista al reproductor.
            reproductor.settings.setMode("loop", true); // para que vuelva a empezar cuando acabe.
            reproductor.controls.play(); // Doy al play!
        }
Exemplo n.º 44
0
        private void setMediaItem(IWMPMedia item, int j)
        {
            if (item != null)
            {

                if (Player != null)
                {
                    Player.currentPlaylist.appendItem(item);
                }
                else
                {
                    bool append;
                    if (j == 0)
                    {
                        append = m_appendToQueue;
                    }
                    else
                    {
                        append = true;
                    }
                    AddInHost.Current.MediaCenterEnvironment.PlayMedia(MediaType.Audio, item.sourceURL, append);
                }
            }
        }
Exemplo n.º 45
0
 private void AddMedia(string filename)
 {
     m_media = m_wmp.newMedia(filename);
     if (m_media.getItemInfo("FileSize") == "")
     {
         System.Windows.MessageBox.Show("The following file is not a proper media :\n" + filename, "File type", MessageBoxButton.OK, MessageBoxImage.Error);
         return;
     }
     string sfilesize;
     double filesize = double.Parse(m_media.getItemInfo("FileSize"));
     if (filesize / 1073741824 >= 1)
         sfilesize = Math.Round(filesize / 1073741824, 1).ToString() + "Gb";
     else if (filesize / 1048576 >= 1)
         sfilesize = ((int)filesize / 1048576).ToString() + "Mb";
     else
         sfilesize = ((int)filesize / 1024).ToString() + "Kb";
     m_playlist.Add(
         filename,
         m_media.getItemInfo("Title"),
         m_media.getItemInfo("Artist"),
         m_media.durationString,
         m_media.getItemInfo("Genre"),
         m_media.getItemInfo("ReleaseDateYear"),
         sfilesize,
         m_media.getItemInfo("MediaType"),
         m_media.getItemInfo("Album"));
 }
Exemplo n.º 46
0
        /// <summary>
        /// Open new audio from the Library.
        /// </summary>
        private void btnOpen_Click(object sender, System.EventArgs e)
        {
            Library libForm = new Library();
            libForm.WMPlayer = Player;
            libForm.ShowDialog();
            if (libForm.DialogResult == DialogResult.OK)
            {
                try
                {
                    theMedia = libForm.TheMedia;

                    if(theMedia != null) // Test whether the user chose a media item.
                    {
                        lblSongName.Text = theMedia.name;
                        lblSourceURL.Text = theMedia.sourceURL;

                        // Set the current media. It will play automatically.
                        Player.currentMedia = theMedia;
                    }
                }
                catch(COMException comExc)
                {
                    int hr = comExc.ErrorCode;
                    String Message = String.Format("There was an error.\nHRESULT = {1}\n{2}", hr.ToString(), comExc.Message);
                    MessageBox.Show(Message, "COM Exception");
                }
             }
        }
Exemplo n.º 47
0
 public MediaProperty(IWMPMedia Media)
 {
     this.Media = Media;
 }
Exemplo n.º 48
0
 /// <summary>
 /// Select media item.
 /// </summary>
 private void listBox1_SelectedIndexChanged(object sender, System.EventArgs e)
 {
     try
     {
         // Retrieve the selected item as an IWMPMedia.
         theMedia = mediaPlaylist.get_Item(listBox1.SelectedIndex);
     }
     catch(COMException comExc)
     {
         int hr = comExc.ErrorCode;
         String Message = String.Format("There was an error.\nHRESULT = {1}\n{2}", hr.ToString(), comExc.Message);
         MessageBox.Show(Message, "COM Exception");
     }
 }
Exemplo n.º 49
0
        //private int num_channels = 2;
        public string GetDuration(string path,long file_length ,out double secs_duration)
        {
            try
            {
                string audio_duration = "-1";
                mediainfo = null;
                secs_duration = 0.0;

                if (File.Exists(path))
                {
                    if (path.ToUpper().Contains("MP3"))
                    {
                        mediainfo = wmp.newMedia(path);

                        if (mediainfo.duration > 0.0)
                        {
                            //audio_duration = mediainfo.durationString;
                            audio_duration = mediainfo.duration.ToString();
                            secs_duration = mediainfo.duration;
                        }

                    }
                    else if( path.ToUpper().Contains("WAV"))
                    {
                        secs_duration = Math.Round( ((file_length - header) / (sample_rate * (bit_rate / 8.0)))/2.0 , 3);
                        audio_duration = secs_duration.ToString();
                    }
                    else
                    {
                        label_play.Text = ("Audio file extension not identified: " + path);
                    }

                }
                else
                {
                    label_play.Text = ("Audio file not found: " + path);
                }

                return audio_duration;
            }
            catch
            {
                secs_duration = 0.0;
                return "-1";

            }
        }
Exemplo n.º 50
0
        public void restore(string path)
        {
            XmlTextReader reader = new XmlTextReader(path);
            string url;
            string attrName = "";
            string restoreLibPath = "C:\\Users\\Michael\\Music";
            string backupLibPath = "H:\\My Music";
            while (reader.Read())
            {
                if (reader.NodeType == XmlNodeType.Element)
                {
                    if (reader.Name == "library")
                        continue;
                    if (reader.Name == "MediaItem")
                    {
                        if (reader.HasAttributes)
                        {
                            reader.MoveToNextAttribute();
                            url = reader.Value;
                            reader.MoveToElement();
                            string searchUrl = url.Replace(backupLibPath, restoreLibPath);
                            Trace.WriteLine(searchUrl);
                            IWMPPlaylist pl = m_media.getByAttribute("SourceURL", searchUrl);
                            if(pl.count == 1)
                                m_mediaItem = pl.get_Item(0);
                            else
                                m_mediaItem = null;
                        }
                        else
                        {
                        }
                    }
                    else
                    {
                        attrName = reader.Name.Replace('-', '/');
                    }

                }
                else if (m_mediaItem != null && reader.NodeType == XmlNodeType.Text)
                {
                    try
                    {
                        Trace.WriteLine(attrName + " = " + reader.Value);
                        m_mediaItem.setItemInfo(attrName, reader.Value);
                    }
                    catch (UnauthorizedAccessException e)
                    {
                    }
                }
            }
        }
Exemplo n.º 51
0
 public Song(IWMPMedia item)
 {
     song = item.getItemInfo("Title");
     song_artist = item.getItemInfo("Author");
     duration = item.durationString;
     year = item.getItemInfo("WM/OriginalReleaseYear");
     if (year.Equals("") || year.Length < 4) year = item.getItemInfo("WM/Year");
     genre = item.getItemInfo("WM/Genre");
 }
Exemplo n.º 52
0
        private byte[] GetTrackArt(WindowsMediaPlayer player, IWMPMedia track, string collectionId)
        {
            byte[] imageData = null;
            if (!string.IsNullOrEmpty(track.sourceURL) && File.Exists(track.sourceURL))
            {
                // Try and find the album art that WMP, WMC, Zune creates. I'd much rather read from
                // a local JPEG than try to read from media that's currently playing and probably locked
                FileInfo pathInfo = new FileInfo(track.sourceURL);
                //LogUtility.LogMessage(pathInfo.FullName + " exists");
                FileInfo albumArtInfo = new FileInfo(string.Format("{0}{1}AlbumArt_{2}_Large.jpg",
                    pathInfo.DirectoryName, Path.DirectorySeparatorChar, collectionId));

                if (!albumArtInfo.Exists)
                {
                    albumArtInfo = new FileInfo(string.Format("{0}{1}AlbumArt_{2}_Small.jpg",
                       pathInfo.DirectoryName, Path.DirectorySeparatorChar, collectionId));
                }

                if (!albumArtInfo.Exists)
                {
                    albumArtInfo = new FileInfo(string.Format("{0}{1}ZuneAlbumArt.jpg",
                       pathInfo.DirectoryName, Path.DirectorySeparatorChar));
                }

                //LogUtility.LogMessage("Album art path is " + albumArtInfo.FullName);
                if (albumArtInfo.Exists)
                {
                    //LogUtility.LogMessage("Album art exists");
                    using (FileStream artStream = albumArtInfo.OpenRead())
                    {
                        byte[] artInfo = new byte[artStream.Length];
                        artStream.Read(artInfo, 0, (int)artStream.Length);
                        imageData = artInfo;
                    }
                }
            }

            // Couldn't get the art from the folder.jpg, so now try to read the id3 tag
            if (File.Exists(track.sourceURL))
            {
                using (FileStream fileStream = new FileStream(track.sourceURL, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                {
                    try
                    {
                        TagContainer tags = new Id3TagManager().ReadV2Tag(fileStream);
                        if (tags != null)
                        {
                            IFrame apicFrame = tags.SearchFrame("APIC");
                            if (apicFrame != null)
                            {
                                PictureFrame pictureFrame = FrameUtilities.ConvertToPictureFrame(apicFrame);
                                imageData = pictureFrame.PictureData.ToArray<byte>();
                            }
                        }
                    }
                    catch (Id3TagException) { /* Do nothing */}
                }
            }

            return imageData;
        }
Exemplo n.º 53
0
 public PlaylistItem(int index, IWMPMedia item)
     : base(item)
 {
     number = Convert.ToString(index + 1);
 }
Exemplo n.º 54
0
 public void removeItem(IWMPMedia pIWMPMedia)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 55
0
 public void addSong(IWMPMedia item)
 {
     songs.Add(new Song(item));
 }
Exemplo n.º 56
0
        void request()
        {
            string uriString =
                       string.Format("https://api.vk.com/method/{0}?oid={1}&access_token={2}",
                      "audio.get", MY_ID, ACCESS_TOKEN);
            WebRequest _webRequest = WebRequest.Create(uriString);
            WebResponse _webResponce = _webRequest.GetResponse();
            Stream _stream = _webResponce.GetResponseStream();
            StreamReader _streamReader = new StreamReader(_stream);
            string responseFromServer = _streamReader.ReadToEnd();
            _streamReader.Close();
            _webResponce.Close();
            responseFromServer = HttpUtility.HtmlDecode(responseFromServer);
            JToken _jtoken = JToken.Parse(responseFromServer);
            AudioList = _jtoken["response"].Children().Skip(1).Select(c => c.ToObject<Audio>()).ToList();
            this.Invoke((MethodInvoker)delegate
            {
                Playlist = axWindowsMediaPlayer1.playlistCollection.newPlaylist("vkPLayList");
                for (int i = 0; i < AudioList.Count; i++)
                {
                    
                    Media = axWindowsMediaPlayer1.newMedia(AudioList[i].url);
                    Playlist.appendItem(Media);
                    listView1.Items.Add(AudioList[i].artist + " " + AudioList[i].title);
                }
                axWindowsMediaPlayer1.currentPlaylist = Playlist;
                axWindowsMediaPlayer1.Ctlcontrols.stop();

            });
        }
Exemplo n.º 57
0
            public void add_song_to_album(IWMPMedia media_item)
            {
                if (albumYear == "" || albumYear.Length < 4) albumYear = media_item.getItemInfo("WM/OriginalReleaseYear");
                if (albumYear == "" || albumYear.Length < 4) albumYear = media_item.getItemInfo("WM/Year");
                genre = media_item.getItemInfo("WM/Genre");
                albumGenre_add(genre);

                if (albumImage.Length == 0) findAlbumCover(media_item.sourceURL);
                albumTrackCount++;
                artistTrackCount++;
                trackCount++;

                song = media_item.getItemInfo("Title");
                songLocation = media_item.sourceURL;
                songTrackNumber = media_item.getItemInfo("WM/TrackNumber");
                songLength = media_item.durationString;
                song_artist = media_item.getItemInfo("Author");

                string s = media_item.getItemInfo("WM/AlbumTitle");
                if (album != s) nextAlbum = s;

                s = media_item.getItemInfo("WM/AlbumArtist");
                if (s == "") s = "None";
                if (artist != s) nextArtist = s;

                return;
            }
Exemplo n.º 58
0
 public void insertItem(int lIndex, IWMPMedia pIWMPMedia)
 {
     throw new NotImplementedException();
 }
Exemplo n.º 59
0
        public void ShowFileInfo(IWMPMedia media)
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine("Media-info for " + media.name);
            sb.AppendLine();
            sb.AppendLine("Attributes:");
            for (int att = 0; att < media.attributeCount; att++)
            {
                string attName = media.getAttributeName(att);
                sb.AppendFormat("{0}: {1}", att, attName);
                sb.AppendLine();
                sb.AppendFormat(" -> {0}", media.getItemInfo(attName));
                sb.AppendLine();

            }
            sb.AppendLine();
            sb.AppendLine("Other:");
            sb.AppendLine();
            sb.AppendFormat("Marker-count: {0}",media.markerCount);

            MessageBox.Show(sb.ToString());
        }
 private string GetAlbum(IWMPMedia mediaItem)
 {
     return mediaItem.getItemInfoByAtom(albumIndex);
 }