Uh, wait. You're sending the song name to a socket, then playing the music.
Why send the song name?

Brutish solution is this:

def update(dt):
  global music
  if not music.playing:
    pyglet.app.exit()

and before pyglet.app.run():

  pyglet.clock.schedule_interval(1/60.0, update)

This should work. For reference, check the documentation on music playback
and event loops. API reference could also help.

On 18 July 2011 17:40, musicmac <[email protected]> wrote:

> hey guys
> i just started using pyglet this morning for a music project, the idea
> is to be able to play the same song on 2 machines much like a sonos
> box or something but the cheap man way. I currently have
> [code]
> import os
> import socket
> import pyglet
>
> port = 8081
> s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
> print 'ip adress?'
> ip = raw_input();
> dir = os.getcwd()
> print os.listdir(dir)
> running = 1
> while (running == 1):
>    print "which song now? (type the file name in full don't forget
> the .mp3)"
>    song = raw_input()
>    s.sendto((song), (ip, port))
>    music = pyglet.resource.media(song)
>    music.play()
>    pyglet.app.run()
> [/code]
> but the program just sticks at playing the song and pyglet won't
> close :(
>  TLDR how can i close pyglet after a song has played?
>
> --
> 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.
>
>

-- 
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.

Reply via email to