TiVo Community Forum banner
1 - 4 of 4 Posts

· Registered
Joined
·
16 Posts
Thanks again wmcbrine for another awesome application. There was just one frustrating thing for me: the Tivo would exit to live TV if the HME stream was paused for too long, which happens a lot to me; so I added a bookmark function that saves the current position whenever I pause the stream or return to the list of files. I have attached the two files I changed for reference.
 

Attachments

· Registered
Joined
·
16 Posts
I modified the up() and down() functions in the listview module.
Code:
    def down(self, i):
        if self.pos < self.startpos + self.pagesize - 1:    #if pos != bottom of current page
            if self.pos + i > self.startpos + self.pagesize - 1:    #page down
                self.pos = self.startpos + self.pagesize - 1    #set pos to bottom of current page
            else:    #increment pos
                self.pos += i
        else:    #new page
            if self.startpos + self.pagesize + self.pagesize > len(self.items) - 1:    #if end of new page is beyond last item in list
                self.startpos = len(self.items) - self.pagesize    #set startpos to last item - pagesize
            else:    #increment startpos
                self.startpos += self.pagesize
            if self.pos + i > len(self.items) - 1:    #if newpos > last item in list
                self.pos = len(self.items) - 1    #set pos to last item in list
            else:    #increment pos
                self.pos += i
            self.redraw()
        self.pos_update()

    def up(self, i):
        if self.pos > self.startpos:
            if self.pos - i < self.startpos:    #page up
                self.pos = self.startpos
            else:
                self.pos -= i
        else:    #new page
            if self.startpos - self.pagesize < 0:
                self.startpos = 0
            else:
                self.startpos -= self.pagesize
            if self.pos - i < 0:
                self.pos = 0
            else:
                self.pos -= i
            self.redraw()
        self.pos_update()
I also broke out the bookmarking functionality in to it's own module:
Code:
import os

LENGTH = 0
BOOKMARK = 0

def save(filename, buffer, position):
    if position > 5:
        global LENGTH, BOOKMARK
        buffer = int(round(float(buffer) / 1000))
        position = int(round(float(position) / 1000))
        if LENGTH < BOOKMARK + buffer:    #previous play underran
            LENGTH = BOOKMARK + buffer
        new_bookmark = BOOKMARK + position
        try:
            filehandler = open(filename + ".bkm", 'w')
            filehandler.writelines('&#37;s\n' % LENGTH)
            filehandler.writelines('%s' % new_bookmark)
            filehandler.flush()
            filehandler.close()
        except IOError:
            print "Error saving bookmark!"

def load(filename):
    START_TIME = ''
    if os.path.exists(filename + '.bkm'):
        try:
            filehandler = open(filename + ".bkm", 'r')
            global LENGTH, BOOKMARK
            LENGTH = int(filehandler.readline())
            BOOKMARK = int(filehandler.readline())
            if BOOKMARK >= 5:
                BOOKMARK -= 5
            filehandler.flush()
            filehandler.close()
            START_TIME = '--start-time=%s' % BOOKMARK
        except IOError:
            print "Error loading bookmark!"
    return START_TIME

def erase(filename):
    try:
        if os.path.exists(filename + '.bkm'):
            os.remove(filename + '.bkm')
    except IOError:
        print "Error erasing bookmark!"
I added:
Code:
                    bookmark.save(self.stream_url, self.duration, self.position)
to the handle_resource_info() and handle_key_press() functions in the hmevlc module.

I made the following changes to the vlc module:
  1. Added ,soverlay to PARAMS so I could use subtitle files:
    Code:
    PARAMS = '#transcode{vcodec=%(VCODEC)s,vb=%(VBITRATE)d,' + \
             'acodec=%(ACODEC)s,ab=%(ABITRATE)d,audio-sync,samplerate=44100,' + \
             'fps=29.97,soverlay}:std{access=http,dst=:%(SERVER)d,mux=ps}'    #Added ",soverlay" to transcode options, to show subtitles from seperate subtitle files.
  2. Inserted the second line below, in the vlc.start function; and modified the now third line accordingly:
    Code:
        if client_count == 1:
            start_time = bookmark.load(url)    #Added by Mel Smith
            pid = subprocess.Popen([vlcpath, url, '-I', 'dummy', '-V', 'dummy', start_time, '--sout', PARAMS % globals()]).pid    # Added "start_time" parameter to VLC command line options.
 

Attachments

1 - 4 of 4 Posts
This is an older thread, you may not receive a response, and could be reviving an old thread. Please consider creating a new thread.
Top