How to play a video with vbscript?

This forum is meant for requesting technical support or reporting bugs.

Moderators: time-killer-games, Vengeance66, Candle, reneuend, GM-Support

How to play a video with vbscript?

Postby thexavi » Sun Dec 18, 2011 1:33 pm

I've tried many things I've read in the forums but nothing works
I got multiple errors.

How can I play a video with vb script?

I'm using simple menu plugin and I want to play a video depending of the choosen option.

Any way??

Thanks
thexavi
Junior Member
 
Posts: 6
Joined: Wed Jun 22, 2005 3:59 pm

Postby mercedes » Sun Dec 18, 2011 9:14 pm

HI there..Welcome to the forums..:)


Are u using the Full Version of AM?

XP or Windows7....?

..Any chance you forgot to put the procedure to play sound and video..

If you're getting an error...could u be more specific...:)
User avatar
mercedes
VIP
 
Posts: 2460
Joined: Sun Mar 09, 2008 10:43 pm
Location: Canada..~

Postby reneuend » Sun Dec 18, 2011 9:29 pm

.....and what version of Adventure Maker are you using?

If we know the answers to Mercedes and this question, then we can help you determine what the problem and solution is.

...and welcome to the forums! :)
---


Image
Image
User avatar
reneuend
Administrator
 
Posts: 2762
Joined: Sat Nov 22, 2008 8:37 pm
Location: Midwest Cornfield, USA

Postby thexavi » Mon Dec 19, 2011 12:38 pm

Hello friends.

I'm using windows 7 and I'm using the last free edition of aventura maker.
It says you can evaluate some features if you use less than 20 frames.
I also tried a full edition 4.5 and get the same problems.

I use something like this in the vbs procedures (I copied from the forum)
Code:
Sub PlayVideo(FileName, Left, Top, Width, Height, Repeat)
'Full screen video: PlayVideo "c:\filename.avi", 0, 0, 640, 480, False
'If the video is located in your "Frames" folder, use the "GetPath(5)" command:
'To stop a video: StopVideo
Action.LoadControl MediaPlayerObject(1)
MediaPlayerObject(1).Move Left*ScreenObject.TwipsPerPixelX, Top*ScreenObject.TwipsPerPixelX, Width*ScreenObject.TwipsPerPixelY, Height*ScreenObject.TwipsPerPixelY
MediaPlayerObject(1).FileName = FileName
If Repeat = True Then
MediaPlayerObject(1).PlayCount = 0
Else
MediaPlayerObject(1).PlayCount = 1
End If
MediaPlayerObject(1).Visible = True
MediaPlayerObject(1).Play
End Sub

And when I call the sub playvideo I got an error about mediaplayerobject

I think the problem, as I read, if due to windows 7. Any suggest?

Thank you again
thexavi
Junior Member
 
Posts: 6
Joined: Wed Jun 22, 2005 3:59 pm

Postby reneuend » Mon Dec 19, 2011 8:50 pm

You need to use the latest version of AM. I believe it is 4.6.

I have the video and sound routines for windows 7, but I'm at work, so I'll post when I get home!
---


Image
Image
User avatar
reneuend
Administrator
 
Posts: 2762
Joined: Sat Nov 22, 2008 8:37 pm
Location: Midwest Cornfield, USA

Postby thexavi » Mon Dec 19, 2011 9:07 pm

I have the last edition of the free one.
I won't buy the full edition if I can't check if what I want to do works.

Ok, I'll wait your post anyway

Thank you
thexavi
Junior Member
 
Posts: 6
Joined: Wed Jun 22, 2005 3:59 pm

Postby reneuend » Tue Dec 20, 2011 2:50 am

Here are the routines that will work with Windows 7 using the latest AM version 4.6.1

Code: Select all
Sub PlaySoundWin7(SoundFile, NumRepeat, ChannelNumber)
   If ChannelNumber < 9 Then
      'With VBScript it is currently not possible to interact with the 8 first audio channels.
      MsgBox "The specified audio channel is invalid.", vbCritical, "Error"
      Exit Sub
   End If
   If Action.IsComponentInstalled("NSPlay.NSPlayCtl.1") = False Then
      MsgBox "Unable to find the media player component.", vbCritical, "Error"
   Else
      If Action.DoesComponentExist("MediaPlayer" + CStr(ChannelNumber)) = false Then
         AddComponent "NSPlay.NSPlayCtl.1", "MediaPlayer" + CStr(ChannelNumber)
      End If
      Component("MediaPlayer" + CStr(ChannelNumber)).Object.FileName = SoundFile
      Component("MediaPlayer" + CStr(ChannelNumber)).Object.PlayCount = NumRepeat
      Component("MediaPlayer" + CStr(ChannelNumber)).Object.Play
   End If
