Link to home
Start Free TrialLog in
Avatar of mikeydk
mikeydkFlag for Denmark

asked on

Show MP4 file and close (HTA)

Hey

I need to show a short video - and close after the video ends.

(I'm able to start mshta.exe or another standard application)

Howto? (HTA?)

Thanks in advance

Mike
Avatar of Jeff Darling
Jeff Darling
Flag of United States of America image

Sample HTA to play a video then close

<html>
<head>
<title>Play Video and then Close automatically</title>
<HTA:APPLICATION
  APPLICATIONNAME="Play then Close"
  ID="MyHTMLapplication"
  VERSION="1.0"/>
  <meta http-equiv="x-ua-compatible" content="ie=edge" />
</head>

<script language="VBScript">

Sub Window_OnLoad
  'This method will be called when the application loads
  'Add your code here
   Window.ReSizeTo 505, 370
   
End Sub

Sub ExitProgram
  window.close()
End Sub

</script>

<body bgcolor="white">

<div id="myID">
<video id="myVideo" width="480" height="320" autostart="true"  controls="controls">
<source src="Sunrise.mp4" type="video/mp4">
</video>
</div>

<script type='text/javascript'>

  // Play automatically  
  document.getElementById("myVideo").play();

  // setup event listener to close when video is done playing.
  document.getElementById('myVideo').addEventListener('ended',myHandler,false);
  function myHandler(e) {
    if(!e) { e = window.event; }
      ExitProgram();
  }
</script>
<!--{{InsertControlsHere}}-Do not remove this line-->
</body>
</html>

Open in new window

Sunrise.mp4
Avatar of mikeydk

ASKER

Exitprogram not defined? (Line: 43)
ASKER CERTIFIED SOLUTION
Avatar of Jeff Darling
Jeff Darling
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial