Changeset - fff8762db48a
[Not reviewed]
default
0 1 1
drewp@bigasterisk.com - 20 years ago 2005-06-14 02:52:37
drewp@bigasterisk.com
finished incomplete patch- asco now measures the length of songs (only for .wav)
2 files changed with 21 insertions and 9 deletions:
0 comments (0 inline, 0 general)
bin/ascoltami
Show inline comments
 
@@ -26,13 +26,13 @@ import Tkinter as tk
 

	
 
from twisted.internet import reactor,tksupport
 
from twisted.internet.error import CannotListenError
 
from twisted.web import xmlrpc, server
 

	
 
import run_local
 
from light9 import networking, showconfig
 
from light9 import networking, showconfig, wavelength
 

	
 
from pympd import Mpd
 

	
 
appstyle={'fg':'white','bg':'black'}
 

	
 
class XMLRPCServe(xmlrpc.XMLRPC):
 
@@ -135,31 +135,26 @@ class Player:
 

	
 
        self.check_autopause()
 

	
 
        reactor.callLater(.05, self.pollStatus)
 

	
 
    def set_total_time(self, song_path):
 
        raise NotImplementedError("get lengther.py from semprini")
 
        # currently only good for .wav
 
        p = os.path.join(showconfig.musicDir(), song_path)
 
        self.total_time.set(wavelength.wavelength(p))
 

	
 
    def play(self, song_path):
 
    
 
        self.autopausedthissong = False
 
        self.mpd.clear()
 
        self.mpd.add(showconfig.songInMpd(self.pre_post_names[0]))
 
        self.mpd.add(showconfig.songInMpd(song_path))
 
        self.mpd.add(showconfig.songInMpd(self.pre_post_names[1]))
 
        self.filename_var.set(song_path)
 

	
 
        self.set_total_time(song_path)
 
##         # jump to song 1 to get its total_time
 
##         self.mpd.seek(seconds=0, song=1)
 
##         self.mpd.pause()
 
##         self.mpd.status().addCallback(self.play2)
 

	
 
##     def play2(self, stat):
 
##         self.total_time.set(stat.time_total)
 
        self.mpd.seek(seconds=0, song=0)
 

	
 
    def check_autopause(self):
 
        pause_time = self.total_time.get() + 10
 
        if (not self.autopausedthissong and
 
            self.state.get() == "play" and
light9/wavelength.py
Show inline comments
 
new file 100644
 
#!/usr/bin/python
 

	
 
from __future__ import division, nested_scopes
 
import sys, wave
 

	
 
def wavelength(filename):
 
    wavefile = wave.open(filename, 'rb')
 

	
 
    framerate = wavefile.getframerate() # frames / second
 
    nframes = wavefile.getnframes() # number of frames
 
    song_length = nframes / framerate
 

	
 
    return song_length
 

	
 
if __name__ == "__main__":
 
    for songfile in sys.argv[1:]:
 
        print songfile, wavelength(songfile)
0 comments (0 inline, 0 general)