Author Topic: Plying mp3 file locked for renaming. How to unlock?  (Read 313 times)

trippinVBsix

  • Posts: 2
Hi all, Newbie here.

I'm playing an mp3 in VB6 using the code below and need to rename and move the file, but it stays locked so I assume the file is locked by the library. How can I unlock it for file operations?

1. The files play fine and stops when I press the buttons
2. After I press play, the file is locked (I can't rename it) unless
3. I do Call BASS_Free

The problem with (3.) is that I need a new initializing (form_load code) after that, and that takes time. Is there another call I can use to release the file to the OS (Windows 10 BTW).
Thanx guys...

My code (simplified but all calls to the library):
'form_load - initiating
        If (HiWord(BASS_GetVersion) <> BASSVERSION) Then exit sub
        If BASS_Init(-1, 44100, 0, Me.hWnd, 0) = BASSFALSE Then Exit Sub

'play button click event
        StreamHandle = BASS_StreamCreateFile(BASSFALSE, StrPtr(strPath2file), 0, 0, 0)
        If (BASS_ChannelPlay(StreamHandle, BASSFALSE) = 0) Then Exit Sub

'stop button click event
        If StreamHandle <> 0 Then Call BASS_ChannelStop(StreamHandle)

'form_unload - exiting, cleaning up
        Call BASS_Free

'If you have links to where I can find pause, polling if lib is playing, finding current position in file and total time, I would be greatfull - but 'the locking' is my main issue :- )

jpf

  • Posts: 75
Re: Plying mp3 file locked for renaming. How to unlock?
« Reply #1 on: 16 Jul '19 - 16:04 »
Call BASS_StreamFree (StreamHandle) to unlock the file.



trippinVBsix

  • Posts: 2
Re: Plying mp3 file locked for renaming. How to unlock?
« Reply #2 on: 16 Jul '19 - 18:28 »
Thanks, jpf. It sounds so easy when you say it  :D.