mirror of
https://github.com/oleid/gnome-shell-teatime.git
synced 2022-04-29 18:53:50 +00:00
fix playback issue (#20)
This commit is contained in:
parent
5153e81064
commit
73f394bc2a
22
src/utils.js
22
src/utils.js
@ -84,10 +84,24 @@ function formatTime(sec_num) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function playSound(uri) {
|
function playSound(uri) {
|
||||||
Gst.init(null, 0);
|
if ( typeof this.player == 'undefined' ) {
|
||||||
let player = Gst.ElementFactory.make("playbin","player");
|
Gst.init(null, 0);
|
||||||
player.set_property('uri', uri);
|
this.player = Gst.ElementFactory.make("playbin","player");
|
||||||
player.set_state(Gst.State.PLAYING);
|
this.playBus = this.player.get_bus();
|
||||||
|
this.playBus.add_signal_watch();
|
||||||
|
this.playBus.connect("message", Lang.bind(this,
|
||||||
|
function(playBus, message) {
|
||||||
|
if (message != null) {
|
||||||
|
// IMPORTANT: to reuse the player, set state to READY
|
||||||
|
let t = message.type;
|
||||||
|
if ( t == Gst.MessageType.EOS || t == Gst.MessageType.ERROR) {
|
||||||
|
this.player.set_state(Gst.State.READY);
|
||||||
|
}
|
||||||
|
} // message handler
|
||||||
|
}));
|
||||||
|
} // if undefined
|
||||||
|
this.player.set_property('uri', uri);
|
||||||
|
this.player.set_state(Gst.State.PLAYING);
|
||||||
}
|
}
|
||||||
|
|
||||||
function setCairoColorFromClutter(cr, c) {
|
function setCairoColorFromClutter(cr, c) {
|
||||||
|
Loading…
Reference in New Issue
Block a user