srinath madusanka
srinath madusanka

Reputation: 592

control embedded video using jquery

I have an embedded video and I only want to allow logged-in users to view it.

If a user is not logged in and tries to play it must log an alert

I try following way but it does not work:

<div id="container">
       <embed id="playerid" width="300" height="200" flashvars="file=http://www.mydomain.com/Video/demo.flv&amp;autostart=false&amp;stretching=fill&amp;image=http://www.mydomain.com/Video/demo.jpg&amp;logo=http://www.mydomain.com/Video/Watermark.gif" allowscriptaccess="always" allowfullscreen="true" quality="high" bgcolor="#330099" name="ply" id="ply" style="undefined" src="player.swf" type="application/x-shockwave-flash">
</div>

my jQuery code is

<script>
<?php
if(!$login){
?>
    $(document).ready(function(){
        $('#container').click(function(){
            alert('video clicked');
        }); 
    });
<?php
}
?>
</script>

Upvotes: 1

Views: 80

Answers (1)

Monwabisi Sifumba
Monwabisi Sifumba

Reputation: 40

Try this:

<?php $login = true; //Let's make it true just for testing ?>
<script>
    $(document).ready(function(){
    $('#container').click(function(){
    if("<?php echo($login); ?>"){
      alert('Play Video');
     }else{
      alert("Please login to play video");
     }
    });
</script>

Upvotes: 1

Related Questions