public SongItem(Song song) { InitializeComponent(); track.Text = song.Track.ToString(); songName.Text = song.Title; duration.Text = string.Format("{0}:{1}", TimeSpan.FromSeconds((double)song.Duration).Minutes,TimeSpan.FromSeconds((double)song.Duration).Seconds.ToString("00")); }
internal Mp3Player(Song song) { CurrentSong = song; _memoryStream = new MemoryStream(); using (Stream stream = SubsonicRequest.GetSongStream(CurrentSong/*, format:"mp3"*/)) { byte[] buffer = new byte[32768]; int read; while ((read = stream.Read(buffer, 0, buffer.Length)) > 0) { _memoryStream.Write(buffer, 0, read); } } _memoryStream.Position = 0; _waveStream = new Mp3FileReader(_memoryStream); _waveOut = new WaveOut(WaveCallbackInfo.FunctionCallback()); _waveOut.Init(_waveStream); }
void PlayerCurrentItemChanged(object pdispMedia) { CurrentSong = player.CurrentSong; SetCurrentSongInfo(); timer.Start(); }
public SongPlayer(Song song) { StartPlayer(new List<Song>{ song }); }
public SongPlayer(Song song) { CurrentSong = song; player.URL = song.Url; player.Error += PlaybackError; }
internal static string GetSongUrl(Song song) { var parameters = new Dictionary<string, string> {{"id", song.ID}}; return BuildRequestUrl(RequestType.stream, parameters); }
/// <summary> /// Gets the stream for the specified song /// </summary> /// <param name="id">A string which uniquely identifies the file to stream. Obtained by calls to getMusicDirectory.</param> /// <param name="song"></param> /// <param name="maxBitRate">If specified, the server will attempt to limit the bitrate to this value, in kilobits per second. If set to zero, no limit is imposed. Legal values are: 0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256 and 320.</param> /// <exception cref="WebException">Thrown when the user is not logged in. This should be caught by the UI thread.</exception> /// <returns>MP3 Stream</returns> public static Stream GetSongStream(Song song, int maxBitRate = 0/*, string format = null*/) { if (!Connected) throw new InvalidCredentialException(NOT_CONNECTED_MESSAGE); if (!SupportedBitRate(maxBitRate)) throw new ArgumentOutOfRangeException( String.Format("This bitrate is not allowed. Allowed bitrates are {0}", String.Join(", ", AllowedBitrates))); var parameters = new Dictionary<string, string> { {"id", song.ID}, {"maxBitRate", maxBitRate.ToString()} }; /*if (!String.IsNullOrEmpty(format)) parameters.Add("format", format);*/ string requestURL = BuildRequestUrl(RequestType.stream, parameters); WebRequest request = WebRequest.Create(requestURL); WebResponse response = request.GetResponse(); Stream dataStream = response.GetResponseStream(); return dataStream; }