private static MusicItem fromStatus(StatusPimpResponse status) { if (!hasTrack(status)) { return(null); } return(AudioConversions.PimpTrackToMusicItem(status.track, null, null, null, null)); }
public async Task <IEnumerable <MusicItem> > Search(string term) { var jsonResponse = await ToJson <IEnumerable <PimpTrack> >("/search?term=" + term + "&limit=100"); return(jsonResponse .Select(item => AudioConversions.PimpTrackToMusicItem(item, PlaybackUriFor(item.id), Username, Password, IsCloud ? CloudServerID : null)) .ToList()); }
public override async Task LoadData() { var status = await session.StatusCall(); var items = status.playlist.Select(item => AudioConversions.PimpTrackToMusicItem(item, null, session.Username, session.Password, session.IsCloud ? session.CloudServerID : null)).ToList(); Sync(items, status.index); }
public override async Task SetPlaylist(MusicItem song) { // TODO remove await SubmitDownload(song); var newPlaylist = new PlaylistInfo(AudioConversions.ToPlaylistTrack(song)); await SavePlaylist(newPlaylist); }
public override async Task AddSong(MusicItem song) { // TODO remove await SubmitDownload(song); var info = await LoadPlaylist(); info.Tracks.Add(AudioConversions.ToPlaylistTrack(song)); await SavePlaylist(info); }
public override async Task LoadData() { // might return null but I don't know why var playlistInfo = await LoadPlaylist(); if (playlistInfo != null) { var tracks = playlistInfo.Tracks; List <MusicItem> items = playlistInfo.Tracks .Select(i => AudioConversions.playTrack2musicItem(i, null, null)) .ToList(); Sync(items, playlistInfo.CurrentIndex); } }
/// <summary> /// maps a json response to a list of music items /// </summary> /// <param name="response">the fetched data</param> private List <MusicItem> Itemize(FoldersPimpResponse response) { var ret = new List <MusicItem>(); foreach (var folder in response.folders) { ret.Add(AudioConversions.FolderToMusicItem(folder)); } foreach (var track in response.tracks) { ret.Add(AudioConversions.PimpTrackToMusicItem(track)); } return(ret); }
public static PlaybackStatus ToPlaybackStatus(StatusPimpResponse status) { var playlist = status.playlist .Select(track => AudioConversions.PimpTrackToMusicItem(track, null, null, null, null)) .ToList(); return(new PlaybackStatus( fromStatus(status), position(status), status.index, playlist, volume(status), playerState(status), status.mute)); }
private AlarmModel ToModel(MusicAlarm json) { var when = json.when; var time = new DateTime(2013, 1, 1, when.hour, when.minute, 0); var days = when.days.Select(DayName).ToList(); return(new AlarmModel(this) { Id = json.id, IsOn = json.enabled, Time = time, EnabledDays = new ObservableCollection <object>(days), Track = AudioConversions.PimpTrackToMusicItem(json.job.track, null, Session.Username, Session.Password, Session.IsCloud ? Session.CloudServerID : null) }); }
/// <summary> /// maps a json response to a list of music items /// </summary> /// <param name="response">the fetched data</param> private List <MusicItem> Itemize(FoldersPimpResponse response) { var ret = new List <MusicItem>(); foreach (var folder in response.folders) { ret.Add(AudioConversions.FolderToMusicItem(folder)); } foreach (var track in response.tracks) { var uri = session.PlaybackUriFor(track.id); ret.Add(TrackToMusicItem(track, uri)); } return(ret); }
public override async Task SetPlaylist(MusicItem song) { await TrySubmitDownload(song); PlaylistDatabase.SetPlaylist(AudioConversions.ToPlaylistTrack(song)); }
private MusicItem ToItem(PimpTrack track) { return(AudioConversions.PimpTrackToMusicItem(track, null, null, null, null)); }
public Task <IEnumerable <MusicItem> > Search(string term) { return(MapList <MusicItem, PimpTrack>(searchResource + "?term=" + term, item => AudioConversions.PimpTrackToMusicItem(item, null, Session.Username, Session.Password, Session.IsCloud ? Session.CloudServerID : null))); }
public Task <IEnumerable <MusicItem> > Tracks() { return(MapList <MusicItem, PimpTrack>(tracksResource, item => AudioConversions.PimpTrackToMusicItem(item, null, Session.Username, Session.Password, Session.IsCloud ? Session.CloudServerID : null))); }
public MusicItem TrackToMusicItem(PimpTrack track, Uri uri) { return(AudioConversions.PimpTrackToMusicItem(track, uri, session.Username, session.Password, session.IsCloud ? session.CloudServerID : null)); }