Source language: Translate to:

Load music

Questions about using NeoBook's scripting language

Moderator: Neosoft Support

Load music

Postby Neobook » Mon Jan 29, 2007 11:11 am

Hello,

I want to know how to load a music if I write the name in a variable. The variable will be search the name that I wrotte in My Music (My Documents\My Music). I believe it is with the find function, but it doesn't work !

If any body can help me !
Neobook
 
Posts: 131
Joined: Sat Jul 01, 2006 7:07 am

Postby Neosoft Support » Mon Jan 29, 2007 12:28 pm

There are several different ways to load a sound file. The simplest is probably to use the PlaySoundFile action. For example:

PlaySoundFile "C:\Multimedia\Sound\Bachto.mid" "Normal"

Instead of a literal file name you can also use a variable:

SetVar "[MyMusic]" "C:\Multimedia\Sound\Bachto.mid"
PlaySoundFile "[MyMusic]" "Normal"
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5593
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Postby Neobook » Wed Jan 31, 2007 6:23 am

Hello,

Thanks for your answer, it is possible to play an mp3 sound ? I tried with DX but it can't load with variable.
Neobook
 
Posts: 131
Joined: Sat Jul 01, 2006 7:07 am

Postby Neosoft Support » Wed Jan 31, 2007 12:09 pm

You can play MP3 files if you have the proper MP3 driver installed on your PC. NeoBookDX doesn't include its own media drivers or players. Instead it lets Windows' DirectX handle the actual loading and playing of sound and video. DirectX is the same technology that Windows Media Player uses. If Windows Media Player can play your file, the NeoBookDX usually can too. If a particular type of file doesn't work, try upgrading to the latest version of Windows Media Player.
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5593
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Postby Neobook » Wed Jan 31, 2007 12:38 pm

Thanks,

I have all driver for MP3.

SetVar "[MyMusic2]" "[MyDocuments]My Music\[MyMusic].mp3"
PlaySoundFile "[MyMusic2]" "Normal"
Setvar "[MyMusic]" ""

When I writte in the TextEntry ([MyMusic]) the name of the music, and I click of Enter, Neobook have to play the music (if it found).

But the PlaySoundFile action can't play the MP3 files.

How can I do it ?
Neobook
 
Posts: 131
Joined: Sat Jul 01, 2006 7:07 am

Postby Neosoft Support » Thu Feb 01, 2007 11:07 am

I didn't have any trouble playing MP3 files using PlaySoundFile so there may be a problem with your code. Try just playing a sound file directly without attempting to set any variables. For example:

PlaySoundFile "C:\Multimedia\MyMusic.mp3" "Normal"
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5593
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Postby Neobook » Thu Feb 01, 2007 11:26 am

Thanks,

But I don't know what I play for a music, because it's the variable, I write the name in the variable so it can load the music.
Neobook
 
Posts: 131
Joined: Sat Jul 01, 2006 7:07 am

Postby Gaev » Thu Feb 01, 2007 12:56 pm

NeoBook:

Assuming the mp3 file is called xyz.mp3 ...

Step 1:

Confirm that when you double click on file entry for xyz.mp3 in Windows Explorer, the file plays as expected


Step 2:

If Step 1 is OK, try this code in a button ...
Code: Select all
SetVar "[MyMusic2]" "[MyDocuments]My Music\xyz..mp3"
FileExists "[MyMusic2]" "[FileExistsStatus]"
If "[FileExistsStatus]" "=" "True"
   AlertBox "MyMusic2" "File|[MyMusic2]|Exists"
Else
   AlertBox "MyMusic2" "File|[MyMusic2]|DOES NOT EXIST"
   Return
EndIf
PlaySoundFile "[MyMusic2]" "Normal"
... let us know what results you get.
User avatar
Gaev
 
Posts: 3718
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby Cipolla » Fri Feb 02, 2007 5:48 am

Just an idea, maybe there are square brackets "[]" in the filename?
then the file used as a variable could not be found by neobook.

did you get a message in the debugger?
Greetings from Germany
Klaus
User avatar
Cipolla
 
Posts: 166
Joined: Fri Apr 01, 2005 1:45 am
Location: Germany

Postby Neobook » Fri Feb 02, 2007 8:33 am

Hello,

Thanks for the answer.

In My Document\My Music, they are :

- aze.mp3
- fgh.mp3
- fggh.mp3
- ...

They are a lot of music in My Document\My Music

In the text Entry, when I write the title (for example : fhg.mp3) it search in My Music and play it.

So you saied :
SetVar "[MyMusic2]" "[MyDocuments]My Music\xyz..mp3"

This can not work, because the name of the music is writing.

I have to write the music and it searchs and play.

It's why I wrotte that :
SetVar "[MyMusic2]" "[MyDocuments]My Music\[MyMusic].mp3"

[MyMusic] is the Text Entry.
Last edited by Neobook on Fri Feb 02, 2007 9:22 am, edited 1 time in total.
Neobook
 
Posts: 131
Joined: Sat Jul 01, 2006 7:07 am

Postby Gaev » Fri Feb 02, 2007 9:18 am

NeoBook:
In My Document\My Music, they are :
- aze.mp3
- fgh.mp3
- fggh.mp3
- ...
They are a lot of music in My Document\My Music

So you saied :
SetVar "[MyMusic2]" "[MyDocuments]My Music\xyz..mp3"
This can not work, because the name of the music is writing.
... I am not sure I understand your last comment ... but the objective of my last post was to help you to "debug" your problem ... you do this "one step at a time" ... and depending on your results, you either found the problem ... or if it works as expected, you move to the next step.

So when you go to Wndows Explorer ... folder My Documents\My Music ... and click on aze.mp3 ... does it play as expected ? ... if it works, you will have established that the file is playable in your environment.

If it does, (temporarily) create a new button in your pub ... and for the click event, insert the code I suggested in the last post ... and advise if it works when you click on it ... if it works, you will establish that you can play that mp3 file via NeoBook's command.

In the text Entry, when I write the title (for example : fhg.mp3) it search in My Music and play it.

It's why I wrotte that :
SetVar "[MyMusic2]" "[MyDocuments]My Music\[MyMusic].mp3"

[MyMusic] is the Text Entry.
... if you are entering fhg.mp3 ... and your SetVar command is appending .mp3 to [MyMusic] ... you are probably ending up with fhg.mp3.mp3
User avatar
Gaev
 
Posts: 3718
Joined: Fri Apr 01, 2005 7:48 am
Location: Toronto, Canada

Postby Neobook » Fri Feb 02, 2007 9:22 am

Yes, now it is work,

Thank you very much Gaev
Neobook
 
Posts: 131
Joined: Sat Jul 01, 2006 7:07 am


Return to NeoBook Action Commands

Who is online

Users browsing this forum: No registered users and 2 guests