Embedded Windows Media Player Time Control

Dear Experts,

Is there a way to control (or limit) play time of an mp3 song using embedded Windows Media Player on a web site?
I would like to play a demo portion of about 30 seconds instead of the whole music on a web site using a Windows Media Player, but don't want to create a separate 30 second demo file.
Is there a way to limit the playing time of the embedded Windows Media Player?

Thanks, in advance.
Who is Participating?
eeBlueShadowConnect With a Mentor Commented:
JavaScript is not the best way to go about this. There are specially designed playlist files (ASX) to help you here.


For example, copy the following text to a file, give it a .asx extension and open it in Media Player

    <DURATION VALUE="00:00:10" />
    <REF HREF="http://blueshadow.no-ip.com/ee/bennyhill.mp3"></REF>

However, since you a) aren't creating a separate file for your 'demo' and b) need to send the player the URL of the full file, it's possible for someone to catch the URL of the file and simply download the whole thing. There's no way getting around that, unfortunately

checkout this PAQ:

you can call the settimeout function in javascript with interval set to 30 secs. once the playing has started call settimeout keeping check on counter; if it reaches 30 then stop playing the file.
check this url source for getting acquainted with settimeout :

matthewyeaAuthor Commented:
Thanks, aspmaestro and eeBlueShadow.
I've created a script and it worked great.  Thanks again.  ^^
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.