示例#1
0
        // WARNING: This will be called from a thread!
        protected override void LoadFromDevice()
        {
            importer = new DatabaseImportManager(this);
            importer.KeepUserJobHidden = true;
            importer.Threaded          = false; // We are already threaded
            importer.Finished         += OnImportFinished;

            foreach (string audio_folder in BaseDirectories)
            {
                importer.Enqueue(audio_folder);
            }
        }
 public void Import()
 {
     try {
         if (importer == null)
         {
             importer = new Banshee.Library.LibraryImportManager();
         }
         finished           = false;
         importer.Finished += CreatePlaylist;
         importer.Enqueue(uris);
     } catch (PlaylistImportCanceledException e) {
         Hyena.Log.Exception(e);
     }
 }
示例#3
0
        // WARNING: This will be called from a thread!
        protected override void LoadFromDevice()
        {
            import_reset_event = new System.Threading.ManualResetEvent(false);

            importer = new DatabaseImportManager(this)
            {
                KeepUserJobHidden  = true,
                SkipHiddenChildren = false
            };
            importer.Finished += OnImportFinished;

            foreach (string audio_folder in BaseDirectories)
            {
                importer.Enqueue(audio_folder);
            }

            import_reset_event.WaitOne();
        }
        public void Enqueue(string path)
        {
            try {
                SafeUri uri = new SafeUri(path);
                if (uri.IsLocalPath && !String.IsNullOrEmpty(uri.LocalPath))
                {
                    path = uri.LocalPath;
                }
            } catch {
            }

            lock (this) {
                if (importer == null)
                {
                    importer = new DatabaseImportManager(this);
                    importer.KeepUserJobHidden = true;
                    importer.ImportResult     += delegate(object o, DatabaseImportResultArgs args) {
                        Banshee.ServiceStack.Application.Invoke(delegate {
                            if (args.Error != null || path_to_play != null)
                            {
                                return;
                            }

                            path_to_play = args.Path;
                            if (args.Track == null)
                            {
                                // Play immediately if the track is already in the source,
                                // otherwise the call will be deferred until the track has
                                // been imported and loaded into the cache
                                PlayEnqueued();
                            }
                        });
                    };

                    importer.Finished += delegate {
                        if (visible)
                        {
                            Banshee.Base.ThreadAssist.ProxyToMain(delegate {
                                TrackInfo current_track = ServiceManager.PlaybackController.CurrentTrack;
                                // Don't switch to FSQ if the current item is a video
                                if (current_track == null || !current_track.HasAttribute(TrackMediaAttributes.VideoStream))
                                {
                                    ServiceManager.SourceManager.SetActiveSource(this);
                                }
                            });
                        }
                    };
                }

                if (PlaylistFileUtil.PathHasPlaylistExtension(path))
                {
                    Banshee.Kernel.Scheduler.Schedule(new DelegateJob(delegate {
                        // If it's in /tmp it probably came from Firefox - just play it
                        if (path.StartsWith(Paths.SystemTempDir))
                        {
                            Banshee.Streaming.RadioTrackInfo.OpenPlay(path);
                        }
                        else
                        {
                            PlaylistFileUtil.ImportPlaylistToLibrary(path, this, importer);
                        }
                    }));
                }
                else
                {
                    importer.Enqueue(path);
                }
            }
        }