Exemple #1
0
        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 ();
                    }
                });
            }
        }
            public int Compare(Source sa, Source sb)
            {
                StationSource a = sa as StationSource;
                StationSource b = sb as StationSource;

                return(a.PlayCount.CompareTo(b.PlayCount));
            }
Exemple #3
0
 public StationEditor(LastfmSource lastfm, StationSource source)
 {
     this.lastfm = lastfm;
     this.source = source;
     Initialize ();
     Title = Catalog.GetString ("Edit Station");
     Arg = source.Arg;
 }
Exemple #4
0
 public StationEditor(LastfmSource lastfm, StationSource source)
 {
     this.lastfm = lastfm;
     this.source = source;
     Initialize();
     Title = Catalog.GetString("Edit Station");
     Arg   = source.Arg;
 }
Exemple #5
0
        private void OnRefreshSource(object o, EventArgs args)
        {
            StationSource source = Actions.SourceActions.ActionSource as StationSource;

            if (source != null)
            {
                source.Refresh();
            }
        }
        private void OnCommandLineArgument(string uri, object value, bool isFile)
        {
            if (!isFile || String.IsNullOrEmpty(uri))
            {
                return;
            }

            // Handle lastfm:// URIs
            if (uri.StartsWith("lastfm://"))
            {
                StationSource.CreateFromUrl(lastfm_source, uri);
            }
        }
Exemple #7
0
 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;
 }
Exemple #8
0
        public LastfmTrackInfo(Track track, StationSource station, string trackauth)
        {
            this.station   = station;
            this.trackauth = trackauth;
            Uri            = new SafeUri(track.Locations[0]);
            ArtistName     = track.Creator;
            TrackTitle     = track.Title;
            AlbumTitle     = track.Album;
            Duration       = track.Duration;
            TrackNumber    = (int)track.TrackNumber;
            XspfTrack      = track;

            MediaAttributes = TrackMediaAttributes.AudioStream | TrackMediaAttributes.Music;

            CanSaveToDatabase = false;
        }
        public LastfmTrackInfo(Track track, StationSource station, string trackauth)
        {
            this.station = station;
            this.trackauth = trackauth;
            Uri = new SafeUri (track.Locations[0]);
            ArtistName = track.Creator;
            TrackTitle = track.Title;
            AlbumTitle = track.Album;
            Duration = track.Duration;
            TrackNumber = (int) track.TrackNumber;
            XspfTrack = track;

            MediaAttributes = TrackMediaAttributes.AudioStream | TrackMediaAttributes.Music;

            CanSaveToDatabase = false;
        }
 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);
 }
Exemple #11
0
        private void OnArtistPlaySimilarRadio(object sender, EventArgs args)
        {
            StationSource similar_radio = null;

            foreach (StationSource station in lastfm.Children)
            {
                if (station.Type == StationType.Similar && station.Arg == lastfm.Actions.CurrentArtist)
                {
                    similar_radio = station;
                    break;
                }
            }

            if (similar_radio == null)
            {
                similar_radio = new StationSource(lastfm,
                                                  String.Format(Catalog.GetString("Similar to {0}"), lastfm.Actions.CurrentArtist),
                                                  "Similar", lastfm.Actions.CurrentArtist
                                                  );
                lastfm.AddChildSource(similar_radio);
            }

            ServiceManager.SourceManager.SetActiveSource(similar_radio);
        }
        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);
        }
        private void OnArtistPlaySimilarRadio (object sender, EventArgs args)
        {
            StationSource similar_radio = null;
            foreach (StationSource station in lastfm.Children) {
                if (station.Type == StationType.Similar && station.Arg == lastfm.Actions.CurrentArtist) {
                    similar_radio = station;
                    break;
                }
            }

            if (similar_radio == null) {
                similar_radio = new StationSource (lastfm,
                    String.Format (Catalog.GetString ("Similar to {0}"), lastfm.Actions.CurrentArtist),
                    "Similar", lastfm.Actions.CurrentArtist
                );
                lastfm.AddChildSource (similar_radio);
            }

            ServiceManager.SourceManager.SetActiveSource (similar_radio);
        }
Exemple #14
0
        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 ();
                    }
                });
            }
        }