Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!
  • 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.


    To learn more about how to use our BBCode feature, please click here.

    Thank you, Code Forum.

Does anyone know how to load SWF/content after a video plays?

David

Coder
I used to have the code to do this but I lost it. Argh!

I want to be able to play a video first, then load my SWF or content. This should be easily done right?

I want the user to watch my 15 second video then immediately be provided the SWF.

Can Anyone help?
 
Last edited by a moderator:
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.
Very nice coding.
 
You can also do it with JavaScript like this...
JavaScript:
<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>
 

New Threads

Latest posts

Buy us a coffee!

Back
Top Bottom