0

I have done a script that displays only an image of a the video when the user uploads one. The thing is that i want the video to start when the users clicks on the image but now when the user clicks the video appears with no autoplay.

here is the code

<div class="img_container"> <a href="#." id="video_thumb_<?php echo $id;?>" style="display:block;" 
    onClick="javascript:loadVideo(\'<?php echo $id;?>\')"> <img src='<?php echo $my_thumb;?>' class="imgpreview" /> </a> <div style="display:none;" 
        id="video_<?php echo $id;?>"?autoplay="1"></div>';




 <script>
    function loadVideo(input){
        document.getElementById("video_thumb_"+input).style.display="none";
        document.getElementById("video_"+input).style.display="block";
    }
</script> 
1
Contributor
4
Replies
12
Views
1 Year
Discussion Span
Last Post by SimonIoa
1

ok i got it...

<iframe class="new" width="'.$w.'" height="'.$h.'" src="'.$this->data["iframe"].'?autoplay=1" frameborder="0" allowfullscreen></iframe>

0
$orimessage = 'https://www.youtube.com/watch?v=m5N9IHqqGcA';

if(textlink($orimessage))
{
    $link =textlink($orimessage);
    $em = new Wall_Expand($link);
    $site = $em->get_site();
    if($site != "")
    {

        $my_thumb= $em->get_thumb("medium");
       $code = $em->get_iframe();

        if($my_thumb != "")
        {
            echo '<div class="img_container"><a href="#" id="video_thumb_'.$omsg_id.'" style="display:block;" onClick="javascript:loadVideo(\''.$omsg_id.'\')"><img src='.$my_thumb.' class="imgpreview" /></a>';
            if($code != ""){
                echo '<div style="display:none;" id="video_'.$omsg_id.'"?autoplay="1">'.$code.'</div>';
            }
            echo '</div>';
        }
    }
}
?>

and the .js

    function loadVideo(input){
        document.getElementById("video_thumb_"+input).style.display="none";
        document.getElementById("video_"+input).style.display="block";
    }

when pressed the video doesnt start the autoplay you have to press twice to start the video

Edited by SimonIoa: change

0

and this is the function

public function get_iframe($w = -1, $h = -1){
        $this->prepare_data("iframe");
        if($this->site != "" && $this->data["iframe"] != "")
        {

            if($w < 0 || $h < 0)
            {
                $w = (is_int($this->data["w"]) && $this->data["w"] > 0) ? $this->data["w"] : $this->default_size["w"];
                $h = (is_int($this->data["h"]) && $this->data["h"] > 0) ? $this->data["h"] : $this->default_size["h"];
            }
            $w=492;
            return '<iframe class="new" width="'.$w.'" height="'.$h.'" src="'.$this->data["iframe"].'?autoplay=0" frameborder="0" allowfullscreen></iframe>';
        }
        else
        {
            return "";
        }
    }
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.