// estimate the length of each song based on file size public void GetSongLength(PandoraUser user, PandoraSong song, WebProxy proxy) { if (!IsValid(song, proxy)) { throw new PandoraException("Attempting to get song length for an expired song."); } WebRequest request = WebRequest.Create(song.AudioURL); if (proxy != null) request.Proxy = proxy; request.Method = "HEAD"; using (WebResponse response = request.GetResponse()) { long bytes = response.ContentLength; int seconds = (int)((bytes * 8) / (int.Parse(song.AudioInfo.Bitrate) * 1000)); song.Length = new TimeSpan(0, 0, seconds); } }
internal SkipHistory(PandoraUser user) : this() { _user = user; }
public void GetSongLength(PandoraUser user, PandoraSong song) { GetSongLength(user, song, null); }