1 # -*- coding: utf-8 -*-
3 # gPodder - A media aggregator and podcast client
4 # Copyright (c) 2005-2010 Thomas Perl and the gPodder Team
6 # gPodder is free software; you can redistribute it and/or modify
7 # it under the terms of the GNU General Public License as published by
8 # the Free Software Foundation; either version 3 of the License, or
9 # (at your option) any later version.
11 # gPodder is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU General Public License for more details.
16 # You should have received a copy of the GNU General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
25 from gst
.extend
.discoverer
import Discoverer
32 self
.mainloop
= gobject
.MainLoop()
35 def run(self
, filename
):
36 gobject
.idle_add(self
.on_idle
, filename
)
38 return self
.result
/ gst
.MSECOND
40 def on_idle(self
, filename
):
41 d
= Discoverer(filename
)
42 d
.connect('discovered', self
.on_data
)
46 def on_data(self
, discoverer
, ismedia
):
47 if discoverer
.is_video
:
48 self
.result
= discoverer
.videolength
49 elif discoverer
.is_audio
:
50 self
.result
= discoverer
.audiolength
51 gobject
.idle_add(self
.mainloop
.quit
)
53 def get_track_length(filename
):
55 Returns track length in microseconds.
57 Prefers video streams to audio streams. If no supported streams were found,
62 return GstFile().run(filename
)
64 __all__
= ['get_track_length']
66 # vim: set ts=4 sts=4 sw=4 et: