[gnome-music] New attempt on fixing the regression by adding a GLib around it
- From: Seif Lotfy <seiflotfy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-music] New attempt on fixing the regression by adding a GLib around it
- Date: Tue, 30 Apr 2013 11:36:31 +0000 (UTC)
commit f7f1c17e80058b6a15df8382408d61e846dabaa3
Author: Seif Lotfy <seif lotfy com>
Date: Tue Apr 30 13:36:05 2013 +0200
New attempt on fixing the regression by adding a GLib around it
src/player.js | 44 +++++++++++++++++++++++++++++---------------
1 files changed, 29 insertions(+), 15 deletions(-)
---
diff --git a/src/player.js b/src/player.js
index c477d08..e3647ce 100644
--- a/src/player.js
+++ b/src/player.js
@@ -95,18 +95,22 @@ const Player = new Lang.Class({
Gst.init(null, 0);
this.player = Gst.ElementFactory.make("playbin", "player");
- this.connect("about-to-finish", Lang.bind(this,
+ this.player.connect("about-to-finish", Lang.bind(this,
function() {
- if (this.timeout) {
- GLib.source_remove(this.timeout);
- }
- if (!this.playlist || !this.currentTrack || !this.playlist.iter_next(this.currentTrack))
- this.currentTrack=null;
- else {
- this.load( this.playlist.get_value( this.currentTrack, this.playlist_field));
- this.timeout = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 1000, Lang.bind(this,
this._updatePositionCallback));
+ GLib.timeout_add(GLib.PRIORITY_DEFAULT, 1000, Lang.bind(this,
+ function() {
+ if (this.timeout) {
+ GLib.source_remove(this.timeout);
+ }
+ if (!this.playlist || !this.currentTrack || !this.playlist.iter_next(this.currentTrack))
+ this.currentTrack=null;
+ else {
+ this.load( this.playlist.get_value( this.currentTrack, this.playlist_field));
+ this.timeout = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 500, Lang.bind(this,
this._updatePositionCallback));
+ }
+ return false;
}
- return false;}));
+ ))}));
this.bus = this.player.get_bus();
this.bus.add_signal_watch()
this.bus.connect("message", Lang.bind(this,
@@ -324,15 +328,25 @@ const Player = new Lang.Class({
this.progress_scale.set_draw_value(false);
this._setDuration(1);
+ this.progress_scale.connect("button-press-event", Lang.bind(this,
+ function() {
+ this.player.set_state(Gst.State.PAUSED);
+ this._updatePositionCallback();
+ GLib.source_remove(this.timeout);
+ return false;
+ }));
this.progress_scale.connect("value-changed", Lang.bind(this,
function() {
let seconds = Math.floor(this.progress_scale.get_value() / 60);
this.song_playback_time_lbl.set_label(this.seconds_to_string(seconds));
- print (seconds, this.duration)
- if (this.duration == seconds && this.player.get_state(1)[1] != Gst.State.PAUSED) {
- this.progress_scale.set_value(0.0)
- GLib.timeout_add (500, null, Lang.bind(this, function () {this.emit("about-to-finish")}))
- }
+ return false;
+ }));
+ this.progress_scale.connect("button-release-event", Lang.bind(this,
+ function() {
+ this.onProgressScaleChangeValue(this.progress_scale);
+ this.player.set_state(Gst.State.PLAYING);
+ this._updatePositionCallback();
+ this.timeout = GLib.timeout_add(GLib.PRIORITY_DEFAULT, 1000, Lang.bind(this,
this._updatePositionCallback));
return false;
}));
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]