Thanks for posting this.
I'm having trouble getting this code to work with the 'resource not
found error'. The path appears to be correct, but am I missing
anything?
import msvcrt
import os
import pyglet
import sys
from collections import deque
def main():
songTypes = ['whistle', 'champions', 'endgame', 'goals', 'other',
'intermission', 'penalty', 'other', 'warmup']
pyglet.resource.path = songTypes
pyglet.resource.reindex()
playLists = []
for iter in songTypes:
playLists.append(initializePlaylist(iter))
while True:
printChoices(songTypes)
choice = msvcrt.getch()
if not choice in b'123456789qQ':
print(' >> Invalid choice')
continue
if choice in b'qQ': break
tuneQueue = playLists[int(choice) - 1]
playSong(tuneQueue[0])
tuneQueue.rotate()
def initializePlaylist(songtype):
"""returns a double ended qeue, each entry a (filename, filepath
to a song)"""
playlist = deque()
print os.path.join(os.path.abspath(os.curdir),songtype)
playlistfile = open(os.path.abspath(os.curdir) + '\\' + songtype +
'.m3u', 'r')
playlistfile.readline() # First line is useless data
while True:
mp3Tag = playlistfile.readline() # MP3 tag info
filePath = playlistfile.readline() # File path
if not mp3Tag: break
# The MP3 tag isn't used in the script, so don't bother saving
it
#playlist.append(filePath)
playlist.append(os.path.normpath(os.path.join(os.path.abspath(os.curdir),filePath)))
playlistfile.close()
return playlist
def playSong(song):
"""Takes a double ended qeue, plays first entry"""
print song
music = pyglet.resource.media(song)
player.play(music)
pyglet.app.run()
print("Press any key to stop playing.")
msvcrt.getch()
player.stop()
def printChoices(choices):
"""Prints enumerated choices to stdout."""
print("Choices:\n")
for index, choice in enumerate(choices):
print("\t%d. %s" % (index + 1, choice.title()))
print("\n\tQ. Quit")
if __name__ == "__main__":
player = pyglet.media.Player()
main()
--
You received this message because you are subscribed to the Google Groups
"pyglet-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/pyglet-users?hl=en.