0

Here is my code :-

<?php
            $sql = "SELECT * FROM era_videos ORDER BY video_id";
            $sqlex = mysqli_query($db,$sql);

            $m = 1;

            while($result = mysqli_fetch_assoc($sqlex))
            {


        ?>
                <div class="slide" current_id="<?php echo $m;?>" style="width:300px !important; height:200px !important;">
                    <object class="youtube" id="videoid<?php echo $m;?>" width="300" height="200"><param name="movie" value="https://www.youtube.com/v/<?php echo $result['urlname'];?>"version=3&amp;hl=en_US&amp;rel=0">    </param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="https://www.youtube.com/v/<?php echo $result['urlname'];?>"version=3&amp;hl=en_US&amp;rel=0" type="application/x-shockwave-flash" width="300" height="200" allowscriptaccess="always" allowfullscreen="true"></embed></object>
                </div>
       <?php
                $m++;
            }
       ?>

jQuery Code :-

jQuery('#iCarouselNext').click(function()
      {
         var current_id = parseInt($('.current').attr('current_id'));

         var previous_id = current_id - 1;

         $('#videoid'+previous_id).stopVideo();


      });

But it throws an error - Uncaught TypeError: Object [object Object] has no method 'stopVideo'

I found this but no solution Stop a youtube video with jquery?

Thanks in advance

Community
  • 1
  • 1
Rakesh Shetty
  • 4,548
  • 7
  • 40
  • 79

1 Answers1

0

Use

$('#videoid'+previous_id).get(0).stopVideo();

Or

$('#videoid'+previous_id)[0].stopVideo();

Also there is an error in your logic of getting the current_id

var current_id = parseInt($('.current').attr('current_id'));

This will always give the first element's id.

SajithNair
  • 3,867
  • 1
  • 17
  • 23