Page 1 of 1

Error Executing Script - Type Mismatch: mediaplayerobject

PostPosted: Sun Dec 19, 2010 6:31 pm
by reneuend
I'm getting this error every time I click on a hotspot or when a new frame loads. I can't seem to locate the issue. I turned off transitions, but that didn't make a difference. Has anyone else experienced this and know how to get around it?

(edit) I loaded my Picture Perfect puzzle game and for the most part it worked, except for this particular error showing up when I click on a hotspot. But it seems random because it doesn't happen on most hotspots. I'll check to see if it repeats with the same sequence.

PostPosted: Mon Dec 20, 2010 7:50 am
by juhuwoorps
Are you playing sounds in any of the hotspots with VBscript?

PostPosted: Mon Dec 20, 2010 2:39 pm
by reneuend
Yes. I'm sure I am....let me guess..you can't do that? :oops:

PostPosted: Mon Dec 20, 2010 3:36 pm
by juhuwoorps
you need an other a code as normaly. Im typing this from my cellphone so i cant copy the right code now but you can find it here at the forum

PostPosted: Mon Dec 20, 2010 4:25 pm
by reneuend
When you get a chance, I would really appreciate it! I need more control over the sound like with creating timed events and delays.

(edit) I found the thread where GM shows how to play sound now.
http://www.adventuremaker.com/phpBB2/viewtopic.php?t=5382
I created a subroutine with it. However, it would be better if there was a endless loop and then another routine to stop the sound.

Thanks for responding Juhu!


Code: Select all
sub PlaySoundWin7(SoundFile, NumRepeat)

  If Action.IsComponentInstalled("NSPlay.NSPlayCtl.1") = False Then
    MsgBox "Unable to find the media player component.", vbCritical, "Error"
  Else
    If Action.DoesComponentExist("MediaPlayer1") = false Then
      AddComponent "NSPlay.NSPlayCtl.1", "MediaPlayer1"
    End If
    Component("MediaPlayer1").Object.FileName = SoundFile '(replace with your file)
    Component("MediaPlayer1").Object.PlayCount = NumRepeat
    Component("MediaPlayer1").Object.Play
  End If
 
End Sub


PostPosted: Mon Dec 20, 2010 7:05 pm
by Mystery
Wouldn't 0 for NumRepeat loop it endlessly? That was at least the case with the previous code (that is not compatible with W7).
And if that works, there must be a way to stop the player, too.

PostPosted: Mon Dec 20, 2010 7:33 pm
by CBSection31
If I recall, GM_Support released an updated code for playing sounds through VBScript in Windows 7. I used it for The Filmmaker, and it worked flawlessly...unfortunately, I don't have access to that project's code at the moment. If you search through the Windows 7 thread in this forum, I think the code is there. :)

PostPosted: Mon Dec 20, 2010 7:36 pm
by Mystery
I think that's the script that reneuend quoted above :)

PostPosted: Mon Dec 20, 2010 8:01 pm
by reneuend
Hi Mystery,
Nice to hear from you again.
I haven't found a way to stop the sound or to run multiple sounds at the same time, even though i experimented with GM's code. If someone knows of a way to do either or both of these that would help out a lot!

PostPosted: Mon Dec 20, 2010 8:40 pm
by Mystery
Thanks reneuend :D I was too busy lately, but now I have some Christmas vacation :D

Well, I just successfully used the following script to stop the sound - I'm on Vista, so double check it for W7:

Code: Select all
Component("MediaPlayer1").Object.Stop

PostPosted: Mon Dec 20, 2010 9:07 pm
by reneuend
AWESOME!!!!!!

W need to start a place where we can collect new routines for Windows 7. :wink:

Now, one more thing. How do you play multiple channels with this new routine? Since you're on vacation, I figure it wouldn't hurt to ask for more! :)

PostPosted: Mon Dec 20, 2010 9:12 pm
by Mystery
I don't think it was ever possible to use the different channels with scripting? I think the channel is selected randomly.
You should be able to add a sound by going to the Audio Tab of the Hotspot Properties.

PostPosted: Mon Dec 20, 2010 9:38 pm
by reneuend
Nice try. You're not getting out of it that easy! :)
It was possible because I wrote my own routine to allow channel selection.

Code: Select all
Sub PlaySound2(FileName, Channel, Repeat)
  Action.LoadControl MediaPlayerObject(Channel)
  MediaPlayerObject(Channel).FileName = FileName
  If Repeat = True Then
    MediaPlayerObject(Channel).PlayCount = 0
  Else
    MediaPlayerObject(Channel).PlayCount = 1
  End If
  MediaPlayerObject(Channel).Play
End Sub

PostPosted: Mon Dec 20, 2010 9:50 pm
by Mystery
LOL, how on Earth should I know how to update your own subroutine for W7? I'm not ShadowHunter ;) :lol:
Sorry, I have no idea how to add channels to the new code :?
You might have to wait for smarter people :lol:

PostPosted: Mon Dec 20, 2010 10:27 pm
by juhuwoorps
I'm glad you have found the code.
Mysterys code for stoping sound work with WIN7. I have tried it a longer time ago as AM4.6.0 was released.

Now I have to give your subroutine a try :)