Guest, before posting your code please take these rules into consideration:
It is required to use our BBCode feature to display your code. While within the editor click < / > or >_ and place your code within the BB Code prompt. This helps others with finding a solution by making it easier to read and easier to copy.
You can also use markdown to share your code. When using markdown your code will be automatically converted to BBCode. For help with markdown check out the markdown guide.
Don't share a wall of code. All we want is the problem area, the code related to your issue.
Well, PHP will not be able to see if the user has watched the whole video, if the video is stuck loading, etc.
You could try something like...
PHP:
sleep(15);
And then echo out the SWF... However, this will also prevent the rest of your site from loading - anything below the video.
You could also use PHP in the following way...
PHP:
<html>
<!-- header / stuff here -->
<?php if(!isset($_GET['swf']) || $_GET['swf'] !== 'true'){ $swf = false; ?>
<!-- your video that auto starts playing -->
<?php } else { $swf = true; ?>
<!-- your swf here -->
<?php } ?>
<!-- footer / stuff here -->
</html>
<?php
if($swf !== true){ // first time here - watching video...
sleep(15); // don't do anything for 15 seconds
echo "<script>window.location.href='yourpage.php?swf=true';</script>"
}
?>
This would get the job done, but if the video doesn't load fully for the user or its slow or they find a way to pause it, your page will redirect with PHP before they finish the video. JavaScript is much better
Your best bet is to do something with JavaScript. You can detect video plays/stops/timing/etc & automatically load other content in (your SWF) right afterwards. I highly recommend using JS and not PHP for this.
Well, PHP will not be able to see if the user has watched the whole video, if the video is stuck loading, etc.
You could try something like...
PHP:
sleep(15);
And then echo out the SWF... However, this will also prevent the rest of your site from loading - anything below the video.
You could also use PHP in the following way...
PHP:
<html>
<!-- header / stuff here -->
<?php if(!isset($_GET['swf']) || $_GET['swf'] !== 'true'){ $swf = false; ?>
<!-- your video that auto starts playing -->
<?php } else { $swf = true; ?>
<!-- your swf here -->
<?php } ?>
<!-- footer / stuff here -->
</html>
<?php
if($swf !== true){ // first time here - watching video...
sleep(15); // don't do anything for 15 seconds
echo "<script>window.location.href='yourpage.php?swf=true';</script>"
}
?>
This would get the job done, but if the video doesn't load fully for the user or its slow or they find a way to pause it, your page will redirect with PHP before they finish the video. JavaScript is much better
Your best bet is to do something with JavaScript. You can detect video plays/stops/timing/etc & automatically load other content in (your SWF) right afterwards. I highly recommend using JS and not PHP for this.
<html>
<video id="HTML5VideoPlayer" width="480" height="400" controls="true" poster="">
<source type="video/mp4" src="video.mp4"></source></video>
</html>
<script>
window.onload = function(){ // wait for window to load
// when video is finished: (html5 video player required)
document.getElementById("HTML5VideoPlayer").addEventListener("ended", function(e) {
this.style.display = "none"; // hide video player
// embed the SRC into page
// do it here
});
}
</script>