, (*1)
Mp3, NTC, Youtube media embed, (*2)
Installation
Add line, (*3)
"require": {
"thanhsm/mediaembed": "dev-master"
}
```
To composer.json in your project and then run ```composer update```
# How to use ?
Input:
```php
<?php
$input = 'Link here http://mp3.zing.vn/bai-hat/Vi-Ai-Vi-Anh-Dong-Nhi/ZW70UWO6.html';
Process content, (*4)
$content = new MediaEmbed($input);
or
$content = MediaEmbed::process($input);
Get get parsed content, (*5)
$contentProcessed = $content->getContent();
Example
http://youtube.com will become <a href="http://youtube.com">youtube.com</a>, (*6)
Check media object in content, (*7)
$content->hasMedia();
If contain media you can get media object with, (*8)
if ($content->hasMedia()) {
$media = $content->getMediaProvider();
}
You can set media width/height simple by, (*9)
//pixel
$media->setWidth(200);
$media->setHeight(100);
or
$media->setSize(200, 100);
Get Media Size, (*10)
$media->getSize();
Get embed code (HTML), (*11)
$media->getHTML();
Output, (*12)
<iframe width="200" height="100" src="http://mp3.zing.vn/embed/song/ZW70UWO6?autostart=false" frameborder="0" allowfullscreen="true"></iframe>
Get all media data, (*13)
$data = $media->getData();
You also call with chaining method, (*14)
$data = $content->getMediaProvider()->getData()
Output, (*15)
$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
];
All issues please post to here, thanks you., (*16)