3 # Player - a very simple media player based on GstPlayer
5 # Copyright (C) 2016 Antonio Ospite <ao2@ao2.it>
7 # This program is free software: you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation, either version 3 of the License, or
10 # (at your option) any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
23 gi.require_version('Gst', '1.0')
24 from gi.repository import Gst
27 gi.require_version('GstPlayer', '1.0')
28 from gi.repository import GstPlayer
30 from gi.repository import GObject
31 GObject.threads_init()
36 self.player = GstPlayer.Player.new(signal_dispatcher=GstPlayer.PlayerGMainContextSignalDispatcher())
37 self.player.connect("error", self.error_cb)
38 self.player.connect("end-of-stream", self.end_of_stream_cb)
39 self.player.connect("state-changed", self.state_changed_cb)
41 self.mainloop = GObject.MainLoop()
43 def end_of_stream_cb(self, player):
46 def error_cb(self, player, error):
50 def state_changed_cb(self, player, state):
53 def play(self, filename):
54 self.player.set_uri(Gst.filename_to_uri(filename))
67 player.play(sys.argv[1])
68 except KeyboardInterrupt:
72 if __name__ == "__main__":