PHP code example of thanhsm / mediaembed

1. Go to this page and download the library: Download thanhsm/mediaembed library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

thanhsm / mediaembed example snippets



$input = 'Link here http://mp3.zing.vn/bai-hat/Vi-Ai-Vi-Anh-Dong-Nhi/ZW70UWO6.html';

$content = new MediaEmbed($input);
or
$content = MediaEmbed::process($input);

$contentProcessed = $content->getContent();

$content->hasMedia();

if ($content->hasMedia()) {
    $media = $content->getMediaProvider();
}

//pixel
$media->setWidth(200);
$media->setHeight(100);
or
$media->setSize(200, 100);

$media->getSize();

$media->getHTML();

$data = $media->getData();

$data = $content->getMediaProvider()->getData()

$data = [
    'provider' => 'mp3',
    'embed_type' => 'song',
    'id' => ZW70UWO6,
    'html' => '<iframe width="200" height="100" src="http://mp3.zing.vn/embed/song/ZW70UWO6?autostart=false" frameborder="0" allowfullscreen="true"></iframe>',
    'with' => default width,
    'height' => default height
];