End Sub


Code: Select all
Sub StopSoundWin7()

  Component("MediaPlayer1").Object.Stop

End Sub



Code: Select all
Sub PlayVideoWin7(VideoFile, NumRepeat, ChannelNumber)
   If ChannelNumber < 9 Then
      'With VBScript it is currently not possible to interact with the 8 first video channels.
      MsgBox "The specified video channel is invalid.", vbCritical, "Error"
      Exit Sub
   End If
   If Action.IsComponentInstalled("NSPlay.NSPlayCtl.1") = False Then
      MsgBox "Unable to find the media player component.", vbCritical, "Error"
   Else
      If Action.DoesComponentExist("MediaPlayer" + CStr(ChannelNumber)) = false Then
         AddComponent "NSPlay.NSPlayCtl.1", "MediaPlayer" + CStr(ChannelNumber)
      End If
      Component("MediaPlayer" + CStr(ChannelNumber)).Object.FileName = VideoFile
      Component("MediaPlayer" + CStr(ChannelNumber)).Object.PlayCount = NumRepeat
      Component("MediaPlayer" + CStr(ChannelNumber)).Object.Play
   End If
End Sub


Code: Select all
Sub StopVideoWin7(ChannelNumber)
   If ChannelNumber < 9 Then
      'With VBScript it is currently not possible to interact with the 8 first video channels.
      MsgBox "The specified audio channel is invalid.", vbCritical, "Error"
      Exit Sub
   End If
   If Action.DoesComponentExist("MediaPlayer" + CStr(ChannelNumber)) = true Then
      Component("MediaPlayer" + CStr(ChannelNumber)).Object.Stop
   End If
End Sub
---


Image
Image
User avatar
reneuend
Administrator
 
Posts: 2762
Joined: Sat Nov 22, 2008 8:37 pm
Location: Midwest Cornfield, USA

Postby thexavi » Tue Dec 20, 2011 6:49 pm

It works with the free edition of am 4.6!!!

The problem is that when I click with right button of the mouse it displays a mediaplayer menu and it doesn't like me.

When a video is playing by "play a video" in the properties of a frame or in the properties of a hotspot, it doesn't happen.

Any suggests?
thexavi
Junior Member
 
Posts: 6
Joined: Wed Jun 22, 2005 3:59 pm

Postby reneuend » Tue Dec 20, 2011 10:41 pm

When you right-click during game play??? Is that with the script or using AM's tools to set up the video?

I'll need exact details on how you are setting it up to know what the issue is. I've not had any problems with videos and Windows 7 unless I was trying something a bit unique.
---


Image
Image
User avatar
reneuend
Administrator
 
Posts: 2762
Joined: Sat Nov 22, 2008 8:37 pm
Location: Midwest Cornfield, USA

Postby mercedes » Tue Dec 20, 2011 11:14 pm

The problem is that when I click with right button of the mouse it displays a mediaplayer menu and it doesn't like me.


So the video plays, or is the screen blank when you rightclick--when the menu appears..?

I'm confused..cause on one hand..sounds like its playing..Then u rightclick....a menu appears..

On the other..It sounds like it doesn't...:?

When a video is playing by "play a video" in the properties of a frame or in the properties of a hotspot, it doesn't happen.

User avatar
mercedes
VIP
 
Posts: 2460
Joined: Sun Mar 09, 2008 10:43 pm
Location: Canada..~

Postby thexavi » Wed Dec 21, 2011 10:40 am

reneuend wrote:When you right-click during game play??? Is that with the script or using AM's tools to set up the video?

I'll need exact details on how you are setting it up to know what the issue is. I've not had any problems with videos and Windows 7 unless I was trying something a bit unique.


Yes. During game play.

I explain.
If I play a video with scripting with the above code, the video plays and while the video is playing, if I click with the right button in the video apperar a menu of the windows player( options, full screen, help, properties, repeat, zoom, etc)

If I play a video with the tools provides in AM it doesn't happen. when I right click appears the menu of AM on top (Exit, save load)

I'm at work and I can't show you any screenshot.
thexavi
Junior Member
 
Posts: 6
Joined: Wed Jun 22, 2005 3:59 pm

Postby mercedes » Wed Dec 21, 2011 11:43 pm

..Are you still using the Simple Menu plugin..Perhaps it's not compatible with the Media Player..and/or Windows7..ect..

I can't seem to find any threads on this issue... :?
User avatar
mercedes
VIP
 
Posts: 2460
Joined: Sun Mar 09, 2008 10:43 pm
Location: Canada..~


Return to Adventure Maker Technical Support and Bug Reports

Who is online

Users browsing this forum: No registered users and 0 guests