Ejemplo n.º 1
0
	def _calc_bmpThumbnail(self):
		song = Song(url = self.url, _useDb = False)
		try:
			song.openFile()
		except IOError as exc:
			return {"error": exc}
		# Earlier, we copied the song.gain. Because of some internal musicplayer redesign,
		# musicplayer currently ignores the gain when it calculates the bmpThumnail.
		# But I think the thumbnails actually look better without the gain adoption,
		# so I'll just leave it that way now.
		import musicplayer
		try:
			# We have song.gain which mostly lowers the volume. So increase here for nicer display.
			duration, bmpData = musicplayer.calcBitmapThumbnail(song, 600, 81, volume = 1.5)
		except Exception as exc:
			return {"error": exc}
		return {"duration": duration, "bmpThumbnail": bmpData}
Ejemplo n.º 2
0
	def _calc_bmpThumbnail(self):
		song = Song(url = self.url, _useDb = False)
		try:
			song.openFile()
		except IOError as exc:
			return {"error": exc}
		# Earlier, we copied the song.gain. Because of some internal musicplayer redesign,
		# musicplayer currently ignores the gain when it calculates the bmpThumnail.
		# But I think the thumbnails actually look better without the gain adoption,
		# so I'll just leave it that way now.
		import musicplayer
		try:
			# We have song.gain which mostly lowers the volume. So increase here for nicer display.
			duration, bmpData = musicplayer.calcBitmapThumbnail(song, 600, 81, volume = 1.5)
		except Exception as exc:
			return {"error": exc}
		return {"duration": duration, "bmpThumbnail": bmpData}
Ejemplo n.º 3
0
			def doBmpCalc(queue):
				try:
					def calcBmpCallback(song, completion, duration, bmpData):
						if subview.window() is None: return False # window was closed
						with self.lock:
							if song != self.curSong: return False
						queue.put((duration, bmpData))
						return True

					song._useDb = False
					song.openFile()
					import musicplayer
					bmpThumbRet = musicplayer.calcBitmapThumbnail(song, 600, 81, procCallback = calcBmpCallback)
					if bmpThumbRet:
						queue.put(bmpThumbRet)
				except Exception:
					print "doBmpCalc raised exception"
					sys.excepthook(*sys.exc_info())
				queue.put(None)
Ejemplo n.º 4
0
            def doBmpCalc(queue):
                try:

                    def calcBmpCallback(song, completion, duration, bmpData):
                        if subview.window() is None:
                            return False  # window was closed
                        with self.lock:
                            if song != self.curSong: return False
                        queue.put((duration, bmpData))
                        return True

                    song._useDb = False
                    song.openFile()
                    import musicplayer
                    bmpThumbRet = musicplayer.calcBitmapThumbnail(
                        song, 600, 81, procCallback=calcBmpCallback)
                    if bmpThumbRet:
                        queue.put(bmpThumbRet)
                except Exception:
                    print "doBmpCalc raised exception"
                    sys.excepthook(*sys.exc_info())
                queue.put(None)
Ejemplo n.º 5
0
        "/Users/az/Music/Electronic/One Day_Reckoning Song (Wankelmut Remix) - Asaf Avidan & the Mojos.mp3",
    ]
    i = 5
    if len(sys.argv) >= 2: i = int(sys.argv[1])
    filename = files[i]

bmpWidth = 500
bmpHeight = 151
bgColor = (50, 50, 50)
timelineColor = (100, 100, 100)
timelineInterval = 5  # every 5 sec

assert os.path.isfile(filename)
import musicplayer
duration, bmp = musicplayer.calcBitmapThumbnail(Song(filename), bmpWidth,
                                                bmpHeight, bgColor,
                                                timelineColor,
                                                timelineInterval)


def formatTime(t):
    if t is None: return "?"
    mins = long(t // 60)
    t -= mins * 60
    hours = mins // 60
    mins -= hours * 60
    if hours: return "%02i:%02i:%02.0f" % (hours, mins, t)
    return "%02i:%02.0f" % (mins, t)


print filename, formatTime(duration)
    def readPacket(self, bufSize):
        s = self.f.read(bufSize)
        return s

    def seekRaw(self, offset, whence):
        r = self.f.seek(offset, whence)
        return self.f.tell()


for f in files:
    musicplayer.getMetadata(Song(f))
    progr()

print "after getMetadata"
step()

for f in files:
    musicplayer.calcAcoustIdFingerprint(Song(f))
    progr()

print "after calcAcoustIdFingerprint"
step()

for f in files:
    musicplayer.calcBitmapThumbnail(Song(f))
    progr()

print "after calcBitmapThumbnail"
step()
Ejemplo n.º 7
0
		"/Users/az/Music/Electronic/Von Paul Kalkbrenner - Aaron.mp3",
		"/Users/az/Music/Electronic/One Day_Reckoning Song (Wankelmut Remix) - Asaf Avidan & the Mojos.mp3",
	]
	i = 5
	if len(sys.argv) >= 2: i = int(sys.argv[1])
	filename = files[i]

bmpWidth = 500
bmpHeight = 151
bgColor = (50,50,50)
timelineColor = (100,100,100)
timelineInterval = 5 # every 5 sec

assert os.path.isfile(filename)
import musicplayer
duration, bmp = musicplayer.calcBitmapThumbnail(Song(filename), bmpWidth, bmpHeight, bgColor, timelineColor, timelineInterval)

def formatTime(t):
	if t is None: return "?"
	mins = long(t // 60)
	t -= mins * 60
	hours = mins // 60
	mins -= hours * 60
	if hours: return "%02i:%02i:%02.0f" % (hours,mins,t)
	return "%02i:%02.0f" % (mins,t)

print filename, formatTime(duration)

open("thumbnail.bmp", "w").write(bmp)

os.system("open thumbnail.bmp")