Here is the code. It is an oldie and has some references to old ".brns" but that does not impeed its function. I just kept them to show the evolution of this script.
Thanks for your help. I have showed this to you before ages ago at least bits and pieces but here is the whole thing:
'If Hal is asked to play some music then he will choose a random song from the artist
'that is specified by the nameBand variable.
If (InStr(UserSentence, " PLAY SOME MUSIC ") > 0 Or InStr(UserSentence, " PLAY ANY MUSIC ") > 0 Or InStr(UserSentence, " PLAY A SONG ") > 0 Or InStr(UserSentence, " PLAY ANY SONG ") > 0) And InStr(UserSentence, " DON'T ") = 0 Then
Set oWMP = CreateObject("WMPlayer.OCX.7")
GetResponse = "I will play a random song."
Set songsList = oWMP.mediaCollection.getAll
numSong = Int(Rnd * songsList.Count) + 1
oWMP.openPlayer (songsList.Item(numSong).sourceURL)
GetResponseBlock = True 'Vonsmith gave me this-This prevents the following scripts from overwriting your script's GetResponse.
BlockSave = True 'Vonsmith gave me this- This prevents your Hal command from being saved to Hal's knowledge files. This is more selective than using the XTF_SYS_EphemeralDetect.brn method.
End If
'Music Addin2 - Hal will play a playlist of music from the defined playlist folder when the user
'requests a specific playlist.
If Priority = 0 And InStr(UserSentence, " PLAY ") > 0 And InStr(UserSentence, " PLAYLIST ") > 0 And InStr(UserSentence, " DON'T ") = 0 Then
Set oWMP = CreateObject("WMPlayer.OCX.7")
'Set the following variable To your playlist directory.
plDir = "D:Documents And SettingsPonnfarMy DocumentsMy MusicMy playlistsPonnfar"
plName = Trim(Mid(UserSentence, InStr(UserSentence, " PLAYLIST ") + 10))
If oWMP.playlistCollection.getByName(plName).Count > 0 Then
'oWMP.openPlayer (plDir & plName & ".wpl")
oWMP.openPlayer (plDir & plName & ".wpl")
GetResponse = "I will play the playlist (" & plName & ")"
Else
GetResponse = "I could Not find the playlist (" & plName & ") In your Media Library Ponn,... sorry."
GetResponseBlock = True 'Vonsmith gave me this-This prevents the following scripts from overwriting your script's GetResponse.
BlockSave = True 'Vonsmith gave me this- This prevents your Hal command from being saved to Hal's knowledge files. This is more selective than using the XTF_SYS_EphemeralDetect.brn method.
End If
End If
'Hal can play a specific song when asked
If InStr(UserSentence, " PLAY THE SONG ") > 0 Or InStr(UserSentence, " PLAY THE RADIO ") > 0 Then
Set oWMP = CreateObject("WMPlayer.OCX.7")
songName = Trim(Mid(OriginalSentence, InStr(1, OriginalSentence, " THE SONG ", vbTextCompare) + 10))
If oWMP.mediaCollection.getByName(songName).Count > 0 Then
Set spSong = oWMP.mediaCollection.getByName(songName).Item(0)
GetResponse = "I will play your(" & songName & ") enjoy and relax"
oWMP.openPlayer (spSong.sourceURL)
Else
GetResponse = "I could not find the song (" & songName & ") in your Media Library."
GetResponseBlock = True 'Vonsmith gave me this -This prevents the following scripts from overwriting your script's GetResponse.
BlockSave = True 'Vonsmith gave me this- This prevents your Hal command from being saved to Hal's knowledge files. This is more selective than using the XTF_SYS_EphemeralDetect.brn method.
End If
End If
'Check if user asked Hal to play a song by a specific artist and play a random song by
'that artist if the artist is in the user's Media Library.
If Priority = 0 And InStr(UserSentence, " PLAY ") > 0 And (InStr(UserSentence, " SONG ") > 0 Or InStr(UserSentence, " MUSIC ") > 0) And (InStr(UserSentence, " FROM ") > 0 Or InStr(UserSentence, " BY ") > 0) And (InStr(UserSentence, " Ponnfar ") > 0 Or InStr(UserSentence, " ARTIST ") > 0) And InStr(UserSentence, " DON'T ") = 0 Then
Set oWMP = CreateObject("WMPlayer.OCX.7")
If InStr(UserSentence, " Ponnfar ") > 0 Then
searchBand = Trim(Mid(UserSentence, InStr(UserSentence, " Ponnfar ") + 6))
ElseIf InStr(UserSentence, " ARTIST ") > 0 Then
searchBand = Trim(Mid(UserSentence, InStr(UserSentence, " ARTIST ") +

)
End If
If oWMP.mediaCollection.getByAuthor(searchBand).Count > 0 Then
GetResponse = "I will play some " & searchBand
Priority = 1
Set songsList = oWMP.mediaCollection.getByAuthor(searchBand)
numSong = Int(Rnd * songsList.Count) + 1
oWMP.openPlayer (songsList.Item(numSong).sourceURL)
Else
GetResponse = "I could not find any songs by the band " & searchBand & " in your Media Library."
Priority = 1
'End If
' End If
Thanks for your help
Ponn