Page 1 of 1

ListBox Commands

PostPosted: Mon Apr 25, 2016 1:05 pm
by StarterPack
Hi Guys

When i double click a song name in the ListBox, it plays the song till the end and stop . I want to know what script can i use on a different button to tell the ListBox that when the song stops, it must select the next song and keep on playing. So i want to use it like a On/Off button. When it's ON it must keep om playing and when it's OFF it must only play the selected song and then stop.

I also want to learn more about the ListBox commands like Play Random Song, Pause, Next Song etc, if anyone can direct me to where i can read about it, it will be much appreciated.

Thank You

Re: ListBox Commands

PostPosted: Mon Apr 25, 2016 1:55 pm
by Gaev
StarterPack:
I also want to learn more about the ListBox commands like Play Random Song, Pause, Next Song etc, if anyone can direct me to where i can read about it, it will be much appreciated.

Listbox commands only allow you (your code) to respond to user selection of ListBox entries ... you have to use other commands to manage audio/video files ... take a look at the NeoBookDX plugin from NeoBook here ... http://neosoftware.com/nbdx.html ... you can call this plugin's command to play, pause, stop audio/video files.

I want to know what script can i use on a different button to tell the ListBox that when the song stops, it must select the next song and keep on playing. So i want to use it like a On/Off button. When it's ON it must keep om playing and when it's OFF it must only play the selected song and then stop.

You can use the facilities within the NeoBookDX plugin to trigger further action when a song is played ... there, you can setup code to find/select the song associated with the next entry in your ListBox.

As for the ON/OFF switch, you can use a Push Button (whose ClickAction changes the value of a [variable] fron ON to OFF and back again) or a Radio Button or even another ListBox (with entries named ON and OFF).

Note that NeoBook is like your Lego Toy system ... it does not provide whole houses, boats, cars etc. ... but the bricks that you can mix and match to build the house, boat or car to your exact requirements.

Re: ListBox Commands

PostPosted: Mon Apr 25, 2016 5:55 pm
by StarterPack
Hi gaev

Thank you for your reply. I don't really understand how to use plugins for now, but i will learn in time.
I somehow managed to write script and for now it works fine for what i want.
This is what i did

To just play a song once

In ListBox DoubleClick Action

Code: Select all
SetVar "[PlayNum]" "1"
TimerStart "TimerPlay" "10"


TIMERPLAY1
Code: Select all
If "[PlayNum]" "=" "1"
SetVar "[TextEntry1]" ""
StrIns "[ListBox1]" "[TextEntry1]" "" "[TextEntry1]"
ListBoxFindItem "ListBox1" "[TextEntry1]" "[Num]"
StopMedia ""
PlaySoundFile "[PubDir][ListBox1]" "Wait"
Else
TimerStop "Timer2"
StopMedia ""
EndIf


For my ON button to keep on playing to the next song

ON BUTTON
Code: Select all
SetVar "[PlayNum]" "3"
TimerStart "Timer2" "500"


TIMER2
Code: Select all
If "[PlayNum]" "=" "3"
Math "[Num]+1" "" "[Count]"
StopMedia ""
ListBoxGetItem "ListBox1" "[Count]" "[TextEntry1]"
Math "[Num]+1" "" "[Num]"
PlaySoundFile "[PubDir][TextEntry1]" "Wait"
TimerStart "Timer2" "500"
Else
TimerStop "Timer2"
EndIf


And for my OFF button

OFF BUTTON
Code: Select all
StopMedia ""


Everything works for me at least, if it could only highlighted the song that is currently playing, it would be nice

Re: ListBox Commands

PostPosted: Mon Apr 25, 2016 6:39 pm
by StarterPack
OK Got It

I just put FindFirst Command In

Code: Select all
If "[PlayNum]" "=" "3"
Math "[Num]+1" "" "[Count]"
StopMedia ""
ListBoxGetItem "ListBox1" "[Count]" "[TextEntry1]"
FindFirst "(TextEntry1)" "Current"
Math "[Num]+1" "" "[Num]"
PlaySoundFile "[PubDir][TextEntry1]" "Wait"
TimerStart "Timer2" "500"
Else
TimerStop "Timer2"
EndIf

Re: ListBox Commands

PostPosted: Mon Apr 25, 2016 7:06 pm
by Gaev
StarterPack:

I somehow managed to write script and for now it works fine for what i want.

1) According to the Help file ... the Purpose of the PlaySoundFile command is to "Play a digital audio (WAVE) or music (MIDI) sound file." ... are the sound files you wish to play limited to these file types ?

2) You have used this combination of code before ...
Code: Select all
SetVar "[TextEntry1]" ""
StrIns "[ListBox1]" "[TextEntry1]" "" "[TextEntry1]"

... I am confused about the purpose of doing this ... assuming that a null "insert position" is the same as "1", how is this different from just doing ...
Code: Select all
SetVar "[TextEntry1]" "[ListBox1]"


Everything works for me at least
I will take your word that "everything works" ... though I am not sure if it needs to be so complicated.

if it could only highlighted the song that is currently playing, it would be nice

With ListBoxes ...

a) when the user selects an entry, it is highligted and its value (name or text) is stored in the corresponding variable (e.g. [ListBox1])

b) when your script changes the value of the variable (e.g. [ListBox1]), the corresponding entry will be highlighted

... so where you add to the counter [num], you can also change the value of the corrersponding variable ... take a look at ListBoxSize, ListBoxFindItem, ListBoxGetItem commands.