thanhsm/mediaembed

This package is abandoned and no longer maintained. No replacement package was suggested.

Generate media embed from NTC, Zing Mp3, Youtube

v1.0.1 2015-04-10 11:06 UTC

This package is not auto-updated.

Last update: 2024-02-03 14:25:23 UTC


README

Build Status Code Climate Latest Stable Version Total Downloads Latest Unstable Version License

Media Embed

Mp3, NTC, Youtube media embed

Installation

Add line

"require": {
    "thanhsm/mediaembed": "dev-master"
  }

To composer.json in your project and then run composer update

How to use ?

Input:

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

Process content

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

Get get parsed content

$contentProcessed = $content->getContent();

Example http://youtube.com will become <a href="http://youtube.com">youtube.com</a>

Check media object in content

$content->hasMedia();

If contain media you can get media object with

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

You can set media width/height simple by

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

Get Media Size

$media->getSize();

Get embed code (HTML)

$media->getHTML();

Output

<iframe width="200" height="100" src="http://mp3.zing.vn/embed/song/ZW70UWO6?autostart=false" frameborder="0" allowfullscreen="true"></iframe>

Get all media data

$data = $media->getData();

You also call with chaining method

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

Output

$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.