How do I use playlists in an HTA file using VBScript?

105 views Asked by At

I have found many pieces of code to this effect but all are using WMP7.ocx. I have an installer that takes 10 to 15 minutes to complete and I would like to have something non-intensive to add a bit of joy to the otherwise arduous and dull process. I tried a video and all was well until the install portion of the app began. The video 1st lagged, then lost sync, then died completely. Here is what I am using currently: !!UPDATED!!

<OBJECT 
  ID="myvideo"
  CLASSID="CLSID:22d6f312-b0f6-11d0-94ab-0080c74c7e95"
  CODEBASE="http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=5,1,52,701" STANDBY="Loading Microsoft Windows Media Player components..." TYPE="application/x-oleobject" >
  <PARAM NAME="autostart" VALUE="1">
  <PARAM NAME="showcontrols" VALUE="1">
  <PARAM NAME="AllowChangeDisplaySize" VALUE="1">
  <PARAM NAME="DisplaySize" VALUE="13">
  <PARAM NAME="ShowGotoBar" VALUE="1">
  <PARAM NAME="Volume" VALUE="-250">
  <PARAM NAME="SendKeyboardEvents" VALUE="1">
  <PARAM NAME="SendPlayStateChangeEvents" VALUE="1">
  <PARAM NAME="EnableFullScreenControls" VALUE="1">
  <PARAM NAME="animationatStart" VALUE="1">
  <PARAM NAME="transparentatStart" VALUE="1">
  <PARAM NAME="mute" value="false">
  <PARAM NAME="loop" value="True">
  <PARAM NAME="fileName" value="" ID="m3">
</OBJECT>

'Then I figured out this piece that made it easy

sub musicbox()
max=25
min=1
Randomize
d = Int((max-min+1)*Rnd+min)
t = "https://example.com/M2/" & d & ".mp3"
vid.filename=t
vid.play
End Sub

Now I just need to know how to tell the app that when the process has stopped so it can run this subroutine again for another song. The code I keep finding seems not to work in HTAs. One step at a time! :)

1

There are 1 answers

1
LesFerch On

If you're okay with defining your playlist within the HTA, you can play any number of videos in a loop like the example below which auto-plays three video files named "Vid1.mp4", "Vid2.mp4", and "Vid3.mp4":

<!DOCTYPE html>
<html>
<head>
<meta http-equiv="X-UA-Compatible" content="IE=9">
<script language="vbscript">
window.resizeTo 800,500
VidNum = 1
VidCount = 3

Sub PlayNextVideo
  VidNum = VidNum + 1
  If VidNum>VidCount Then VidNum = 1
  vid.src = "vid" & VidNum & ".mp4"
  vid.play
End Sub

</script>
</head>
<body>
<video id="vid" width="100%" controls autoplay onended="PlayNextVideo()">
    <source src="vid1.mp4" type='video/mp4'/>
</video>
</body>
</html>