by Just Guessing » Sat Sep 07, 2013 6:20 pm
I'm not sure I know what you mean; isn't EVERY timer created as an object?
And yes, I am seeking to cancel a SPECIFIC timer; if a button is pressed in a popup before the song ends. Not being able to cancel the specific timer has a convoluted solution (though I have the script working at this point).
Below is the script in working state (if less than perfect) . Maybe someone spots superior solutions or absent error handling!
This is a
KARAOKE TRANSITION SCRIPT:
before the current song in the 'NOW PLAYING' list ends, a popup announces the next song.
There is a button. The next song will not start unless the button is pressed.
There is then a 3 second gap before the next song.
After checking out your scripts, Mr Weichert, It struck me that I should borrow your inspiration of your "Speak Song Title" script. So I have studied and mimicked your examples and implimented a voice that will come after a few seconds, if no one presses the button (to harrass the singers who aren't paying attention). I'm amazed how simple it is to implement the SAPI voice, though was frustrated with how hard it is to get it to be intelligable! Anyone who doesn't carve out that function will have to personalize the messages themselves. Its a pain, but it IS pretty funny. I should credit Steegy as his RatePlayedSong actually began as the framework. I should credit others too, if I knew who to credit, as mostly i'm copying someone's elses example!
Code: Select all
'====================================================================================
' DCM KARAOKE ANNOUNCER - when a song is ending, announces next, pauses and asks for permission to continue
' put in AUTO scripts folder
'================================================================ !!!!!TEST FOR "NO PHOTO" FAILURE!
Option Explicit
Dim MenuItem, NextOne, PreviousSong, IntervalTimer, GapTimer, AnnaTimer
Dim NextSong
Dim NextArtist
Dim NextTitle
Const Gap = 3000 ' tweak here (milliseconds)
Const Interval = 6000 ' tweak here (milliseconds)
''Const MenuItemOn = True
'Dim MenuItemOn
Sub OnStartup
Set MenuItem = SDB.UI.AddMenuItem(SDB.UI.Menu_TBStandard, 0, 0)
MenuItem.IconIndex = 2
MenuItem.Caption = "Karaoke Transition Box"
MenuItem.Checked = False
Script.RegisterEvent MenuItem, "OnClick", "MenuItem_OnClick"
Script.RegisterEvent SDB, "OnPlay", "IntervalCheck"
Script.RegisterEvent SDB, "OnStop", "WereStopping"
Script.RegisterEvent SDB, "OnPause", "WerePausing"
Script.RegisterEvent SDB, "OnTrackEnd", "SpeakAnna"
End Sub
Sub SpeakAnna
If ( SDB.Player.CurrentSongIndex < SDB.Player.PlaylistCount - 1 ) Then
Set AnnaTimer = SDB.CreateTimer(5000)
Script.RegisterEvent AnnaTimer, "OnTimer", "AnnaTimerSub"
End If
End Sub
Sub AnnaTimerSub(AnnaTimer)
AnnaTimer.Enabled = False
Script.UnRegisterEvents AnnaTimer
Set AnnaTimer = Nothing
If Not SDB.Player.isPlaying Then
Dim SongTitle : SongTitle = SDB.Player.CurrentSong.Title
Dim SongArtist : SongArtist = SDB.Player.CurrentSong.ArtistName
Dim AnnaSays1 : AnnaSays1 = "\r-2 I \p4\r-4 mean,\r-5\p2 for \p-3 the \r-7\p9\e love/e \r-7\v7\p-8 of. \3 \v10 \r0 \p1Who \p-2\r-2owns \r0 the \p0 song, " & SongTitle & "? \5 \p2 \r-6 Folks?"
Dim AnnaSays2 : AnnaSays2 = "\r-7Yo!\4 \r-3 Who gonna \r-5 sing? \3 \p7" & SongTitle & ". \4 " & SongTitle & "!"
Dim AnnaSays3 : AnnaSays3 = "Dog playin piano. \3\r-6Crazy,\r0 \p6in \r-10\p10 saine \p-3\r-4 broe. \r0Any who. " & SongTitle & ", \r-1 you're up."
Dim AnnaSays4 : AnnaSays4 = "Someone chose " & SongTitle & ", by " & SongArtist & ". Or, \r-6 \p9 am \r-4\p3 I \r-10\p-4 high?"
Dim AnnaSays5 : AnnaSays5 = "\p-2\r2 ain't no \r-5 skin \r1\p-3 off \r-6\p10 \e my /e \p-5\r0 arse, \p0 if no one wants to claim\r-6 " & SongTitle & "! \r-1 Just\r-5 sayin."
Dim AnnaSays6 : AnnaSays6 = "\r-5\p-8 \e what /e \9\r0\p0 Because, I'm, a \p7\r-4 \e row butt? /e \3\p0\r0 Is that why you \r-4 ignore me? \r0 I, got \p3 " & SongTitle & " \p0 all ready, for who ever \r1 selected \r0 it. \r-2 Any time, \r-5\p9\3 Oh \p-5 Kay"
Dim AnnaSays7 : AnnaSays7 = "\r0 whats the \r-2 problem?\3 "
Dim AnnaSays8 : AnnaSays8 = "\r-6 \p-8 I'm\r-1 in\p7\evisible/e\r-4 over \p5 here? \5 \p-2 \r-3 or \p-10 \e \r-6 what? /e " '
Dim AnnaSays9 : AnnaSays9 = "Waiting For \r-5\e\p7some/e \p1one, \r-1 \p0To sing \p7 \r-4" & SongTitle & ", \p-7\r-1by \p3 \r-5 " & SongArtist & "!"
Dim AnnaSays10 : AnnaSays10 = "You're scaring me \r-2\p-4people. \p0 \1 Are \1 our \r0 attention spans \r-2 \p9 that, \p0 \r0 short? Really? Who picked \e " & SongTitle & "?/e Come on."
Dim AnnaSays11 : AnnaSays11 = "Calling the \p3 \e song \p0\r-3 stir \r0/e \2 who chose \r-2 " & SongTitle & ""
Dim AnnaSays12 : AnnaSays12 = "Well, \r-3\p5SOMEBODY \p0\r0 picked \r-2\e " & SongTitle & "/e. \r0\4 Are \r-3 we \r-4 in the \p4 \r-3 toilet. \p0 \3 \r-6 Hello,"
Dim AnnaSays13 : AnnaSays13 = "Is that \r-5\edog/e \r0 playing PIANO? seriously? Well, \r-1\p-2anyway, \r0\p0 someone was going to sing " & SongTitle & ""
Dim AnnaSays14 : AnnaSays14 = " \r-10 \p-7 <pron sym=""p ah l""/> /p\p10 <pron sym=""l iy - iy - iy z""/> /p/r"
Dim AnnaSays15 : AnnaSays15 = "OK, in five seconds, if nobody else starts \p-9 singing \r-3\p-9\3 ohhhh \r4 \p0 what's the \r-2 song? \r-1\p-1 " & SongTitle & ", \r0 then, \p10 \r-10 I'm \r4\p-1 going to \p-6\r-1 sing \p-8 it! \2 \r2\p5 You want that? \4 \r0\p-2 No!\r1 I didn't \p4\r-2 \e think /e\p-3 so!"
Dim AnnaSays16 : AnnaSays16 = " \r-6 please. \r-8\p4 Please! \r-10 \p10 <pron sym=""l iy - 1 iy 1 - iy - iy - iy - iy - iy - iy z""/> /v/p/r"
Dim AnnaSays17 : AnnaSays17 = "\r-10 NEXT! NEXT! <pron sym=""n eh k k k k k - k s t""/>\4 \p5Oh, \r-6\p-5 " & SongTitle & "!"
Dim AnnaSays18 : AnnaSays18 = "\p8\r-6 Well \p-10\r-3 shit, \p5 \r0 what \p-7\r-10 ever. \r-4 \p0 go \r-2\p-4baby, \5\r-2\p10 " & SongTitle & ". \4 By \p3 \r-5 " & SongArtist
Dim AnnaSays19 : AnnaSays19 = "Arrow! \5 \p2\r-1 Arrow! \5\r1 That's \p-6 his \p7\r-2 name, \p0\r3 right? \7 \r-2 Arrow! \r0 Play piano arrow! \7 \p5 Lots \p-5 of \p-6\r1 Dalmations are \r-2 deaf, \r3\p-5 you know. \5 \p8 Maybe \p4 he's \p-2 deaf!"
Dim AnnaSays20 : AnnaSays20 = "\r-6 Um, \r-5\p9 blah \r-4\p1 blah \r-3\p-9 blah \r0\p8 \9 what's the \r-3 song \r-2 \p-5 here. \5 \r-8 \p9 " & SongTitle & "! \p10 \r0 By \p10\r-9 " & SongArtist & "! \6 \r2 \p-9 Like \r-10\p6 I \p-7\r0 know."
Dim AnnaSays21 : AnnaSays21 = "OK, " & SongTitle & " \4 \p5 " & SongTitle & "\4\p6 " & SongTitle & " \4 \p1\r-2" & SongTitle & "\7\p0\r0 Play piano arrow! "
Dim Sapi
Set Sapi = CreateObject("SAPI.SpVoice")
Sapi.Rate = 0
Sapi.Volume = 100
Randomize
Dim iLower : iLower = 1
Dim iUpper : iUpper = 21
Dim Chaos : Chaos = Int((iUpper - iLower + 1) * Rnd + iLower)
Dim Fun : Fun = Eval("AnnaSays" & Chaos)
Dim ThePhrase
ThePhrase = GetCtrlSpeakText(Fun)
Sapi.speak ThePhrase, 8
Set Sapi = Nothing
End If
End Sub
Sub IntervalCheck
If MenuItem.Checked Then
If SDB.Player.isPlaying And ( SDB.Player.CurrentSongIndex < SDB.Player.PlaylistCount - 1 ) Then
Set IntervalTimer = SDB.CreateTimer(Interval * 1.2)
Script.RegisterEvent IntervalTimer, "OnTimer", "IntervalTimerSub"
End If
If (SDB.Player.CurrentSongIndex = SDB.Player.PlaylistCount - 1) Then
Script.UnRegisterAllEvents
Set IntervalTimer = Nothing
Set GapTimer = Nothing
End If
End If
End Sub
Sub IntervalTimerSub(IntervalTimer)
If SDB.Player.isPlaying Then
If (SDB.Player.CurrentSong.SongLength - SDB.Player.PlaybackTime) < ( Interval * 2 ) Then ' And (SDB.Player.PlaybackTime > Interval)
Script.UnregisterEvents IntervalTimer
Set IntervalTimer = Nothing
SDB.Player.StopAfterCurrent = True
GetForm
End If
End If
End Sub
Sub GapTimerSub(GapTimer)
If (Not SDB.Player.isPlaying) Then
SDB.Player.PlaybackTime = 0
SDB.Player.Play
End If
Script.UnregisterEvents GapTimer
End Sub
Sub WePressedIt()
GetForm.Common.Visible = False
Dim remaining
remaining = (SDB.Player.CurrentSong.SongLength - SDB.Player.PlaybackTime) - 800 ' 800 is a correction for wierd delay
If remaining > ( (Interval * 2) - 800 ) Or remaining < 0 Then
remaining = 0
End If
Set GapTimer = SDB.CreateTimer(remaining + Gap)
Script.RegisterEvent GapTimer, "OnTimer", "GapTimerSub"
End Sub
Sub WerePausing '(IntervalTimer)
If MenuItem.Checked Then
If SDB.Player.isPlaying Then
Call IntervalCheck
End If
If SDB.Player.isPaused Then
Script.UnregisterEvents IntervalTimer
Set IntervalTimer = Nothing
End If
End If
End Sub
Sub WereStopping '(IntervalTimer)
If MenuItem.Checked Then
Script.UnregisterEvents IntervalTimer
Set IntervalTimer = Nothing
Script.UnRegisterAllEvents
End If
End Sub
Function GetForm
Set GetForm = SDB.Objects("KaraokeBox_Form")
Dim Webby
Dim result
Dim TheContent
Dim TheWorks
Set GetForm = SDB.UI.NewForm
GetForm.Common.SetRect 200, 200, 1530, 585
GetForm.BorderStyle = 2 ' 3 = Resizable
GetForm.FormPosition = 4 ' Screen Center
GetForm.StayOnTop = True
GetForm.Common.Visible = True
GetForm.SavePositionName = "KaraokeBox_Form"
GetForm.Caption = "Your Karaoke pleasure is ready, at your convenience..."
Set SDB.Objects("KaraokeBox_Form") = GetForm
Set Webby = SDB.UI.NewActiveX(GetForm, "Shell.Explorer")
'Webby.Common.SetRect 0, 0, 1500, 500
Webby.Common.ClientHeight = GetForm.Common.ClientHeight ' this is a test
Webby.Common.ClientWidth = GetForm.Common.ClientWidth ' this is a test
Webby.Common.Anchors = 15 '1 + 2 + 4+8 ' 15...test??
Webby.Common.ControlName = "Webby"
Set NextSong = SDB.Player.PlaylistItems(SDB.Player.CurrentSongIndex + 1)
NextArtist = NextSong.ArtistName
NextTitle = NextSong.Title
If NextSong.AlbumArt.Count > 0 Then
Dim CoverTmp, CoverSize, CoverTmpFile, CoverObject, CoverFile
Set CoverObject = NextSong.AlbumArt.Item(0)
CoverSize = 350
Set CoverTmp = CoverObject.Image.ConvertFormatEx(CoverSize, CoverSize, "image/jpeg", 100, 0, 0)
CoverFile = SDB.TemporaryFolder & "tmpCoverResize.jpg"
Set CoverTmpFile = SDB.Tools.FileSystem.CreateTextFile(CoverFile, True)
CoverTmpFile.WriteData CoverTmp.ImageData, CoverTmp.ImageDataLen
CoverTmpFile.Close
End If
Set TheContent = New Page
TheContent.Add "<!DOCTYPE html>"
TheContent.Add "<html>"
TheContent.Add "<head>"
TheContent.Add "</head>"
TheContent.Add "<body style=""background-color:#000; font-family:Verdana; font-size:36px; color:#FC3; text-align:center;"">"
TheContent.Add "<div style=""height:480px; width:1440px; padding:40px,40px; padding-Right:40px;"">"
TheContent.Add "<div STYLE=""float:right; width:360px; height:390px; padding-top:30px"">"
TheContent.Add "<div STYLE=""width:350px; height:350px;"">"
TheContent.Add "<img src='" & CoverFile & "'>"
TheContent.Add "</div>"
TheContent.Add "</div>"
TheContent.Add "<div STYLE=""float:Left; width:70%; height:450px; padding:20px,20px; padding-Left:40px;"">"
TheContent.Add "<div STYLE=""width:90%; height:80px; padding-top:10px; font-style:italic; text-align:left;"">"
TheContent.Add "THE NEXT SONG IS:"
TheContent.Add "</div>"
TheContent.Add "<div STYLE=""width:98%; height:120px; padding-top:40px; font-size:60px; font-weight:bold;"">"
TheContent.Add NextTitle
TheContent.Add "</div>"
TheContent.Add "<div STYLE=""width:98%; height:30px; padding-top:20px; font-size:24px; font-weight:bold; font-style:italic"">"
TheContent.Add " as once performed by the soon to be unnecessary:"
TheContent.Add "</div>"
TheContent.Add "<div STYLE=""width:98%; height:60px; padding-top:20px; font-size:36px; font-weight:bold;"">"
TheContent.Add NextArtist
TheContent.Add "</div>"
TheContent.Add "<div STYLE=""width:98%; height:40px; padding-top:15px; font-size:24px;"">"
Dim Btn : Set Btn = SDB.UI.NewButton(GetForm)
Btn.Caption = SDB.Localize("OK, I'M READY TO SING!")
Btn.Common.SetRect 270, 410, 560, 45
Btn.Common.Anchors = 4 + 8
Script.RegisterEvent Btn, "OnClick", "WePressedIt"
TheContent.Add "</div>"
TheContent.Add "</div>"
TheContent.Add "</div>"
TheContent.Add "</body>"
TheContent.Add "</html>"
TheWorks = TheContent.Content
Webby.SetHTMLDocument(TheWorks)
'End If
End Function
Class Page ' part of effort to get html, tool this some?
Dim KaraTable, KaraAddRows, KaraRow
Private Sub Class_Initialize()
KaraAddRows = 50
KaraRow = 0
ReDim KaraTable(KaraAddRows)
End Sub
Public Sub Add(Line)
If KaraRow > UBound(KaraTable) Then ReDim Preserve KaraTable(UBound(KaraTable) + KaraAddRows)
KaraTable(KaraRow) = Line
KaraRow = KaraRow + 1
End Sub
Public Function Content
Content = Join(KaraTable, vbNewLine)
End Function
End Class
Sub MenuItem_OnClick(Button)
Button.Checked = Not Button.Checked
End Sub
Function GetCtrlSpeakText(ByVal Str)
Dim out
Dim numstr
out = Str
out = Replace(out, "\22", "<silence msec= '2200'/>", 1, -1, 0) ' \# = pause
out = Replace(out, "\20", "<silence msec= '2000'/>", 1, -1, 0)
out = Replace(out, "\18", "<silence msec= '1800'/>", 1, -1, 0)
out = Replace(out, "\16", "<silence msec= '1600'/>", 1, -1, 0)
out = Replace(out, "\14", "<silence msec= '1400'/>", 1, -1, 0)
out = Replace(out, "\12", "<silence msec= '1200'/>", 1, -1, 0)
out = Replace(out, "\10", "<silence msec= '1000'/>", 1, -1, 0)
out = Replace(out, "\9", "<silence msec= '900'/>", 1, -1, 0)
out = Replace(out, "\8", "<silence msec= '800'/>", 1, -1, 0)
out = Replace(out, "\7", "<silence msec= '700'/>", 1, -1, 0)
out = Replace(out, "\6", "<silence msec= '600'/>", 1, -1, 0)
out = Replace(out, "\5", "<silence msec= '500'/>", 1, -1, 0)
out = Replace(out, "\4", "<silence msec= '400'/>", 1, -1, 0)
out = Replace(out, "\3", "<silence msec= '300'/>", 1, -1, 0)
out = Replace(out, "\2", "<silence msec= '200'/>", 1, -1, 0)
out = Replace(out, "\1", "<silence msec= '100'/>", 1, -1, 0)
out = Replace(out, "/e", "</emph>", 1, -1, 0)
out = Replace(out, "\e", "<emph>", 1, -1, 0)
out = Replace(out, "/r", "</rate>", 1, -1, 0)
out = Replace(out, "\r10", "<rate absspeed=""10"">", 1, -1, 0) ' \r# for rate -10 to 10
out = Replace(out, "\r9", "<rate absspeed=""9"">", 1, -1, 0)
out = Replace(out, "\r8", "<rate absspeed=""8"">", 1, -1, 0)
out = Replace(out, "\r7", "<rate absspeed=""7"">", 1, -1, 0)
out = Replace(out, "\r6", "<rate absspeed=""6"">", 1, -1, 0)
out = Replace(out, "\r5", "<rate absspeed=""5"">", 1, -1, 0)
out = Replace(out, "\r4", "<rate absspeed=""4"">", 1, -1, 0)
out = Replace(out, "\r3", "<rate absspeed=""3"">", 1, -1, 0)
out = Replace(out, "\r2", "<rate absspeed=""2"">", 1, -1, 0)
out = Replace(out, "\r1", "<rate absspeed=""1"">", 1, -1, 0)
out = Replace(out, "\r0", "<rate absspeed=""0"">", 1, -1, 0)
out = Replace(out, "\r-10", "<rate absspeed=""-10"">", 1, -1, 0)
out = Replace(out, "\r-9", "<rate absspeed=""-9"">", 1, -1, 0)
out = Replace(out, "\r-8", "<rate absspeed=""-8"">", 1, -1, 0)
out = Replace(out, "\r-7", "<rate absspeed=""-7"">", 1, -1, 0)
out = Replace(out, "\r-6", "<rate absspeed=""-6"">", 1, -1, 0)
out = Replace(out, "\r-5", "<rate absspeed=""-5"">", 1, -1, 0)
out = Replace(out, "\r-4", "<rate absspeed=""-4"">", 1, -1, 0)
out = Replace(out, "\r-3", "<rate absspeed=""-3"">", 1, -1, 0)
out = Replace(out, "\r-2", "<rate absspeed=""-2"">", 1, -1, 0)
out = Replace(out, "\r-1", "<rate absspeed=""-1"">", 1, -1, 0)
out = Replace(out, "/p", "</pitch>", 1, -1, 0)
out = Replace(out, "\p10", "<pitch absmiddle=""10"">", 1, -1, 0) ' \p# for pitch -10 to 10
out = Replace(out, "\p9", "<pitch absmiddle=""9"">", 1, -1, 0)
out = Replace(out, "\p8", "<pitch absmiddle=""8"">", 1, -1, 0)
out = Replace(out, "\p7", "<pitch absmiddle=""7"">", 1, -1, 0)
out = Replace(out, "\p6", "<pitch absmiddle=""6"">", 1, -1, 0)
out = Replace(out, "\p5", "<pitch absmiddle=""5"">", 1, -1, 0)
out = Replace(out, "\p4", "<pitch absmiddle=""4"">", 1, -1, 0)
out = Replace(out, "\p3", "<pitch absmiddle=""3"">", 1, -1, 0)
out = Replace(out, "\p2", "<pitch absmiddle=""2"">", 1, -1, 0)
out = Replace(out, "\p1", "<pitch absmiddle=""1"">", 1, -1, 0)
out = Replace(out, "\p0", "<pitch absmiddle=""0"">", 1, -1, 0)
out = Replace(out, "\p-10", "<pitch absmiddle=""-10"">", 1, -1, 0)
out = Replace(out, "\p-9", "<pitch absmiddle=""-9"">", 1, -1, 0)
out = Replace(out, "\p-8", "<pitch absmiddle=""-8"">", 1, -1, 0)
out = Replace(out, "\p-7", "<pitch absmiddle=""-7"">", 1, -1, 0)
out = Replace(out, "\p-6", "<pitch absmiddle=""-6"">", 1, -1, 0)
out = Replace(out, "\p-5", "<pitch absmiddle=""-5"">", 1, -1, 0)
out = Replace(out, "\p-4", "<pitch absmiddle=""-4"">", 1, -1, 0)
out = Replace(out, "\p-3", "<pitch absmiddle=""-3"">", 1, -1, 0)
out = Replace(out, "\p-2", "<pitch absmiddle=""-2"">", 1, -1, 0)
out = Replace(out, "\p-1", "<pitch absmiddle=""-1"">", 1, -1, 0)
out = Replace(out, "/v", "</volume>", 1, -1, 0)
out = Replace(out, "\v10", "<volume level=""100"">", 1, -1, 0) ' \v# for volume 10 to 100
out = Replace(out, "\v9", "<volume level=""90"">", 1, -1, 0)
out = Replace(out, "\v8", "<volume level=""80"">", 1, -1, 0)
out = Replace(out, "\v7", "<volume level=""70"">", 1, -1, 0)
out = Replace(out, "\v6", "<volume level=""60"">", 1, -1, 0)
out = Replace(out, "\v5", "<volume level=""50"">", 1, -1, 0)
out = Replace(out, "\v4", "<volume level=""40"">", 1, -1, 0)
out = Replace(out, "\v3", "<volume level=""30"">", 1, -1, 0)
out = Replace(out, "\v2", "<volume level=""20"">", 1, -1, 0)
out = Replace(out, "\v1", "<volume level=""10"">", 1, -1, 0)
GetCtrlSpeakText = out
End Function
I'm not sure I know what you mean; isn't EVERY timer created as an object?
And yes, I am seeking to cancel a SPECIFIC timer; if a button is pressed in a popup before the song ends. Not being able to cancel the specific timer has a convoluted solution (though I have the script working at this point).
Below is the script in working state (if less than perfect) . Maybe someone spots superior solutions or absent error handling!
This is a [u]KARAOKE TRANSITION SCRIPT[/u]:
before the current song in the 'NOW PLAYING' list ends, a popup announces the next song.
There is a button. The next song will not start unless the button is pressed.
There is then a 3 second gap before the next song.
After checking out your scripts, Mr Weichert, It struck me that I should borrow your inspiration of your "Speak Song Title" script. So I have studied and mimicked your examples and implimented a voice that will come after a few seconds, if no one presses the button (to harrass the singers who aren't paying attention). I'm amazed how simple it is to implement the SAPI voice, though was frustrated with how hard it is to get it to be intelligable! Anyone who doesn't carve out that function will have to personalize the messages themselves. Its a pain, but it IS pretty funny. I should credit Steegy as his RatePlayedSong actually began as the framework. I should credit others too, if I knew who to credit, as mostly i'm copying someone's elses example!
[code]
'====================================================================================
' DCM KARAOKE ANNOUNCER - when a song is ending, announces next, pauses and asks for permission to continue
' put in AUTO scripts folder
'================================================================ !!!!!TEST FOR "NO PHOTO" FAILURE!
Option Explicit
Dim MenuItem, NextOne, PreviousSong, IntervalTimer, GapTimer, AnnaTimer
Dim NextSong
Dim NextArtist
Dim NextTitle
Const Gap = 3000 ' tweak here (milliseconds)
Const Interval = 6000 ' tweak here (milliseconds)
''Const MenuItemOn = True
'Dim MenuItemOn
Sub OnStartup
Set MenuItem = SDB.UI.AddMenuItem(SDB.UI.Menu_TBStandard, 0, 0)
MenuItem.IconIndex = 2
MenuItem.Caption = "Karaoke Transition Box"
MenuItem.Checked = False
Script.RegisterEvent MenuItem, "OnClick", "MenuItem_OnClick"
Script.RegisterEvent SDB, "OnPlay", "IntervalCheck"
Script.RegisterEvent SDB, "OnStop", "WereStopping"
Script.RegisterEvent SDB, "OnPause", "WerePausing"
Script.RegisterEvent SDB, "OnTrackEnd", "SpeakAnna"
End Sub
Sub SpeakAnna
If ( SDB.Player.CurrentSongIndex < SDB.Player.PlaylistCount - 1 ) Then
Set AnnaTimer = SDB.CreateTimer(5000)
Script.RegisterEvent AnnaTimer, "OnTimer", "AnnaTimerSub"
End If
End Sub
Sub AnnaTimerSub(AnnaTimer)
AnnaTimer.Enabled = False
Script.UnRegisterEvents AnnaTimer
Set AnnaTimer = Nothing
If Not SDB.Player.isPlaying Then
Dim SongTitle : SongTitle = SDB.Player.CurrentSong.Title
Dim SongArtist : SongArtist = SDB.Player.CurrentSong.ArtistName
Dim AnnaSays1 : AnnaSays1 = "\r-2 I \p4\r-4 mean,\r-5\p2 for \p-3 the \r-7\p9\e love/e \r-7\v7\p-8 of. \3 \v10 \r0 \p1Who \p-2\r-2owns \r0 the \p0 song, " & SongTitle & "? \5 \p2 \r-6 Folks?"
Dim AnnaSays2 : AnnaSays2 = "\r-7Yo!\4 \r-3 Who gonna \r-5 sing? \3 \p7" & SongTitle & ". \4 " & SongTitle & "!"
Dim AnnaSays3 : AnnaSays3 = "Dog playin piano. \3\r-6Crazy,\r0 \p6in \r-10\p10 saine \p-3\r-4 broe. \r0Any who. " & SongTitle & ", \r-1 you're up."
Dim AnnaSays4 : AnnaSays4 = "Someone chose " & SongTitle & ", by " & SongArtist & ". Or, \r-6 \p9 am \r-4\p3 I \r-10\p-4 high?"
Dim AnnaSays5 : AnnaSays5 = "\p-2\r2 ain't no \r-5 skin \r1\p-3 off \r-6\p10 \e my /e \p-5\r0 arse, \p0 if no one wants to claim\r-6 " & SongTitle & "! \r-1 Just\r-5 sayin."
Dim AnnaSays6 : AnnaSays6 = "\r-5\p-8 \e what /e \9\r0\p0 Because, I'm, a \p7\r-4 \e row butt? /e \3\p0\r0 Is that why you \r-4 ignore me? \r0 I, got \p3 " & SongTitle & " \p0 all ready, for who ever \r1 selected \r0 it. \r-2 Any time, \r-5\p9\3 Oh \p-5 Kay"
Dim AnnaSays7 : AnnaSays7 = "\r0 whats the \r-2 problem?\3 "
Dim AnnaSays8 : AnnaSays8 = "\r-6 \p-8 I'm\r-1 in\p7\evisible/e\r-4 over \p5 here? \5 \p-2 \r-3 or \p-10 \e \r-6 what? /e " '
Dim AnnaSays9 : AnnaSays9 = "Waiting For \r-5\e\p7some/e \p1one, \r-1 \p0To sing \p7 \r-4" & SongTitle & ", \p-7\r-1by \p3 \r-5 " & SongArtist & "!"
Dim AnnaSays10 : AnnaSays10 = "You're scaring me \r-2\p-4people. \p0 \1 Are \1 our \r0 attention spans \r-2 \p9 that, \p0 \r0 short? Really? Who picked \e " & SongTitle & "?/e Come on."
Dim AnnaSays11 : AnnaSays11 = "Calling the \p3 \e song \p0\r-3 stir \r0/e \2 who chose \r-2 " & SongTitle & ""
Dim AnnaSays12 : AnnaSays12 = "Well, \r-3\p5SOMEBODY \p0\r0 picked \r-2\e " & SongTitle & "/e. \r0\4 Are \r-3 we \r-4 in the \p4 \r-3 toilet. \p0 \3 \r-6 Hello,"
Dim AnnaSays13 : AnnaSays13 = "Is that \r-5\edog/e \r0 playing PIANO? seriously? Well, \r-1\p-2anyway, \r0\p0 someone was going to sing " & SongTitle & ""
Dim AnnaSays14 : AnnaSays14 = " \r-10 \p-7 <pron sym=""p ah l""/> /p\p10 <pron sym=""l iy - iy - iy z""/> /p/r"
Dim AnnaSays15 : AnnaSays15 = "OK, in five seconds, if nobody else starts \p-9 singing \r-3\p-9\3 ohhhh \r4 \p0 what's the \r-2 song? \r-1\p-1 " & SongTitle & ", \r0 then, \p10 \r-10 I'm \r4\p-1 going to \p-6\r-1 sing \p-8 it! \2 \r2\p5 You want that? \4 \r0\p-2 No!\r1 I didn't \p4\r-2 \e think /e\p-3 so!"
Dim AnnaSays16 : AnnaSays16 = " \r-6 please. \r-8\p4 Please! \r-10 \p10 <pron sym=""l iy - 1 iy 1 - iy - iy - iy - iy - iy - iy z""/> /v/p/r"
Dim AnnaSays17 : AnnaSays17 = "\r-10 NEXT! NEXT! <pron sym=""n eh k k k k k - k s t""/>\4 \p5Oh, \r-6\p-5 " & SongTitle & "!"
Dim AnnaSays18 : AnnaSays18 = "\p8\r-6 Well \p-10\r-3 shit, \p5 \r0 what \p-7\r-10 ever. \r-4 \p0 go \r-2\p-4baby, \5\r-2\p10 " & SongTitle & ". \4 By \p3 \r-5 " & SongArtist
Dim AnnaSays19 : AnnaSays19 = "Arrow! \5 \p2\r-1 Arrow! \5\r1 That's \p-6 his \p7\r-2 name, \p0\r3 right? \7 \r-2 Arrow! \r0 Play piano arrow! \7 \p5 Lots \p-5 of \p-6\r1 Dalmations are \r-2 deaf, \r3\p-5 you know. \5 \p8 Maybe \p4 he's \p-2 deaf!"
Dim AnnaSays20 : AnnaSays20 = "\r-6 Um, \r-5\p9 blah \r-4\p1 blah \r-3\p-9 blah \r0\p8 \9 what's the \r-3 song \r-2 \p-5 here. \5 \r-8 \p9 " & SongTitle & "! \p10 \r0 By \p10\r-9 " & SongArtist & "! \6 \r2 \p-9 Like \r-10\p6 I \p-7\r0 know."
Dim AnnaSays21 : AnnaSays21 = "OK, " & SongTitle & " \4 \p5 " & SongTitle & "\4\p6 " & SongTitle & " \4 \p1\r-2" & SongTitle & "\7\p0\r0 Play piano arrow! "
Dim Sapi
Set Sapi = CreateObject("SAPI.SpVoice")
Sapi.Rate = 0
Sapi.Volume = 100
Randomize
Dim iLower : iLower = 1
Dim iUpper : iUpper = 21
Dim Chaos : Chaos = Int((iUpper - iLower + 1) * Rnd + iLower)
Dim Fun : Fun = Eval("AnnaSays" & Chaos)
Dim ThePhrase
ThePhrase = GetCtrlSpeakText(Fun)
Sapi.speak ThePhrase, 8
Set Sapi = Nothing
End If
End Sub
Sub IntervalCheck
If MenuItem.Checked Then
If SDB.Player.isPlaying And ( SDB.Player.CurrentSongIndex < SDB.Player.PlaylistCount - 1 ) Then
Set IntervalTimer = SDB.CreateTimer(Interval * 1.2)
Script.RegisterEvent IntervalTimer, "OnTimer", "IntervalTimerSub"
End If
If (SDB.Player.CurrentSongIndex = SDB.Player.PlaylistCount - 1) Then
Script.UnRegisterAllEvents
Set IntervalTimer = Nothing
Set GapTimer = Nothing
End If
End If
End Sub
Sub IntervalTimerSub(IntervalTimer)
If SDB.Player.isPlaying Then
If (SDB.Player.CurrentSong.SongLength - SDB.Player.PlaybackTime) < ( Interval * 2 ) Then ' And (SDB.Player.PlaybackTime > Interval)
Script.UnregisterEvents IntervalTimer
Set IntervalTimer = Nothing
SDB.Player.StopAfterCurrent = True
GetForm
End If
End If
End Sub
Sub GapTimerSub(GapTimer)
If (Not SDB.Player.isPlaying) Then
SDB.Player.PlaybackTime = 0
SDB.Player.Play
End If
Script.UnregisterEvents GapTimer
End Sub
Sub WePressedIt()
GetForm.Common.Visible = False
Dim remaining
remaining = (SDB.Player.CurrentSong.SongLength - SDB.Player.PlaybackTime) - 800 ' 800 is a correction for wierd delay
If remaining > ( (Interval * 2) - 800 ) Or remaining < 0 Then
remaining = 0
End If
Set GapTimer = SDB.CreateTimer(remaining + Gap)
Script.RegisterEvent GapTimer, "OnTimer", "GapTimerSub"
End Sub
Sub WerePausing '(IntervalTimer)
If MenuItem.Checked Then
If SDB.Player.isPlaying Then
Call IntervalCheck
End If
If SDB.Player.isPaused Then
Script.UnregisterEvents IntervalTimer
Set IntervalTimer = Nothing
End If
End If
End Sub
Sub WereStopping '(IntervalTimer)
If MenuItem.Checked Then
Script.UnregisterEvents IntervalTimer
Set IntervalTimer = Nothing
Script.UnRegisterAllEvents
End If
End Sub
Function GetForm
Set GetForm = SDB.Objects("KaraokeBox_Form")
Dim Webby
Dim result
Dim TheContent
Dim TheWorks
Set GetForm = SDB.UI.NewForm
GetForm.Common.SetRect 200, 200, 1530, 585
GetForm.BorderStyle = 2 ' 3 = Resizable
GetForm.FormPosition = 4 ' Screen Center
GetForm.StayOnTop = True
GetForm.Common.Visible = True
GetForm.SavePositionName = "KaraokeBox_Form"
GetForm.Caption = "Your Karaoke pleasure is ready, at your convenience..."
Set SDB.Objects("KaraokeBox_Form") = GetForm
Set Webby = SDB.UI.NewActiveX(GetForm, "Shell.Explorer")
'Webby.Common.SetRect 0, 0, 1500, 500
Webby.Common.ClientHeight = GetForm.Common.ClientHeight ' this is a test
Webby.Common.ClientWidth = GetForm.Common.ClientWidth ' this is a test
Webby.Common.Anchors = 15 '1 + 2 + 4+8 ' 15...test??
Webby.Common.ControlName = "Webby"
Set NextSong = SDB.Player.PlaylistItems(SDB.Player.CurrentSongIndex + 1)
NextArtist = NextSong.ArtistName
NextTitle = NextSong.Title
If NextSong.AlbumArt.Count > 0 Then
Dim CoverTmp, CoverSize, CoverTmpFile, CoverObject, CoverFile
Set CoverObject = NextSong.AlbumArt.Item(0)
CoverSize = 350
Set CoverTmp = CoverObject.Image.ConvertFormatEx(CoverSize, CoverSize, "image/jpeg", 100, 0, 0)
CoverFile = SDB.TemporaryFolder & "tmpCoverResize.jpg"
Set CoverTmpFile = SDB.Tools.FileSystem.CreateTextFile(CoverFile, True)
CoverTmpFile.WriteData CoverTmp.ImageData, CoverTmp.ImageDataLen
CoverTmpFile.Close
End If
Set TheContent = New Page
TheContent.Add "<!DOCTYPE html>"
TheContent.Add "<html>"
TheContent.Add "<head>"
TheContent.Add "</head>"
TheContent.Add "<body style=""background-color:#000; font-family:Verdana; font-size:36px; color:#FC3; text-align:center;"">"
TheContent.Add "<div style=""height:480px; width:1440px; padding:40px,40px; padding-Right:40px;"">"
TheContent.Add "<div STYLE=""float:right; width:360px; height:390px; padding-top:30px"">"
TheContent.Add "<div STYLE=""width:350px; height:350px;"">"
TheContent.Add "<img src='" & CoverFile & "'>"
TheContent.Add "</div>"
TheContent.Add "</div>"
TheContent.Add "<div STYLE=""float:Left; width:70%; height:450px; padding:20px,20px; padding-Left:40px;"">"
TheContent.Add "<div STYLE=""width:90%; height:80px; padding-top:10px; font-style:italic; text-align:left;"">"
TheContent.Add "THE NEXT SONG IS:"
TheContent.Add "</div>"
TheContent.Add "<div STYLE=""width:98%; height:120px; padding-top:40px; font-size:60px; font-weight:bold;"">"
TheContent.Add NextTitle
TheContent.Add "</div>"
TheContent.Add "<div STYLE=""width:98%; height:30px; padding-top:20px; font-size:24px; font-weight:bold; font-style:italic"">"
TheContent.Add " as once performed by the soon to be unnecessary:"
TheContent.Add "</div>"
TheContent.Add "<div STYLE=""width:98%; height:60px; padding-top:20px; font-size:36px; font-weight:bold;"">"
TheContent.Add NextArtist
TheContent.Add "</div>"
TheContent.Add "<div STYLE=""width:98%; height:40px; padding-top:15px; font-size:24px;"">"
Dim Btn : Set Btn = SDB.UI.NewButton(GetForm)
Btn.Caption = SDB.Localize("OK, I'M READY TO SING!")
Btn.Common.SetRect 270, 410, 560, 45
Btn.Common.Anchors = 4 + 8
Script.RegisterEvent Btn, "OnClick", "WePressedIt"
TheContent.Add "</div>"
TheContent.Add "</div>"
TheContent.Add "</div>"
TheContent.Add "</body>"
TheContent.Add "</html>"
TheWorks = TheContent.Content
Webby.SetHTMLDocument(TheWorks)
'End If
End Function
Class Page ' part of effort to get html, tool this some?
Dim KaraTable, KaraAddRows, KaraRow
Private Sub Class_Initialize()
KaraAddRows = 50
KaraRow = 0
ReDim KaraTable(KaraAddRows)
End Sub
Public Sub Add(Line)
If KaraRow > UBound(KaraTable) Then ReDim Preserve KaraTable(UBound(KaraTable) + KaraAddRows)
KaraTable(KaraRow) = Line
KaraRow = KaraRow + 1
End Sub
Public Function Content
Content = Join(KaraTable, vbNewLine)
End Function
End Class
Sub MenuItem_OnClick(Button)
Button.Checked = Not Button.Checked
End Sub
Function GetCtrlSpeakText(ByVal Str)
Dim out
Dim numstr
out = Str
out = Replace(out, "\22", "<silence msec= '2200'/>", 1, -1, 0) ' \# = pause
out = Replace(out, "\20", "<silence msec= '2000'/>", 1, -1, 0)
out = Replace(out, "\18", "<silence msec= '1800'/>", 1, -1, 0)
out = Replace(out, "\16", "<silence msec= '1600'/>", 1, -1, 0)
out = Replace(out, "\14", "<silence msec= '1400'/>", 1, -1, 0)
out = Replace(out, "\12", "<silence msec= '1200'/>", 1, -1, 0)
out = Replace(out, "\10", "<silence msec= '1000'/>", 1, -1, 0)
out = Replace(out, "\9", "<silence msec= '900'/>", 1, -1, 0)
out = Replace(out, "\8", "<silence msec= '800'/>", 1, -1, 0)
out = Replace(out, "\7", "<silence msec= '700'/>", 1, -1, 0)
out = Replace(out, "\6", "<silence msec= '600'/>", 1, -1, 0)
out = Replace(out, "\5", "<silence msec= '500'/>", 1, -1, 0)
out = Replace(out, "\4", "<silence msec= '400'/>", 1, -1, 0)
out = Replace(out, "\3", "<silence msec= '300'/>", 1, -1, 0)
out = Replace(out, "\2", "<silence msec= '200'/>", 1, -1, 0)
out = Replace(out, "\1", "<silence msec= '100'/>", 1, -1, 0)
out = Replace(out, "/e", "</emph>", 1, -1, 0)
out = Replace(out, "\e", "<emph>", 1, -1, 0)
out = Replace(out, "/r", "</rate>", 1, -1, 0)
out = Replace(out, "\r10", "<rate absspeed=""10"">", 1, -1, 0) ' \r# for rate -10 to 10
out = Replace(out, "\r9", "<rate absspeed=""9"">", 1, -1, 0)
out = Replace(out, "\r8", "<rate absspeed=""8"">", 1, -1, 0)
out = Replace(out, "\r7", "<rate absspeed=""7"">", 1, -1, 0)
out = Replace(out, "\r6", "<rate absspeed=""6"">", 1, -1, 0)
out = Replace(out, "\r5", "<rate absspeed=""5"">", 1, -1, 0)
out = Replace(out, "\r4", "<rate absspeed=""4"">", 1, -1, 0)
out = Replace(out, "\r3", "<rate absspeed=""3"">", 1, -1, 0)
out = Replace(out, "\r2", "<rate absspeed=""2"">", 1, -1, 0)
out = Replace(out, "\r1", "<rate absspeed=""1"">", 1, -1, 0)
out = Replace(out, "\r0", "<rate absspeed=""0"">", 1, -1, 0)
out = Replace(out, "\r-10", "<rate absspeed=""-10"">", 1, -1, 0)
out = Replace(out, "\r-9", "<rate absspeed=""-9"">", 1, -1, 0)
out = Replace(out, "\r-8", "<rate absspeed=""-8"">", 1, -1, 0)
out = Replace(out, "\r-7", "<rate absspeed=""-7"">", 1, -1, 0)
out = Replace(out, "\r-6", "<rate absspeed=""-6"">", 1, -1, 0)
out = Replace(out, "\r-5", "<rate absspeed=""-5"">", 1, -1, 0)
out = Replace(out, "\r-4", "<rate absspeed=""-4"">", 1, -1, 0)
out = Replace(out, "\r-3", "<rate absspeed=""-3"">", 1, -1, 0)
out = Replace(out, "\r-2", "<rate absspeed=""-2"">", 1, -1, 0)
out = Replace(out, "\r-1", "<rate absspeed=""-1"">", 1, -1, 0)
out = Replace(out, "/p", "</pitch>", 1, -1, 0)
out = Replace(out, "\p10", "<pitch absmiddle=""10"">", 1, -1, 0) ' \p# for pitch -10 to 10
out = Replace(out, "\p9", "<pitch absmiddle=""9"">", 1, -1, 0)
out = Replace(out, "\p8", "<pitch absmiddle=""8"">", 1, -1, 0)
out = Replace(out, "\p7", "<pitch absmiddle=""7"">", 1, -1, 0)
out = Replace(out, "\p6", "<pitch absmiddle=""6"">", 1, -1, 0)
out = Replace(out, "\p5", "<pitch absmiddle=""5"">", 1, -1, 0)
out = Replace(out, "\p4", "<pitch absmiddle=""4"">", 1, -1, 0)
out = Replace(out, "\p3", "<pitch absmiddle=""3"">", 1, -1, 0)
out = Replace(out, "\p2", "<pitch absmiddle=""2"">", 1, -1, 0)
out = Replace(out, "\p1", "<pitch absmiddle=""1"">", 1, -1, 0)
out = Replace(out, "\p0", "<pitch absmiddle=""0"">", 1, -1, 0)
out = Replace(out, "\p-10", "<pitch absmiddle=""-10"">", 1, -1, 0)
out = Replace(out, "\p-9", "<pitch absmiddle=""-9"">", 1, -1, 0)
out = Replace(out, "\p-8", "<pitch absmiddle=""-8"">", 1, -1, 0)
out = Replace(out, "\p-7", "<pitch absmiddle=""-7"">", 1, -1, 0)
out = Replace(out, "\p-6", "<pitch absmiddle=""-6"">", 1, -1, 0)
out = Replace(out, "\p-5", "<pitch absmiddle=""-5"">", 1, -1, 0)
out = Replace(out, "\p-4", "<pitch absmiddle=""-4"">", 1, -1, 0)
out = Replace(out, "\p-3", "<pitch absmiddle=""-3"">", 1, -1, 0)
out = Replace(out, "\p-2", "<pitch absmiddle=""-2"">", 1, -1, 0)
out = Replace(out, "\p-1", "<pitch absmiddle=""-1"">", 1, -1, 0)
out = Replace(out, "/v", "</volume>", 1, -1, 0)
out = Replace(out, "\v10", "<volume level=""100"">", 1, -1, 0) ' \v# for volume 10 to 100
out = Replace(out, "\v9", "<volume level=""90"">", 1, -1, 0)
out = Replace(out, "\v8", "<volume level=""80"">", 1, -1, 0)
out = Replace(out, "\v7", "<volume level=""70"">", 1, -1, 0)
out = Replace(out, "\v6", "<volume level=""60"">", 1, -1, 0)
out = Replace(out, "\v5", "<volume level=""50"">", 1, -1, 0)
out = Replace(out, "\v4", "<volume level=""40"">", 1, -1, 0)
out = Replace(out, "\v3", "<volume level=""30"">", 1, -1, 0)
out = Replace(out, "\v2", "<volume level=""20"">", 1, -1, 0)
out = Replace(out, "\v1", "<volume level=""10"">", 1, -1, 0)
GetCtrlSpeakText = out
End Function
[/code]