Henri Valeins wrote:
> Hi,
>
> I've modified bookmarker.py and xine.py for freevo work with xine and
> bookmark.
> You need to have in you localconf.py :
>
> VIDEO_PREFERED_PLAYER = 'xine'
>
> I have tested only in file mode not on DVD mode
>
> The patchs are below :
>
> patch for bookmarker.py :
>
> -- bookmarker.py.orig    2007-05-03 17:15:23.000000000 +0200
> +++ bookmarker.py.new    2007-05-04 10:46:42.079220963 +0200
> @@ -48,6 +48,7 @@
> import util
> import menu
> import rc
> +import glob
>
> from event import *
>
> @@ -58,6 +59,7 @@
>      def actions(self, item):
>          self.item = item
>          items = []
> +
>          if item['autobookmark_resume']:
>              items.append((self.resume, _('Resume playback')))
>          if item.type == 'dir' or item.type == 'playlist':
> @@ -68,22 +70,38 @@
>
>          return items
>
> -
>      def resume(self, arg=None, menuw=None):
>          """
>          resume playback
>          """
>          t    = max(0, self.item['autobookmark_resume'] - 10)
>          info = mmpython.parse(self.item.filename)
> -        if hasattr(info, 'seek') and t:
> -            arg='-sb %s' % info.seek(t)
> -        else:
> -            arg='-ss %s' % t
> -        if menuw:
> -            menuw.back_one_menu()
> -        self.item.play(menuw=menuw, arg=arg)
> -
> -
> +    #Modif
> +    if (config.VIDEO_PREFERED_PLAYER == 'xine'):
> +        self.write_playlist(t)
> +        arg = ("--playlist %s/playlist_xine_%s.tox" %
> (config.FREEVO_CACHEDIR, t))
> +    else:
> +        if hasattr(info, 'seek') and t:
> +            arg='-sb %s' % info.seek(t)
> +        else:
> +            arg='-ss %s' % t
> +        if menuw:
> +            menuw.back_one_menu()
> +    self.item.play(menuw=menuw, arg=arg)
> +
> +    def write_playlist(self,time):
> +        t = time
> +        name = '%s/playlist_xine_%s.tox' % (config.FREEVO_CACHEDIR,t)
> +        playlist = open(name,'w')
> +        playlist.write ("# toxine playlist\n")
> +        playlist.write ("entry {\n")
> +        playlist.write ("    identifier = %s;\n" % self.item.filename)
> +        playlist.write ("    mrl = %s;\n" % self.item.filename)
> +        playlist.write ("    start = %s\n" % t)
> +        playlist.write ("};\n")
> +        playlist.write ("# END\n")
> +        playlist.close()
> +
>      def bookmark_menu(self,arg=None, menuw=None):
>          """
>          Bookmark list
> @@ -106,22 +124,32 @@
>
>              if not self.item.mplayer_options:
>                  self.item.mplayer_options = ''
> -            file.mplayer_options = str(self.item.mplayer_options) +  '
> -ss %s' % time
> -            items.append(file)
> +        if (config.VIDEO_PREFERED_PLAYER == 'xine'):
> +        self.write_playlist(int(line))
> +        cmd = ' --playlist %s/playlist_xine_%s.tox' %
> (config.FREEVO_CACHEDIR,int(line))
> +        file.mplayer_options = (cmd)
> +        else:
> +        file.mplayer_options = str(self.item.mplayer_options) +  ' -ss
> %s' % time
> +        items.append(file)
>
>          if items:
>              moviemenu = menu.Menu(self.item.name, items,
> fxd_file=self.item.skin_fxd)
>              menuw.pushmenu(moviemenu)
> -        return
> +    return
>
>
>      def eventhandler(self, item, event, menuw):
>          if event in (STOP, USER_END):
> -            if item.mode == 'file' and not item.variants and \
> +        # effacer tous les fichiers repondant a la condition
> +        playlist_remove = ("%s/playlist_xine*.tox" %
> config.FREEVO_CACHEDIR)
> +        for filename in glob.glob(playlist_remove):
> +            os.remove(filename)
> +
> +        if item.mode == 'file' and not item.variants and \
>                     not item.subitems and item.elapsed:
> -                item.store_info('autobookmark_resume', item.elapsed)
> -            else:
> -                _debug_('auto-bookmark not supported for this item')
> +            item.store_info('autobookmark_resume', item.elapsed)
> +        else:
> +            _debug_('auto-bookmark not supported for this item')
>
>          if event == PLAY_END:
>              item.delete_info('autobookmark_resume')
> @@ -129,14 +157,23 @@
>
>          # Bookmark the current time into a file
>          if event == STORE_BOOKMARK:
> -            bookmarkfile = util.get_bookmarkfile(item.filename)
> +        #Get time elapsed for xine video
> +        videoplayer = config.VIDEO_PREFERED_PLAYER
> +        if (videoplayer == 'xine'):
> +            command = ("%s -S get_time" % config.CONF.xine)
> +            handle = os.popen(command,'r')
> +            position = handle.read();
> +            handle.close()
> +            item.elapsed = int(position)
> +
> +        bookmarkfile = util.get_bookmarkfile(item.filename)
>
> -            handle = open(bookmarkfile,'a+')
> -            handle.write(str(item.elapsed))
> -            handle.write('\n')
> -            handle.close()
> -            rc.post_event(Event(OSD_MESSAGE, arg='Added Bookmark'))
> -            return True
> +        handle = open(bookmarkfile,'a+')
> +        handle.write(str(item.elapsed))
> +        handle.write('\n')
> +        handle.close()
> +        rc.post_event(Event(OSD_MESSAGE, arg='Added Bookmark'))
> +        return True
>
>          return False
>
>
> and for xine.py :
>
> --- xine.py.orig    2007-05-03 17:26:58.000000000 +0200
> +++ xine.py.new    2007-05-04 10:46:49.929813279 +0200
> @@ -86,7 +86,7 @@
>          self.app_mode  = ''
>          self.xine_type = type
>          self.app       = None
> -
> +
>          self.command = [ '--prio=%s' % config.MPLAYER_NICE ] + \
>                         config.XINE_COMMAND.split(' ') + \
>                         [ '--stdctl', '-V', config.XINE_VO_DEV,
> @@ -120,6 +120,9 @@
>          play a dvd with xine
>          """
>          self.item     = item
> +    self.options = options
> +    #Modif for autobookmark
> +    self.item.elapsed = 0
>          if config.EVENTS.has_key(item.mode):
>              self.app_mode = item.mode
>          else:
> @@ -169,10 +172,16 @@
>              self.app_mode = 'vcd'
>
>          else:
> -            command.append(item.url)
> +        if (len(options) > 1):
> +        if (options[1] == '--playlist'):
> +            #command.append('%s %s' % (options[1],options[2]))
> +            command.append(options[1])
> +            command.append(options[2])
> +        else:
> +        command.append(item.url)
>
> -        _debug_('Xine.play(): Starting cmd=%s' % command)
> -
> +        _debug_('Xine.play(): Starting cmd=>%s' % command)
> +
>          rc.app(self)
>          self.app = childapp.ChildApp2(command)
>          return None
> @@ -183,6 +192,15 @@
>          Stop xine
>          """
>          if self.app:
> +        #Modif for autobookmark
> +        command = "%s -S get_time" % config.CONF.xine
> +
> +        handle = os.popen(command,'r')
> +        position = handle.read();
> +        handle.close()
> +        print "Elapsed =", position
> +        self.item.elapsed = int(position)
> +        #######
>              self.app.stop('quit\n')
>              rc.app(None)
>
>
> Regards
>
> Senufo
>
>
>   
Hi Senufo,

That patch looks great and will be very handy in helping to provide a 
common feature set across players. Can you open a feature request in the 
tracker for this? http://sourceforge.net/tracker/?group_id=46652

Thanks,

John

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Freevo-users mailing list
Freevo-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freevo-users

Reply via email to