Exemplo n.º 1
0
class Player(object):
    def __init__(self, media_dir):
        self.media_dir = media_dir
        self.player = None
        self.subtitles = True

    def play(self, filename):
        if self.player:
            self.player.quit()
            self.player = None
        video_path = Path(self.media_dir + filename)
        self.player = OMXPlayer(video_path, args=['--no-osd'])

    def quit(self):
        self.player.quit()
        self.player = None

    def pause(self):
        self.player.play_pause()

    def seek(self, val):
        self.player.set_position(val)

    def set_volume(self, val):
        self.player.set_volume(val)

    def toggle_subtitles(self):
        if self.subtitles:
            self.player.hide_subtitles()
        else:
            self.player.show_subtitles()
        self.subtitles = not self.subtitles

    def set_subtitle_track(self, val):
        self.player.select_subtitle(val)

    @property
    def status(self):
        if self.player != None:
            return {
                'time': int(self.player.position()),
                'length': int(self.player.duration()),
                'volume': int(self.player.volume()),
                'subtitle_tracks': self.player.list_subtitles()
            }
        return {'time': 0, 'length': 0, 'volume': 0, 'subtitle_tracks': []}
Exemplo n.º 2
0
        else:
            clipDuration = currentChanDuration[currentChanStr] - startTimes[
                currentChanStr][currentClip[currentChanStr] - 1]

        print('current channel is now: ' + str(currentChanNum))
        print('current channel duration is: ' +
              str(currentChanDuration[currentChanStr]))
        print('current clip is now: ' + str(currentClip[currentChanStr]))
        print('current clip duration is: ' + str(clipDuration))

        buildsrt(clipDuration, currentChanNum)

        VIDEO_PATH = Path('/home/pi/python/videos/chan' + str(currentChanNum) +
                          '/' + fileList[currentClip[currentChanStr]])
        try:
            player.show_subtitles()
            player.quit()
            player = OMXPlayer(VIDEO_PATH,
                               args=[
                                   '--no-osd',
                                   '--subtitles',
                                   TITLE_PATH,
                                   '--lines',
                                   '1',
                                   '--align',
                                   'center',
                                   '--font-size',
                                   '100',
                                   '--layer',
                                   '1',
                               ],