Exemple #1
0
        public bool Next(bool restart, bool changeImmediately)
        {
            /*
             * TODO: It should be technically possible to handle changeImmediately=False
             * correctly here, but the current implementation is quite hostile.
             * For the moment, just SetNextTrack (null), and go on to OpenPlay if
             * the engine isn't currently playing.
             */
            if (!changeImmediately)
            {
                ServiceManager.PlayerEngine.SetNextTrack((SafeUri)null);
                if (ServiceManager.PlayerEngine.IsPlaying())
                {
                    return(true);
                }
            }
            RadioTrackInfo radio_track = ServiceManager.PlaybackController.CurrentTrack as RadioTrackInfo;

            if (radio_track != null && radio_track.PlayNextStream())
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #2
0
        private void OnOpenLocation(object o, EventArgs args)
        {
            OpenLocationDialog dialog   = new OpenLocationDialog();
            ResponseType       response = dialog.Run();
            string             address  = dialog.Address;

            dialog.Destroy();

            if (response == ResponseType.Ok)
            {
                RadioTrackInfo.OpenPlay(address);
            }
        }
Exemple #3
0
        public bool Previous(bool restart)
        {
            RadioTrackInfo radio_track = ServiceManager.PlaybackController.CurrentTrack as RadioTrackInfo;

            if (radio_track != null && radio_track.PlayPreviousStream())
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
        /// <summary>
        /// Initializes all parameters for recording a track
        /// </summary>
        /// <param name="track_in">
        /// A <see cref="TrackInfo"/> that is to be recorded
        /// </param>
        /// <returns>
        /// A <see cref="System.Boolean"/> indicating if all parameters could successfully be initialized
        /// </returns>
        private bool InitStreamrecorderProcess(TrackInfo track_in)
        {
            if (String.IsNullOrEmpty(output_directory))
            {
                output_directory = Banshee.ServiceStack.ServiceManager.SourceManager.MusicLibrary.BaseDirectory
                                   + Path.DirectorySeparatorChar + "ripped";
                Hyena.Log.DebugFormat("[StreamrecorderService] <InitStreamrecorderProcess> output directory not set, using: {0}", output_directory);
            }

            if (!Directory.Exists(output_directory))
            {
                Hyena.Log.Debug("[StreamrecorderService] <InitStreamrecorderProcess> output directory does not exist, creating.");
                Directory.CreateDirectory(output_directory);
            }

            if (track_in == null)
            {
                return(false);
            }

            if (track_in.Uri == null || track_in.Uri.IsLocalPath)
            {
                Hyena.Log.Debug("[StreamrecorderService] <InitStreamrecorderProcess> Not recording local files");
                return(false);
            }

            DateTime       dt      = DateTime.Now;
            string         datestr = String.Format("{0:d_M_yyyy_HH_mm_ss}", dt);
            string         filename;
            RadioTrackInfo radio_track = track as RadioTrackInfo;

            //split only if Artist AND Title are present, i.e. stream sends complete metadata
            //do not set extension, will be done by recorder!
            if (is_splitting_enabled && track.ArtistName != null && track.ArtistName.Length > 0)
            {
                filename = recorder.SetMetadataFilename(track.TrackTitle, track.ArtistName);
            }
            else
            {
                filename = (radio_track.ParentTrack == null ? track.TrackTitle : radio_track.ParentTrack.TrackTitle) + "_" + datestr;
            }

            recorder.SetOutputParameters(output_directory, filename);

            RippedFileScanner.SetScanDirectory(output_directory);

            return(true);
        }
        private void PlayGenre(object sender, ButtonPressEventArgs args)
        {
            MenuTile       tile = sender as MenuTile;
            Genre          g    = genre_map[tile.PrimaryText];
            string         type = RadioSource.MembershipTypeSchema.Get();
            RadioTrackInfo rti;

            if (type != "")
            {
                string user = RadioSource.UsernameSchema.Get();
                string pass = RadioSource.PasswordSchema.Get();
                rti = new RadioTrackInfo(g.GetM3uUri(type, user, pass));
            }
            else
            {
                rti = new RadioTrackInfo(g.GetM3uUri());
            }
            Log.Debug(string.Format("Tuning Magnatune to {0}", g.GetM3uUri()), null);
            rti.Play();
        }
Exemple #6
0
        public bool Next(bool restart, bool changeImmediately)
        {
            if (!changeImmediately)
            {
                ServiceManager.PlayerEngine.SetNextTrack((SafeUri)null);
                if (ServiceManager.PlayerEngine.IsPlaying())
                {
                    return(true);
                }
            }
            RadioTrackInfo radio_track = ServiceManager.PlaybackController.CurrentTrack as RadioTrackInfo;

            if (radio_track != null && radio_track.PlayNextStream())
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #7
0
        public InternetRadioSource() : base(Catalog.GetString("Radio"), Catalog.GetString("Radio"), "internet-radio", 52)
        {
            Properties.SetString("Icon.Name", "radio");
            TypeUniqueId = "internet-radio";
            IsLocal      = false;

            AfterInitialized();

            InterfaceActionService uia_service = ServiceManager.Get <InterfaceActionService> ();

            uia_service.GlobalActions.Add(
                new ActionEntry("AddRadioStationAction", Stock.Add,
                                Catalog.GetString("Add Station"), null,
                                Catalog.GetString("Add a new Internet Radio station or playlist"),
                                OnAddStation)
                );
            uia_service.GlobalActions["AddRadioStationAction"].IsImportant = false;

            ui_id = uia_service.UIManager.AddUiFromResource("GlobalUI.xml");

            Properties.SetString("ActiveSourceUIResource", "ActiveSourceUI.xml");
            Properties.Set <bool> ("ActiveSourceUIResourcePropagate", true);
            Properties.Set <System.Reflection.Assembly> ("ActiveSourceUIResource.Assembly", typeof(InternetRadioSource).Assembly);

            Properties.SetString("GtkActionPath", "/InternetRadioContextMenu");

            Properties.Set <bool> ("Nereid.SourceContentsPropagate", true);
            Properties.Set <ISourceContents> ("Nereid.SourceContents", new LazyLoadSourceContents <InternetRadioSourceContents> ());

            Properties.Set <string> ("SearchEntryDescription", Catalog.GetString("Search your stations"));
            Properties.SetString("TrackEditorActionLabel", Catalog.GetString("Edit Station"));
            Properties.Set <InvokeHandler> ("TrackEditorActionHandler", delegate {
                var track_actions = ServiceManager.Get <InterfaceActionService> ().TrackActions;
                var tracks        = track_actions.SelectedTracks;
                if (tracks == null || tracks.Count <= 0)
                {
                    return;
                }

                foreach (var track in tracks)
                {
                    var station_track = track as DatabaseTrackInfo;
                    if (station_track != null)
                    {
                        EditStation(station_track);
                        return;
                    }
                }
            });

            Properties.SetString("TrackView.ColumnControllerXml", String.Format(@"
                <column-controller>
                  <!--<column modify-default=""IndicatorColumn"">
                    <renderer type=""Banshee.Podcasting.Gui.ColumnCellPodcastStatusIndicator"" />
                  </column>-->
                  <add-default column=""IndicatorColumn"" />
                  <add-default column=""GenreColumn"" />
                  <column modify-default=""GenreColumn"">
                    <visible>false</visible>
                  </column>
                  <add-default column=""TitleColumn"" />
                  <column modify-default=""TitleColumn"">
                    <title>{0}</title>
                    <long-title>{0}</long-title>
                  </column>
                  <add-default column=""ArtistColumn"" />
                  <column modify-default=""ArtistColumn"">
                    <title>{1}</title>
                    <long-title>{1}</long-title>
                  </column>
                  <add-default column=""CommentColumn"" />
                  <column modify-default=""CommentColumn"">
                    <title>{2}</title>
                    <long-title>{2}</long-title>
                  </column>
                  <add-default column=""RatingColumn"" />
                  <add-default column=""PlayCountColumn"" />
                  <add-default column=""LastPlayedColumn"" />
                  <add-default column=""LastSkippedColumn"" />
                  <add-default column=""DateAddedColumn"" />
                  <add-default column=""UriColumn"" />
                  <sort-column direction=""asc"">genre</sort-column>
                </column-controller>",
                                                                                Catalog.GetString("Station"),
                                                                                Catalog.GetString("Creator"),
                                                                                Catalog.GetString("Description")
                                                                                ));

            ServiceManager.PlayerEngine.TrackIntercept += OnPlayerEngineTrackIntercept;
            //ServiceManager.PlayerEngine.ConnectEvent (OnTrackInfoUpdated, Banshee.MediaEngine.PlayerEvent.TrackInfoUpdated);

            TrackEqualHandler = delegate(DatabaseTrackInfo a, TrackInfo b) {
                RadioTrackInfo radio_track = b as RadioTrackInfo;
                return(radio_track != null && DatabaseTrackInfo.TrackEqual(
                           radio_track.ParentTrack as DatabaseTrackInfo, a));
            };

            var migrator = new XspfMigrator(this);

            if (migrator.Migrate() | migrator.LoadDefaults())
            {
                Reload();
            }
        }
Exemple #8
0
        public SoundCloudSource() : base(Catalog.GetString("SoundCloud"),
                                         Catalog.GetString("SoundCloud"), "soundcloud", 52)
        {
            Properties.SetString("Icon.Name", "soundcloud");
            TypeUniqueId = "soundcloud";
            IsLocal      = false;

            AfterInitialized();

            // Have OnAddArtist() respond to an 'Add' being performed in the GTK window.
            InterfaceActionService uia_service = ServiceManager.Get <InterfaceActionService>();

            uia_service.GlobalActions.Add(
                new ActionEntry("AddSoundCloudArtistAction", Stock.Add,
                                Catalog.GetString("Add SoundCloud Artist"), null,
                                Catalog.GetString("Add a SoundCloud artist or playlist"),
                                OnAddArtist)
                );
            uia_service.GlobalActions["AddSoundCloudArtistAction"].IsImportant = false;

            ui_id = uia_service.UIManager.AddUiFromResource("GlobalUI.xml");

            Properties.SetString("ActiveSourceUIResource", "ActiveSourceUI.xml");
            Properties.Set <bool>("ActiveSourceUIResourcePropagate", true);
            Properties.Set <System.Reflection.Assembly>("ActiveSourceUIResource.Assembly",
                                                        typeof(SoundCloudSource).Assembly);

            Properties.SetString("GtkActionPath", "/SoundCloudContextMenu");
            Properties.Set <bool>("Nereid.SourceContentsPropagate", false);

            Properties.Set <ISourceContents>("Nereid.SourceContents",
                                             new LazyLoadSourceContents <SoundCloudSourceContents>());

            Properties.Set <string>("SearchEntryDescription", Catalog.GetString("Search your SoundCloud artists"));

            Properties.SetString("TrackView.ColumnControllerXml", String.Format(@"
                <column-controller>
                  <!--<column modify-default=""IndicatorColumn"">
                    <renderer type=""Banshee.Podcasting.Gui.ColumnCellPodcastStatusIndicator"" />
                  </column>-->
                  <add-default column=""IndicatorColumn"" />
                  <add-default column=""GenreColumn"" />
                  <column modify-default=""GenreColumn"">
                    <visible>false</visible>
                  </column>
                  <add-default column=""TitleColumn"" />
                  <column modify-default=""TitleColumn"">
                    <title>{0}</title>
                    <long-title>{0}</long-title>
                  </column>
                  <add-default column=""ArtistColumn"" />
                  <column modify-default=""ArtistColumn"">
                    <title>{1}</title>
                    <long-title>{1}</long-title>
                  </column>
				  <add-default column=""CommentColumn"" />
                  <column modify-default=""CommentColumn"">
                    <title>{2}</title>
                    <long-title>{2}</long-title>
                  </column>
				  <add-default column=""YearColumn"" />
                  <column modify-default=""YearColumn"">
                    <title>{3}</title>
                    <long-title>{3}</long-title>
                  </column>
                  <add-default column=""RatingColumn"" />
                  <add-default column=""PlayCountColumn"" />
                  <add-default column=""LastPlayedColumn"" />
                  <add-default column=""LastSkippedColumn"" />
                  <add-default column=""DateAddedColumn"" />
                  <add-default column=""UriColumn"" />
                  <sort-column direction=""asc"">artist</sort-column>
                </column-controller>",
                                                                                Catalog.GetString("Track"),
                                                                                Catalog.GetString("Artist"),
                                                                                Catalog.GetString("Description"),
                                                                                Catalog.GetString("Year")
                                                                                ));

            ServiceManager.PlayerEngine.TrackIntercept += OnPlayerEngineTrackIntercept;

            TrackEqualHandler = delegate(DatabaseTrackInfo a, TrackInfo b) {
                RadioTrackInfo r = b as RadioTrackInfo;
                return(r != null && DatabaseTrackInfo.TrackEqual(
                           r.ParentTrack as DatabaseTrackInfo, a));
            };

            /**
             * TODO:
             *      Figure out how to tell Banshee where to find the track artwork. See below.
             *
             * TrackArtworkIdHandler = delegate(DatabaseTrackInfo a) {
             *      return;
             * };
             */
            SC.log("Initialized");
        }
        /// <summary>
        /// Constructor -- creates a new temporary LiveRadio Plugin source and sets itself as the plugin's source
        /// Any tracks that have remained in the source from a previous (interrupted) session are purged
        /// </summary>
        /// <param name="plugin">
        /// A <see cref="ILiveRadioPlugin"/> -- the plugin the source is created for
        /// </param>
        public LiveRadioPluginSource(ILiveRadioPlugin plugin) :
            base(AddinManager.CurrentLocalizer.GetString("LiveRadioPlugin") + plugin.Name,
                 plugin.Name,
                 "live-radio-plugin-" + plugin.Name.ToLower(),
                 sort_order)
        {
            TypeUniqueId = "live-radio-" + plugin.Name;
            IsLocal      = false;

            Gdk.Pixbuf icon = new Gdk.Pixbuf(System.Reflection.Assembly.GetExecutingAssembly()
                                             .GetManifestResourceStream("LiveRadioIcon.svg"));
            SetIcon(icon);

            plugin.SetLiveRadioPluginSource(this);
            this.plugin = plugin;

            AfterInitialized();

            Properties.Set <bool> ("Nereid.SourceContentsPropagate", true);

            Properties.SetString("TrackView.ColumnControllerXml", String.Format(@"
                <column-controller>
                  <!--<column modify-default=""IndicatorColumn"">
                    <renderer type=""Banshee.Podcasting.Gui.ColumnCellPodcastStatusIndicator"" />
                  </column>-->
                  <add-default column=""IndicatorColumn"" />
                  <add-default column=""GenreColumn"" />
                  <column modify-default=""GenreColumn"">
                    <visible>false</visible>
                  </column>
                  <add-default column=""TitleColumn"" />
                  <column modify-default=""TitleColumn"">
                    <title>{0}</title>
                    <long-title>{0}</long-title>
                  </column>
                  <add-default column=""ArtistColumn"" />
                  <column modify-default=""ArtistColumn"">
                    <title>{1}</title>
                    <long-title>{1}</long-title>
                  </column>
                  <add-default column=""CommentColumn"" />
                  <column modify-default=""CommentColumn"">
                    <title>{2}</title>
                    <long-title>{2}</long-title>
                  </column>
                  <add-default column=""RatingColumn"" />
                  <add-default column=""PlayCountColumn"" />
                  <add-default column=""LastPlayedColumn"" />
                  <add-default column=""LastSkippedColumn"" />
                  <add-default column=""DateAddedColumn"" />
                  <add-default column=""UriColumn"" />
                  <sort-column direction=""asc"">genre</sort-column>
                </column-controller>",
                                                                                AddinManager.CurrentLocalizer.GetString("Station"),
                                                                                AddinManager.CurrentLocalizer.GetString("Creator"),
                                                                                AddinManager.CurrentLocalizer.GetString("Description")
                                                                                ));

            ServiceManager.PlayerEngine.TrackIntercept += OnPlayerEngineTrackIntercept;

            TrackEqualHandler = delegate(DatabaseTrackInfo a, TrackInfo b) {
                RadioTrackInfo radio_track = b as RadioTrackInfo;
                return(radio_track != null && DatabaseTrackInfo.TrackEqual(radio_track.ParentTrack as DatabaseTrackInfo, a));
            };

            source_contents = new LiveRadioPluginSourceContents(plugin);
            source_contents.SetSource(this);

            Properties.Set <ISourceContents> ("Nereid.SourceContents", source_contents);

            this.PurgeTracks();
        }