I am using the following code to play a video on my site. at the moment it is set to auto play. What I would like to know is there a way to make the video only auto play if visited from a specific URL. and not auto play if navigated through the site?
code below:
<video width="640" height="360" controls autoplay>
<source src="__VIDEO__.MP4" type="video/mp4" />
<source src="__VIDEO__.OGV" type="video/ogg" />
<object width="640" height="360" type="application/x-shockwave-flash" data="__FLASH__.SWF">
<param name="movie" value="__FLASH__.SWF" />
<param name="flashvars" value="autostart=true&controlbar=over&image=__POSTER__.JPG&file=__VIDEO__.MP4" />
<img src="__VIDEO__.JPG" width="640" height="360" alt="__TITLE__"
title="No video playback capabilities, please download the video below" />
</object>
</video>
What you can do is use JavaScript to check the referral, if it’s not from your site then set autoPlay to true.
ex:
or
Ideally you’d want to check this with server side code and just spit out the html accordingly. with JS you’ll have to either create the flash object via JS code (something like swfObject), or set autoPlay as false all the time and invoke a play function (if it exists) after the fact when you check the referrer.