Beispiel #1
0
def get_metadata(filename, media_file = None):
    from metadata import Metadata
    if not media_file:
        media_file = media.load(filename)

    if not is_audio_file('', media_file):
        return None

    md = media_file.file_info

    return Metadata(title=md.title, artist=md.author, 
            album=md.album, year=md.year, 
            trackno=md.track, genre=md.genre,
            duration=md.duration
            )
Beispiel #2
0
    def open(self, filename):
        song = media.load(filename)

        if not is_audio_file('', song):
            raise MediaError('File "%s" is not an audio or audio only file' % filename)

        playing = False
        if self._player and self._player.playing:
            playing = True

        self.stop()

        self._lock()
        try:
            self._player = None
        finally:
            self._unlock()

        self._filename = filename
        self._song = song
        self._metadata = get_metadata('', song)

        if playing:
            self.play()