protected override void OnResponse(ResponseType response) { if (response == ResponseType.Ok) { string name = SourceName; StationType type = StationType.FindByLabel(type_combo.ActiveText); string arg = Arg; ThreadAssist.Spawn(delegate { if (source == null) { source = new StationSource(lastfm, name, type.Name, arg); lastfm.AddChildSource(source); //LastFMPlugin.Instance.Source.AddChildSource (source); //ServiceManager.SourceManager.AddSource (source); } else { source.Rename(name); source.Type = type; source.Arg = arg; source.Save(); //source.Refresh (); } }); } }
private void OnArtistPlayFanRadio(object sender, EventArgs args) { StationSource fan_radio = null; foreach (StationSource station in lastfm.Children) { if (station.Type == StationType.Fan && station.Arg == lastfm.Actions.CurrentArtist) { fan_radio = station; break; } } if (fan_radio == null) { fan_radio = new StationSource(lastfm, String.Format(Catalog.GetString("Fans of {0}"), lastfm.Actions.CurrentArtist), "Fan", lastfm.Actions.CurrentArtist ); lastfm.AddChildSource(fan_radio); } ServiceManager.SourceManager.SetActiveSource(fan_radio); }
public static StationSource CreateFromUrl(LastfmSource lastfm, string url) { foreach (StationType type in StationType.Types) { string regex = Regex.Escape(type.GetStationFor("XXX")).Replace("XXX", "([^\\/]+)"); Match match = Regex.Match(url, regex); if (match.Groups.Count == 2 && match.Groups[0].Captures.Count > 0) { Log.DebugFormat("Creating last.fm station from url {0}", url); string arg = match.Groups[1].Captures[0].Value; StationSource station = new StationSource(lastfm, arg, type.Name, arg); lastfm.AddChildSource(station); station.NotifyUser(); } } return(null); }
private bool ServiceStartup() { if (lastfm_source != null) { return(true); } foreach (var src in ServiceManager.SourceManager.FindSources <LastfmSource> ()) { lastfm_source = src; break; } if (lastfm_source == null) { return(false); } lastfm_source.ClearChildSources(); lastfm_source.SetChildSortTypes(station_sort_types); //lastfm_source.PauseSorting (); foreach (StationSource child in StationSource.LoadAll(lastfm_source, lastfm_source.Account.UserName)) { lastfm_source.AddChildSource(child); } //lastfm_source.ResumeSorting (); lastfm_source.SortChildSources(); lastfm_source.Properties.SetString("ActiveSourceUIResource", "ActiveSourceUI.xml"); lastfm_source.Properties.Set <bool> ("ActiveSourceUIResourcePropagate", true); lastfm_source.Properties.Set <System.Reflection.Assembly> ("ActiveSourceUIResource.Assembly", typeof(StationSource).Assembly); lastfm_source.Properties.SetString("SortChildrenActionLabel", Catalog.GetString("Sort Stations by")); actions = new LastfmStreamingActions(lastfm_source); return(true); }