[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] How to close audio file?



Maybe my memory is fuzzy from so much time spent on Linux, but I thought 
Windows only locked files that you have open for writing. Shouldn't it 
not be locking a file that is only open for read?

Is it possible that mixer.music.load() is opening the music file in the 
wrong mode?

---
James Paige

On Fri, Mar 23, 2012 at 03:27:38PM +0000, Russell Jones wrote:
>    Not tested, but try getting a file object and using that instead, e.g.
>    f=open('myfile.wav')
>    pygame.mixer.music.load(f)
>    ...
>    pygame.mixer.music.stop()
>    f.close()
> 
>    Russell
> 
>    On 21 March 2012 01:13, kfank <kurtbutfrank@xxxxxxxxx> wrote:
> 
>      I'm using pygame to play a wav file using the mixer.music module, but
>      after completion the file remains locked.A  For example,
> 
>      import pygame
>      pygame.mixer.init(44100, -16, 2, 1024)
>      clock = pygame.time.Clock()
>      pygame.mixer.music.load('myfile.wav')
>      pygame.mixer.music.play(1)
>      ...
>      # wait until completion
>      ...
>      pygame.mixer.music.stop()
> 
>      At this point the file is still locked by the process. How do you close
>      the file handle which was opened by the load command?