Update of /cvsroot/freevo/freevo/WIP/Aubin
In directory sc8-pr-cvs1:/tmp/cvs-serv23015

Added Files:
        player.py 
Log Message:
My slightly hacked copy of the player.py from src/audio that increments
the playcount and puts in a last play date whenever a song is played.

You can then view the data with the plugin I committed earlier.


FYI: This is all very rough and preliminary; when I've got things working
and tested, I will then begin to restructure some of this into a common
'sql' library and work on abstracting some of this into some sort of plugin.

I still want to make sure I can make dynamic playlists first.

If you want to use any of this, you need to:

1) Install sqlite and pysqlite
2) run ./helpers/musicsqlimport.py and wait for awhile.
3) Enable this player and the plugin if you want.

Then play music as normal and it should start tracking things.



--- NEW FILE: player.py ---
#if 0 /*
# -----------------------------------------------------------------------
# player.py - the Freevo audio player GUI
# -----------------------------------------------------------------------
# $Id: player.py,v 1.1 2003/06/30 04:57:30 outlyer Exp $
#
# Notes:
# Todo:        
#
# -----------------------------------------------------------------------
# $Log: player.py,v $
# Revision 1.1  2003/06/30 04:57:30  outlyer
# My slightly hacked copy of the player.py from src/audio that increments
# the playcount and puts in a last play date whenever a song is played.
#
# You can then view the data with the plugin I committed earlier.
#
#
# FYI: This is all very rough and preliminary; when I've got things working
# and tested, I will then begin to restructure some of this into a common
# 'sql' library and work on abstracting some of this into some sort of plugin.
#
# I still want to make sure I can make dynamic playlists first.
#
# If you want to use any of this, you need to:
#
# 1) Install sqlite and pysqlite
# 2) run ./helpers/musicsqlimport.py and wait for awhile.
# 3) Enable this player and the plugin if you want.
#
# Then play music as normal and it should start tracking things.
#
# Revision 1.4  2003/04/24 19:56:01  dischi
# comment cleanup for 1.3.2-pre4
#
# Revision 1.3  2003/04/22 11:56:45  dischi
# fixed bug that shows the player again after stopping it
#
# Revision 1.2  2003/04/21 18:40:32  dischi
# use plugin name structure to find the real player
#
# Revision 1.1  2003/04/21 13:27:48  dischi
# o make it possible to hide() the audio player
# o mplayer is now a plugin, controlled by the PlayerGUI
#
# -----------------------------------------------------------------------
# Freevo - A Home Theater PC framework
# Copyright (C) 2002 Krister Lagerstrom, et al. 
# Please see the file freevo/Docs/CREDITS for a complete list of authors.
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of MER-
# CHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program; if not, write to the Free Software Foundation, Inc.,
# 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#
# ----------------------------------------------------------------------- */
#endif

from gui.GUIObject import GUIObject

import skin
import rc
import plugin
import sqlite,time,config,os

skin = skin.get_singleton()

TRUE  = 1
FALSE = 0

class PlayerGUI(GUIObject):
    def __init__(self, item, menuw):
        GUIObject.__init__(self)
        if menuw:
            self.visible = TRUE
        else:
            self.visible = FALSE

        self.menuw = menuw
        self.item = item
        self.player = plugin.getbyname(plugin.AUDIO_PLAYER)
        self.running = FALSE
        
    def play(self):
        if self.player.is_playing():
            self.stop()
            
        if self.menuw and self.menuw.visible:
            self.menuw.hide()

        self.running = TRUE

        # Tell the database we played something
        db = sqlite.connect('%s/freevo.sqlite' % (config.FREEVO_CACHEDIR))
        cursor = db.cursor()
        cursor.execute('UPDATE music SET play_count=play_count + 1 WHERE path = \'%s\' 
and filename = \'%s\'' % (os.path.dirname(self.item.filename), 
os.path.basename(self.item.filename)))
        cursor.execute('UPDATE music SET last_play=%f WHERE path = \'%s\' and filename 
= \'%s\'' % (time.time(),os.path.dirname(self.item.filename), 
os.path.basename(self.item.filename)))
        db.commit()
        db.close()
        # ---- done with db

        self.player.play(self.item, self)
        if self.visible:
            rc.app(self.player)
        self.refresh()

    def stop(self):
        self.player.stop()
        self.running = FALSE
        if self.visible:
            rc.app(None)
        
    def show(self):
        if not self.visible:
            self.visible = 1
            self.refresh()
            rc.app(self.player)
            
    def hide(self):
        if self.visible:
            self.visible = 0
            skin.clear()
            rc.app(None)
            
    def refresh(self):
        """
        Give information to the skin..
        """
        if not self.visible:
            return

        if not self.running:
            return
        
        # Calculate some new values
        if not self.item.length:
            self.item.remain = 0
        else:
            self.item.remain = self.item.length - self.item.elapsed
        skin.draw(('player', self.item))
        return




-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to