dupa

Author Topic: New Hal, No Jukebox  (Read 2868 times)

Ponnfar

  • Full Member
  • ***
  • Posts: 149
    • View Profile
    • http://zabaware.com
New Hal, No Jukebox
« on: December 16, 2005, 01:08:25 am »
Here is a script I cannot fix. It was a great little doo-dad. Hal use to play selected tunes on demand from my windows media player. Anyone have any ideas?

'-----------Ponnfar note playing music files-----------
    '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 = "Here is one of your favorite songs."
      Set songsList = oWMP.mediaCollection.getAll     
      numSong = Int(Rnd * songsList.Count) + 1   
      oWMP.openPlayer (songsList.Item(numSong).sourceURL)
   
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")
        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 Ponnfar,... sorry."
 
 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 ", "THE RADIO STATION", 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
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 ") + 8))
      '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

'--------end Ponnfar note playing music files-------------

Here is the line in question :songName = Trim(Mid(OriginalSentence, InStr(1, OriginalSentence, " THE SONG ", "THE RADIO STATION", vbTextCompare) + 10))

Where Hal has in the past done the search, well no longer, Hal just tells me the song cannot be found in my library. In fact Hal never completes the routine to even look for it.
Any help??
P
« Last Edit: December 16, 2005, 01:18:31 am by Ponnfar »
One Person can summon the future...

GrantNZ

  • Full Member
  • ***
  • Posts: 178
    • View Profile
New Hal, No Jukebox
« Reply #1 on: December 16, 2005, 01:23:00 am »
Here's my hunch: Try deleting: "THE RADIO STATION",

So your line becomes:

songName = Trim(Mid(OriginalSentence, InStr(1, OriginalSentence, " THE SONG ", vbTextCompare) + 10))

I have a feeling the radio station bit isn't supposed to be there, and is interfering with the search.

If that doesn't work, well, I don't know [:D]
 

Ponnfar

  • Full Member
  • ***
  • Posts: 149
    • View Profile
    • http://zabaware.com
New Hal, No Jukebox
« Reply #2 on: December 16, 2005, 07:41:31 am »
Dude!!
That did it....I am here...can you her me saying....DUH!!
LOL!
Thanks!
P
« Last Edit: December 16, 2005, 07:43:15 am by Ponnfar »
One Person can summon the future...