I was just trying to create a (basic) music player to discover SB, but when I use the OpenFileRequester() function, it gives me only the name of the file by using both SelectedFileName() and SelectedFileID()
Full path with OpenFileRequester()
-
JohnJohnsonSHERMAN
- Posts: 14
- Joined: Mon Oct 31, 2016 1:50 pm
- Location: Somewhere in this world...
- Contact:
Full path with OpenFileRequester()
Hi all!
I was just trying to create a (basic) music player to discover SB, but when I use the OpenFileRequester() function, it gives me only the name of the file by using both SelectedFileName() and SelectedFileID()
... The full path is never returned, eg. if I had a file located like this : D:/Data/music/mymusic.wav, I can only get the name (mymusic.wav), instead of the full path. How can I get the full path?
I was just trying to create a (basic) music player to discover SB, but when I use the OpenFileRequester() function, it gives me only the name of the file by using both SelectedFileName() and SelectedFileID()
"It's only by continuously trying that you can finally succeed."-The Shadoks
Note : This Sherman is 100% made in France, so his default language is French... Please ̶p̶a̶r̶d̶o̶n̶a̶t̶e̶ forgive him his English ̶m̶i̶s̶t̶a̶ï̶q̶u̶e̶s̶ mistakes
Note : This Sherman is 100% made in France, so his default language is French... Please ̶p̶a̶r̶d̶o̶n̶a̶t̶e̶ forgive him his English ̶m̶i̶s̶t̶a̶ï̶q̶u̶e̶s̶ mistakes
Re: Full path with OpenFileRequester()
You can't get the full path as the browser doesn't have access to it.
-
JohnJohnsonSHERMAN
- Posts: 14
- Joined: Mon Oct 31, 2016 1:50 pm
- Location: Somewhere in this world...
- Contact:
Re: Full path with OpenFileRequester()
So, how applications like music converters or Google Drive file importer can upload files? Does it means that you've to read and copy the whole file in a known location (like "Data/somefiles.xxx") to be able, for example, to load a sound that the user selected in the OpenFileRequester?
"It's only by continuously trying that you can finally succeed."-The Shadoks
Note : This Sherman is 100% made in France, so his default language is French... Please ̶p̶a̶r̶d̶o̶n̶a̶t̶e̶ forgive him his English ̶m̶i̶s̶t̶a̶ï̶q̶u̶e̶s̶ mistakes
Note : This Sherman is 100% made in France, so his default language is French... Please ̶p̶a̶r̶d̶o̶n̶a̶t̶e̶ forgive him his English ̶m̶i̶s̶t̶a̶ï̶q̶u̶e̶s̶ mistakes
Re: Full path with OpenFileRequester()
No, you can access the file once the user selected it, but you can't know the local path of it, only the filename.
-
JohnJohnsonSHERMAN
- Posts: 14
- Joined: Mon Oct 31, 2016 1:50 pm
- Location: Somewhere in this world...
- Contact:
Re: Full path with OpenFileRequester()
It doesn't works for me
When using this small code (from the documentation's examples), the lazer sound is correcly loaded and works fine, but when you try to open another sound, it fails... There is none error nor loading... It dont load anything...
Edit : In fact, it loads only sound files that are in the same directory as the sourcecode. And loads only one file before stopping working.
Code: Select all
;
InitSound()
Procedure Play()
PlaySound(0)
EndProcedure
Procedure RequesterSuccess()
; Process all the selected filename
;
While NextSelectedFile()
Debug "Filename: " + SelectedFileName()
LoadSound(0,SelectedFileID())
Debug "Loading the sound..."
Wend
EndProcedure
Procedure Open()
OpenFileRequester("", @RequesterSuccess(), #PB_Requester_MultiSelection)
EndProcedure
Procedure Start()
If OpenWindow(0, 0, 0, 200, 90, "Sound example", #PB_Window_TitleBar | #PB_Window_SizeGadget | #PB_Window_ScreenCentered)
ButtonGadget(0, 10, 10, 180, 30, "Play")
ButtonGadget(1, 10, 50, 180, 30, "Open")
BindGadgetEvent(0, @Play())
BindGadgetEvent(1, @Open())
EndIf
EndProcedure
Procedure Loading(Type, Filename$, ObjectId)
Static NbLoadedElements
Debug Filename$ + " loaded (id = " + ObjectId + ")"
NbLoadedElements+1
If NbLoadedElements = 1 ; Finished the loading of all sounds, we can start the application
If IsSound(0)
Debug "Ok, sound loaded."
Else
Debug "Error !" ;This always happends...
EndIf
Start()
EndIf
EndProcedure
Procedure LoadingError(Type, Filename$)
Debug Filename$ + ": loading error"
EndProcedure
; Register the loading event before calling any resource load command
BindEvent(#PB_Event_Loading, @Loading())
BindEvent(#PB_Event_LoadingError, @LoadingError())
LoadSound(0, "Data/Lazer.wav")
Edit : In fact, it loads only sound files that are in the same directory as the sourcecode. And loads only one file before stopping working.
"It's only by continuously trying that you can finally succeed."-The Shadoks
Note : This Sherman is 100% made in France, so his default language is French... Please ̶p̶a̶r̶d̶o̶n̶a̶t̶e̶ forgive him his English ̶m̶i̶s̶t̶a̶ï̶q̶u̶e̶s̶ mistakes
Note : This Sherman is 100% made in France, so his default language is French... Please ̶p̶a̶r̶d̶o̶n̶a̶t̶e̶ forgive him his English ̶m̶i̶s̶t̶a̶ï̶q̶u̶e̶s̶ mistakes