allow play to be pressed if stopped but playlist not empty
This commit is contained in:
parent
a82b5b0475
commit
f240424774
3 changed files with 17 additions and 7 deletions
|
@ -237,7 +237,12 @@ public class Playbin : GLib.Object {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void play () {
|
public void play () {
|
||||||
assert (this.state != PlaybinState.STOPPED);
|
if (this.state == PlaybinState.STOPPED) {
|
||||||
|
// allow only when playlist is not empty
|
||||||
|
// and start from the top
|
||||||
|
assert (this._play_queue.get_n_items () > 0);
|
||||||
|
this.select_track (0);
|
||||||
|
} else {
|
||||||
this.state = PlaybinState.PLAYING;
|
this.state = PlaybinState.PLAYING;
|
||||||
debug ("setting state to playing");
|
debug ("setting state to playing");
|
||||||
var ret = this.mpv.set_property_flag("pause", false);
|
var ret = this.mpv.set_property_flag("pause", false);
|
||||||
|
@ -245,6 +250,7 @@ public class Playbin : GLib.Object {
|
||||||
debug (@"failed to set state to playing ($(ret)): $(ret.to_string())");
|
debug (@"failed to set state to playing ($(ret)): $(ret.to_string())");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void go_to_next_track ()
|
public void go_to_next_track ()
|
||||||
requires (this.state != PlaybinState.STOPPED)
|
requires (this.state != PlaybinState.STOPPED)
|
||||||
|
|
|
@ -119,7 +119,7 @@ template $UiPlaybar: Box {
|
||||||
Button {
|
Button {
|
||||||
icon-name: bind $play_pause_icon_name (template.playbin as <$Playbin>.state as <$PlaybinState>) as <string>;
|
icon-name: bind $play_pause_icon_name (template.playbin as <$Playbin>.state as <$PlaybinState>) as <string>;
|
||||||
valign: center;
|
valign: center;
|
||||||
sensitive: bind $playbin_active (template.playbin as <$Playbin>.state as <$PlaybinState>) as <bool>;
|
sensitive: bind $can_press_play (template.playbin as <$Playbin>.state as <$PlaybinState>, template.playbin as <$Playbin>.play_queue_position) as <bool>;
|
||||||
|
|
||||||
clicked => $on_play_pause_clicked ();
|
clicked => $on_play_pause_clicked ();
|
||||||
}
|
}
|
||||||
|
|
|
@ -41,6 +41,10 @@ class Ui.Playbar : Gtk.Box {
|
||||||
return state != PlaybinState.STOPPED;
|
return state != PlaybinState.STOPPED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[GtkCallback] private bool can_press_play (PlaybinState state, uint n_items) {
|
||||||
|
return state != PlaybinState.STOPPED || n_items > 0;
|
||||||
|
}
|
||||||
|
|
||||||
[GtkCallback] private string mute_button_icon_name (bool mute) {
|
[GtkCallback] private string mute_button_icon_name (bool mute) {
|
||||||
return mute ? "audio-volume-muted" : "audio-volume-high";
|
return mute ? "audio-volume-muted" : "audio-volume-high";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue