Fixed formatting.

master
Jay 2 years ago
parent 57e705cf47
commit 1ffd3d72cf

@ -28,28 +28,28 @@ can get tedious, hence a script.
```
[examplejuke-main]
exten = s,1,Answer() # Answer the channel.
same = n,Set(VOLUME(TX)=-3) # Lower volume since that seems necessary.
same = n,Set(c=examplejuke-main) # Set the "c" variable so we can return to this context.
same = n(loop),Background(foobar/menu) # Label for "loop", plays the menu audio.
same = n,WaitExten(5) # Wait a few seconds
same = n,Set(m=$[${m} + 1]) # Increase "m" by one.
same = n,GoToIf($["${m}" < "5"]?loop) # Compare to "5", return to "loop" if true.
same = n,(goodbye)Background(foobar/bye) # It was false...good bye. "Goodbye" label.
same = n,Hangup() # SLAM
exten = _00XX,1,Set(aa=foobar/00album) # Set the aa variable to the album directory for leading 00
same = n,GoToIf($["${EXTEN:-2}" = "00"]?8track-player,*11,1) # Check last two dialed. If album playback, pass total tracks as extension.
same = n,GoTo(cart-player,*${EXTEN:-2},1) # Pass the last two digits to cart-player as *ext
exten = _01XX,1,Set(aa=foobar/01album) # Repeat for album leading 01
exten = s,1,Answer() # Answer the channel.
same = n,Set(VOLUME(TX)=-3) # Lower volume since that seems necessary.
same = n,Set(c=examplejuke-main) # Set the "c" variable so we can return to this context.
same = n(loop),Background(foobar/menu) # Label for "loop", plays the menu audio.
same = n,WaitExten(5) # Wait a few seconds
same = n,Set(m=$[${m} + 1]) # Increase "m" by one.
same = n,GoToIf($["${m}" < "5"]?loop) # Compare to "5", return to "loop" if true.
same = n,(goodbye)Background(foobar/bye) # It was false...good bye. "Goodbye" label.
same = n,Hangup() # SLAM
exten = _00XX,1,Set(aa=foobar/00album) # Set the aa variable to the album directory for leading 00
same = n,GoToIf($["${EXTEN:-2}" = "00"]?8track-player,*11,1) # Check last two dialed. If album playback, pass total tracks as extension.
same = n,GoTo(cart-player,*${EXTEN:-2},1) # Pass the last two digits to cart-player as *ext
exten = _01XX,1,Set(aa=foobar/01album) # Repeat for album leading 01
same = n,GoToIf($["${EXTEN:-2}" = "00"]?8track-player,*15,1)
same = n,GoTo(cart-player,*${EXTEN:-2},1)
exten = _02XX,1,Set(aa=foobar/02album) # Album 02 is different. Files do not have a leading 0.
same = n,GoToIf($["${EXTEN:-2}" = "00"]?8track-player,#12,1) # Pass last two to 8track-player's # pattern.
same = n,GoToIf($["${EXTEN:-2}" < "10"]?cart-player,#${EXTEN:-1},1) # If the last two are less than 10; pass to single digit to cart-player #ext
same = n,GoTo(cart-player,*${EXTEN:-2},1) # Use the "standard" call for tracks more than 10.
exten = _02XX,1,Set(aa=foobar/02album) # Album 02 is different. Files do not have a leading 0.
same = n,GoToIf($["${EXTEN:-2}" = "00"]?8track-player,#12,1) # Pass last two to 8track-player's # pattern.
same = n,GoToIf($["${EXTEN:-2}" < "10"]?cart-player,#${EXTEN:-1},1) # If the last two are less than 10; pass to single digit to cart-player #ext
same = n,GoTo(cart-player,*${EXTEN:-2},1) # Use the "standard" call for tracks more than 10.
```
The setup for the jukeboxes has undergone about as much optimization as I think I can perform. I did trade a few variables for reducing the overall number of lines.
@ -66,45 +66,45 @@ album setups to use this same logic. Provided you can work with the requirement
```
[cart-player]
exten = _#X,1,Wait(.25) # The # extensions are for non-leading zeros. Give DTMF time to shut-up.
same = n,Set(z=${EXTEN}) # Write extension to variable for recall later.
same= n,Background(${aa}/${EXTEN:-1}) # Pass the last digit as the file name to be played. (1.ulaw, 9.ulaw)
same = n,Goto(${c},s,return) # It's done. Go home.
exten = _*XX,1,Wait(.25) # All tracks over 10 or with leading zeros. Shut up DTMF.
same = n,Set(z=${EXTEN}) # Write extension to variable for recall later.
same= n,Background(${aa}/${EXTEN:-2}) # Pass last two of extension (the only two) as filename (01.ulaw ... 99.ulaw)
same = n,Goto(${c},s,return) # It's done. Go Home
exten = 2,1,Goto(cart-player,${z},1) # Start the song over.
exten = i,1,Goto(${c},s,return) # Press anything but 2 to go away at any time.
exten = _#X,1,Wait(.25) # The # extensions are for non-leading zeros. Give DTMF time to shut-up.
same = n,Set(z=${EXTEN}) # Write extension to variable for recall later.
same= n,Background(${aa}/${EXTEN:-1}) # Pass the last digit as the file name to be played. (1.ulaw, 9.ulaw)
same = n,Goto(${c},s,return) # It's done. Go home.
exten = _*XX,1,Wait(.25) # All tracks over 10 or with leading zeros. Shut up DTMF.
same = n,Set(z=${EXTEN}) # Write extension to variable for recall later.
same= n,Background(${aa}/${EXTEN:-2}) # Pass last two of extension (the only two) as filename (01.ulaw ... 99.ulaw)
same = n,Goto(${c},s,return) # It's done. Go Home
exten = 2,1,Goto(cart-player,${z},1) # Start the song over.
exten = i,1,Goto(${c},s,return) # Press anything but 2 to go away at any time.
[8track-player]
exten = _*XX,1,Set(tt=${IF($[${EXTEN:-2} < 10]?${EXTEN:-1}:${EXTEN:-2})}) # Leading zeros. Check if album is less than 10 tracks. Set tt (total tracks).
same = n,Set(t=1) # Initialize track counter.
same = n,Set(p=*) # Set context prefix for controls use.
same = n(lead),GoToIf($[${t} = 10]?tenplus) # If we've crossed track 10, jump to "tenplus". Label for "lead".
same = n(hax),Background(${aa}/0${t}) # Prefix 0 to filename based on "t" for leading zeros. "hax" label.
same = n(next),Set(t=$[${t} + 1]) # "next" label. Increases track counter by one.
same = n,GoToIf($[${t} < ${tt}]?lead) # Compares track count to TT value. Loops back to "lead" if not met.
same = n,Goto(${c},s,goodbye) # We played all the tracks. Go back to main menu "goodbye".
same = n(tenplus),Set(p=#) # "tenplus" label. Change p from * to #.
same = n,GoTo(#00,hax) # Switch to the "hax" prority for #00 to continue double-digit file playback.
exten = _#XX,1,Set(tt=${IF($[${EXTEN:-2} < 10]?${EXTEN:-1}:${EXTEN:-2})}) # No Leading zero filenames. Checks for albums less than 10. Sets tt.
same = n,Set(t=1) # Initializes playback counter
same = n,Set(p=#) # Sets the P variable
same = n(hax),Background(${aa}/${t}) # Plays back file. Hax label. Entry point from * land.
same = n(next),Set(t=$[${t} + 1]) # Increase track count
same = n,GoToIf($[${t} < ${tt}]?hax) # Look at track count compared to total. Go back to hax if not done.
same = n,Goto(${c},s,goodbye) # Done. Stop wasting my money/
exten = 1,1,GoToIf($["${t}" = "1"]?wait) # Track back. Check to see if we can go back. Just skip if we can't.
same = n,Set(t=$[${t} - 1]) # Subtract 1 from T.
same = n(wait),Wait(.25) # Wait for DTMF to shut up.
same = n,Goto(${p}00,hax) # Go back from whatever extension branch we were one based on p to the hax label.
exten = 2,1,Wait(.25) # Wait.
same = n,Goto(${p}00,hax) # Just loop back to hax without changing track count.
exten = 3,1,Wait(.25) # Wait.
same = n,Goto(${p}00,next) # Jump to "next" in wherever the hell we are.
exten = 0,1,Goto(${c},s,return) # Press 0 to go home.
exten = _*XX,1,Set(tt=${IF($[${EXTEN:-2}<10]?${EXTEN:-1}:${EXTEN:-2})}) # Leading zeros. Check if album is less than 10 tracks. Set tt (total tracks).
same = n,Set(t=1) # Initialize track counter.
same = n,Set(p=*) # Set context prefix for controls use.
same = n(lead),GoToIf($[${t} = 10]?tenplus) # If we've crossed track 10, jump to "tenplus". Label for "lead".
same = n(hax),Background(${aa}/0${t}) # Prefix 0 to filename based on "t" for leading zeros. "hax" label.
same = n(next),Set(t=$[${t} + 1]) # "next" label. Increases track counter by one.
same = n,GoToIf($[${t} < ${tt}]?lead) # Compares track count to TT value. Loops back to "lead" if not met.
same = n,Goto(${c},s,goodbye) # We played all the tracks. Go back to main menu "goodbye".
same = n(tenplus),Set(p=#) # "tenplus" label. Change p from * to #.
same = n,GoTo(#00,hax) # Switch to the "hax" prority for #00 to continue double-digit file playback.
exten = _#XX,1,Set(tt=${IF($[${EXTEN:-2}<10]?${EXTEN:-1}:${EXTEN:-2})}) # No Leading zero filenames. Checks for albums less than 10. Sets tt.
same = n,Set(t=1) # Initializes playback counter
same = n,Set(p=#) # Sets the P variable
same = n(hax),Background(${aa}/${t}) # Plays back file. Hax label. Entry point from * land.
same = n(next),Set(t=$[${t} + 1]) # Increase track count
same = n,GoToIf($[${t} < ${tt}]?hax) # Look at track count compared to total. Go back to hax if not done.
same = n,Goto(${c},s,goodbye) # Done. Stop wasting my money
exten = 1,1,GoToIf($["${t}" = "1"]?wait) # Track back. Check to see if we can go back. Just skip if we can't.
same = n,Set(t=$[${t} - 1]) # Subtract 1 from T.
same = n(wait),Wait(.25) # Wait for DTMF to shut up.
same = n,Goto(${p}00,hax) # Go back from whatever extension branch we were one based on p to the hax label.
exten = 2,1,Wait(.25) # Wait.
same = n,Goto(${p}00,hax) # Just loop back to hax without changing track count.
exten = 3,1,Wait(.25) # Wait.
same = n,Goto(${p}00,next) # Jump to "next" in wherever the hell we are.
exten = 0,1,Goto(${c},s,return) # Press 0 to go home.
```
So the basic idea is that these dialplans either play back a single file, or play back an album. They do so without manaually coding a list of files by relying on the files to be
@ -126,6 +126,6 @@ the "hax" label was an early hold-over from testing the leading 0 routine; origi
Though we call specific extensions in the context; once we're in we don't. The number you pass as an extension just configures the number of tracks. Once we have that, we don't need
it. This is why the playback controls and "over 10" make a call to double-0...specifically double-zero hax label. We just need to get back in to the proper set of logic. Calling ext
00 from outside the playback context would likely result in the first file playing and then ending immedately. In fact...brainstorm. Pass the number of tracks and track selection as
00 from outside the playback context would likely result in the first file playing and then ending immedately. ~~In fact...brainstorm. Pass the number of tracks and track selection as
a four digit extension. Set number of tracks to 00 with track number to get single track playback; pass number of tracks with track number 00 to play an album. That might be the next
major revision to the asterisk jukebox if I can figure out how to handle the leading 0 BS.
major revision to the asterisk jukebox if I can figure out how to handle the leading 0 BS.~~ ##### Wait? What? This doesn't even make any sense now. I gotta stop writing stuff at 3AM.
Loading…
Cancel
Save