Beispiel #1
0
 public TrackInfo GetRandom(DateTime notPlayedSince, PlaybackShuffleMode mode, bool repeat, bool resetSinceTime, Shuffler shuffler)
 {
     lock (this) {
         shuffler.SetModelAndCache(this, cache);
         return(shuffler.GetRandom(notPlayedSince, mode, repeat, resetSinceTime));
     }
 }
        public HeaderWidget CreateHeaderWidget()
        {
            var header_widget = new HeaderWidget(populate_mode, populate_from_name);

            header_widget.ModeChanged += delegate(object sender, ModeChangedEventArgs e) {
                populate_mode = e.Value;
                PopulateModeSchema.Set((int)e.Value);
                UpdatePlayQueue();
                OnUpdated();
            };

            header_widget.SourceChanged += delegate(object sender, SourceChangedEventArgs e) {
                populate_from = e.Value;
                if (populate_from == null)
                {
                    populate_from_name = String.Empty;
                    PopulateFromSchema.Set(String.Empty);
                    return;
                }

                populate_from_name = e.Value.Name;
                PopulateFromSchema.Set(e.Value.Name);
                source_set_at = DateTime.Now;
                populate_from.Reload();
                Refresh();
            };

            return(header_widget);
        }
Beispiel #3
0
        public TrackInfo GetRandom(DateTime notPlayedSince, PlaybackShuffleMode mode, bool repeat, bool resetSinceTime)
        {
            lock (this) {
                if (this == Playback)
                {
                    if (model.Count == 0)
                    {
                        return(null);
                    }
                }
                else
                {
                    if (model.UnfilteredCount == 0)
                    {
                        return(null);
                    }
                }

                if (random_began_at < notPlayedSince)
                {
                    random_began_at = last_random = notPlayedSince;
                }

                TrackInfo track = GetRandomTrack(mode, repeat, resetSinceTime);
                if (track == null && (repeat || mode != PlaybackShuffleMode.Linear))
                {
                    random_began_at = (random_began_at == last_random) ? DateTime.Now : last_random;
                    track           = GetRandomTrack(mode, repeat, true);
                }

                last_random = DateTime.Now;
                return(track);
            }
        }
Beispiel #4
0
        private TrackInfo GetRandomTrack(PlaybackShuffleMode mode, bool repeat, bool resetSinceTime)
        {
            foreach (var r in randoms)
            {
                if (resetSinceTime || r.Mode != mode)
                {
                    r.Reset();
                }
            }

            var random = randoms.First(r => r.Mode == mode);

            if (random != null)
            {
                if (!random.IsReady)
                {
                    if (!random.Next(random_began_at) && repeat)
                    {
                        random_began_at = last_random;
                        random.Next(random_began_at);
                    }
                }

                if (random.IsReady)
                {
                    return(random.GetTrack(random_began_at));
                }
            }

            return(null);
        }
        private TrackInfo QueryTrackRandom(PlaybackShuffleMode mode, bool restart)
        {
            var       track_shuffler = Source.TrackModel as Banshee.Collection.Database.DatabaseTrackListModel;
            TrackInfo track          = track_shuffler == null
                ? Source.TrackModel.GetRandom(source_set_at)
                : track_shuffler.GetRandom(source_set_at, mode, restart, last_was_skipped, Banshee.Collection.Database.Shuffler.Playback);

            // Reset to default of true, only ever set to false by EosTransition
            last_was_skipped = true;
            return(track);
        }
Beispiel #6
0
        public HeaderWidget(PlaybackShuffleMode mode, string source_name) : base()
        {
            this.Spacing = 6;

            var fill_label = new Label(Catalog.GetString("_Fill"));
            var mode_combo = new ComboBox(modes.Keys.OrderBy(s => modes[s]).ToArray());

            fill_label.MnemonicWidget = mode_combo;
            mode_combo.Changed       += delegate {
                var value = modes[mode_combo.ActiveText];
                foreach (var widget in sensitive_widgets)
                {
                    widget.Sensitive = value != PlaybackShuffleMode.Linear;
                }
                var handler = ModeChanged;
                if (handler != null)
                {
                    handler(this, new ModeChangedEventArgs(value));
                }
            };

            var from_label = new Label(Catalog.GetString("f_rom"));

            sensitive_widgets.Add(from_label);
            var source_combo_box = new QueueableSourceComboBox(source_name);

            from_label.MnemonicWidget = source_combo_box;
            sensitive_widgets.Add(source_combo_box);
            source_combo_box.Changed += delegate {
                var handler = SourceChanged;
                if (handler != null)
                {
                    handler(this, new SourceChangedEventArgs(source_combo_box.Source));
                }
            };

            PackStart(fill_label, false, false, 0);
            PackStart(mode_combo, false, false, 0);
            PackStart(from_label, false, false, 0);
            PackStart(source_combo_box, false, false, 0);

            // Select the population mode.
            mode_combo.Model.Foreach(delegate(TreeModel model, TreePath path, TreeIter iter) {
                if (modes[(string)model.GetValue(iter, 0)] == mode)
                {
                    mode_combo.SetActiveIter(iter);
                    return(true);
                }
                return(false);
            });
        }
Beispiel #7
0
 public ModeChangedEventArgs(PlaybackShuffleMode value)
 {
     this.value = value;
 }
Beispiel #8
0
 public ShuffleModeChangedEventArgs(PlaybackShuffleMode shuffle_mode)
 {
     this.shuffle_mode = shuffle_mode;
 }
Beispiel #9
0
 public RandomBySlot(PlaybackShuffleMode mode, Shuffler shuffler) : base(mode, shuffler)
 {
 }
Beispiel #10
0
 public RandomBy(PlaybackShuffleMode mode, Shuffler shuffler)
 {
     Shuffler       = shuffler;
     Mode           = mode;
     insert_shuffle = new HyenaSqliteCommand("INSERT OR REPLACE INTO CoreShuffles (ShufflerID, TrackID, LastShuffledAt) VALUES (?, ?, ?)");
 }