To be able to play audio and video files from VBScript, simply copy/paste the following code into the "VBScript Global Procedures" window:
- 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 PlaySound(FileName, Repeat)
Action.LoadControl MediaPlayerObject(2)
MediaPlayerObject(2).FileName = FileName
If Repeat = True Then
MediaPlayerObject(2).PlayCount = 0
Else
MediaPlayerObject(2).PlayCount = 1
End If
MediaPlayerObject(2).Play
End Sub
Sub StopVideo()
MediaPlayerObject(1).Visible = False
MediaPlayerObject(1).Stop
MediaPlayerObject(1).FileName = ""
Action.UnloadControl MediaPlayerObject(1)
End Sub
Sub StopSound()
MediaPlayerObject(2).Stop
MediaPlayerObject(2).FileName = ""
Action.UnloadControl MediaPlayerObject(2)
End Sub
Then you can use the "PlayVideo", "StopVideo", "PlaySound" and "StopSound" function.
For example, to play a video full-screen, type:
- Code: Select all
PlayVideo "c:\filename.avi", 0, 0, 640, 480, False
If the video is located in your "Frames" folder, use the "GetPath(5)" command:
- Code: Select all
PlayVideo GetPath(5) + "filename.avi", 0, 0, 640, 480, False
To make the video loop forever, just replace "False" with "True" in the line above.
To stop the video, simply type:
- Code: Select all
StopVideo
To play a sound, type:
- Code: Select all
PlaySound "c:\filename.mp3", False
If the sound file is located in your "Areas" folder, use the "GetPath(4)" command:
- Code: Select all
PlaySound GetPath(4) + "c:\filename.mp3", False
To make the sound loop forever, just replace "False" with "True" in the line above.
To stop the sound, simply type:
- Code: Select all
StopSound
Please feel free to let me know if you have any questions.
Best regards,
GM-Support