Event after playing a video?

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

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

Event after playing a video?

Postby juhuwoorps » Sun Feb 22, 2009 9:59 pm

Hello to anyone!

Is there a way to play a video with scripting and then when the video is finished to do call another script?

I have looked around and tried but I don't have found where to put a code to do this.

Hope you can help! :)
juhuwoorps
Code Master
 
Posts: 622
Joined: Tue Jul 08, 2008 3:13 pm

Postby Mystery » Mon Feb 23, 2009 12:11 am

Hi juhu, since AM can't detect when your video is over, you will probably need to add a timed event (set the duration of the timed event to the duration of your video).

To be able to play a video from VBScript, add this to the "VBScript Global Procedures":
Code: Select all
Sub PlayVideo(FileName, Left, Top, Width, Height, Repeat)
  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

Sub StopVideo()
  MediaPlayerObject(1).Visible = False
  MediaPlayerObject(1).Stop
  MediaPlayerObject(1).FileName = ""
  Action.UnloadControl MediaPlayerObject(1)
End Sub


Use
Code: Select all
PlayVideo GetPath(2) + "filename.avi", 0, 0, 640, 480, False
to play the video and
Code: Select all
StopVideo
to stop the video.
Make sure you copy the video file to the External Folder of AM.

Here is a working example added in the advanced Hotspot Properties:
Code: Select all
PlayVideo GetPath(2) + "Balloon.avi", 0, 0, 640, 480, False
Action.CreateTimedEvent 2,"StopVideo"
Action.CreateTimedEvent 2, "Action.Message ""Video finished"""
User avatar
Mystery
Forum Admin and Games Page admin
 
Posts: 2990
Joined: Sat Feb 04, 2006 8:12 am
Location: Switzerland

Postby Lyberodoggy » Mon Feb 23, 2009 1:34 pm

Yeah that's what I do too
User avatar
Lyberodoggy
Administrator
 
Posts: 2526
Joined: Sat Feb 17, 2007 3:31 pm
Location: Athens


Return to Adventure Maker Technical Support and Bug Reports

Who is online

Users browsing this forum: No registered users and 0 guests