We help IT Professionals succeed at work.

Show MP4 file and close (HTA)

mikeydk
mikeydk asked
on
605 Views
Last Modified: 2017-04-18
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
Comment
Watch Question

Jeff DarlingDeveloper Analyst
CERTIFIED EXPERT

Commented:
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

Author

Commented:
Exitprogram not defined? (Line: 43)
Developer Analyst
CERTIFIED EXPERT
Commented:
Unlock this solution and get a sample of our free trial.
(No credit card required)
UNLOCK SOLUTION
Unlock the solution to this question.
Thanks for using Experts Exchange.

Please provide your email to receive a sample view!

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.