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 GLib
35 self.player = GstPlayer.Player.new(signal_dispatcher=GstPlayer.PlayerGMainContextSignalDispatcher())
36 self.player.connect("error", self.error_cb)
37 self.player.connect("end-of-stream", self.end_of_stream_cb)
38 self.player.connect("state-changed", self.state_changed_cb)
40 self.mainloop = GLib.MainLoop()
42 def end_of_stream_cb(self, player):
45 def error_cb(self, player, error):
49 def state_changed_cb(self, player, state):
52 def play(self, filename):
53 self.player.set_uri(Gst.filename_to_uri(filename))
66 player.play(sys.argv[1])
67 except KeyboardInterrupt:
71 if __name__ == "__main__":