Question about pathinfo

Asked

Viewed 13 times

0

Hello I have a class called Videoplayer.

At the moment I’m trying to display src for different extensions being it gif or mp4 however I am receiving error or I am not knowing how to implement correctly, would anyone have any idea what I am doing wrong? Thanks in advance.

mistakes --->

Notice: Undefined variable: filename in E: xampp htdocs inpiic includes classes Videoplayer.php on line 18

Notice: Undefined index: extension in E:\xampp\htdocs\projeto\includes\classes\VideoPlayer.php on line 21

Notice: Undefined index: extension in E:\xampp\htdocs\projeto\includes\classes\VideoPlayer.php on line 21

Notice: Array to string conversion in E:\xampp\htdocs\projeto\includes\classes\VideoPlayer.php on line 23
Array

code -->>

   <?php
class VideoPlayer {

    private $video;

    public function __construct($video) {
        $this->video = $video;
    }

    public function create($autoPlay) {
        if($autoPlay) {
            $autoPlay = "autoplay";
        }
        else {
            $autoPlay = "";
        }
        $filePath = $this->video->getFilePath();
        $file_parts = pathinfo($filename);
        $image = '<img src="'.$filePath.'" class="imagePopup" />';
        $video = '<video width="320" height="240" controls><source src="'.$filePath.'"class="imagePopup"  type="video/mp4"></video>';
        (($file_parts['extension'] === 'gif') ? $image : (($file_parts['extension'] === 'mp4') ? $video : 'NULL') );
        return "<gifm class='gifm' >
                    $file_parts
                    
                    
                   <a download href='$filePath' target='_blank'>Download This Image</a>
                </gifm>";
                
    }

}
?>
  • 1

    Where does the variable come from $filename?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.