public async Task <HttpResponseMessage> PerformerPhoto(int id) { var response = Request.CreateResponse(); var result = await _performerService.GetPerformerAsync(id); if (result.Type != ResultType.Ok) { return(null);// NotFound(); } var performer = new Performer { Name = result.Data.Name }; response.Content = new PushStreamContent((stream, content, context) => { var path = FileLocator.GetPerformerImagePath(performer); var image = new HttpFileStream(path); image.WriteToStream(stream, content, context); }, "image/jpeg"); return(response); }
public async Task <HttpResponseMessage> AlbumCover(int id) { var response = Request.CreateResponse(); var result = await _albumService.GetAlbumAsync(id, true); if (result.Type != ResultType.Ok) { return(null);// NotFound(); } var album = new Album { Id = result.Data.Id, Performer = new Performer { Name = result.Data.Performer.Name } }; response.Content = new PushStreamContent((stream, content, context) => { var path = FileLocator.GetAlbumImagePath(album); var image = new HttpFileStream(path); image.WriteToStream(stream, content, context); }, "image/jpeg"); return(response); }
public async Task <HttpResponseMessage> Stream() { var radioResponse = await client.GetAsync("radio/current"); var songModel = await radioResponse.Content.ReadAsAsync <SongModel>(); var song = new Song { Id = songModel.Id, Name = songModel.Name, TrackNo = songModel.TrackNo, Album = new Album { Name = songModel.Album, ReleaseYear = songModel.Year, Performer = new Performer { Name = songModel.Performer } }, }; var response = Request.CreateResponse(); response.Content = new PushStreamContent((a, b, c) => { var path = FileLocator.FindSongPath(song); var audio = new HttpFileStream(path); audio.WriteToStream(a, b, c); }, "audio/mpeg"); return(response); }