Exemplo n.º 1
0
 void Player_PlayStateChange(int newState)
 {
     switch (newState)
     {
         case 1:
             // Stopped
             var mediaItems = new List<IWMPMedia>();
             for (var i = 0; i < Player.currentPlaylist.count; i++)
             {
                 var item = Player.currentPlaylist.get_Item(i);
                 mediaItems.Add(item);
             }
             foreach(var mediaItem in mediaItems)
             {
                 Player.currentPlaylist.removeItem(mediaItem);
             }
             break;
         case 2:
             // Paused
             break;
         case 3:
             // Playing
             break;
     }
 }
Exemplo n.º 2
0
        // AJAX: /Player/RemoveSong
        public ActionResult RemoveSong(string id, string path)
        {
            try
            {
                var mediaItems = new List<IWMPMedia>();
                for (var i = 0; i < Player.currentPlaylist.count; i++)
                {
                    var item = Player.currentPlaylist.get_Item(i);

                    if (string.Equals(item.sourceURL, path, StringComparison.OrdinalIgnoreCase))
                    {
                        mediaItems.Add(item);
                        break;
                    }
                }

                foreach (var mediaItem in mediaItems)
                {
                    Player.currentPlaylist.removeItem(mediaItem);
                }

                return Json(new
                {
                    sMessage = string.Format("Removed '{0}' !", path)
                }, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                return new HttpStatusCodeResult(500, string.Format("{0}: {1}", ex.Message, ex.InnerException));
            }
        }
Exemplo n.º 3
0
        void Player_CurrentItemChange(object pdispMedia)
        {
            var mediaItems = new List<IWMPMedia>();
            for (var i = 0; i < Player.currentPlaylist.count; i++)
            {
                var item = Player.currentPlaylist.get_Item(i);

                if (string.Equals(item.sourceURL, Player.currentMedia.sourceURL, StringComparison.OrdinalIgnoreCase))
                    break;

                mediaItems.Add(item);
            }

            foreach (var mediaItem in mediaItems)
            {
                Player.currentPlaylist.removeItem(mediaItem);
            }
        }
Exemplo n.º 4
0
        // AJAX: /Player/GetPlaylist
        public ActionResult GetPlaylist()
        {
            try
            {
                var tracks = new List<TrackModel>();

                for (var i = 0; i < Player.currentPlaylist.count; i++)
                {
                    var item = Player.currentPlaylist.get_Item(i);

                    short trackNumber = 1;
                    short.TryParse(item.getItemInfo("WM/TrackNumber"), out trackNumber);

                    short year = 2000;
                    short.TryParse(item.getItemInfo("WM/Year"), out year);

                    var track = new TrackModel()
                    {
                        Id = Guid.Empty,
                        Name = item.name,
                        Path = item.sourceURL,
                        Artist = item.getItemInfo("Author"),
                        Album = item.getItemInfo("WM/AlbumTitle"),
                        Number = trackNumber,
                        DurationString = item.durationString,
                        Year = year
                    };
                    tracks.Add(track);
                }

                return Json(new
                {
                    aaTracks = GetTrackJson(tracks)
                }, JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                return new HttpStatusCodeResult(500, string.Format("{0}: {1}", ex.Message, ex.InnerException));
            }
        }