Giter Club home page Giter Club logo

media-embed's Introduction

MediaEmbed

CI PHPStan Minimum PHP Version License Latest Stable Version Total Downloads Coding Standards

A utility library that generates HTML embed tags for audio or video located on a given URL. It also parses and validates given media URLs.

It currently works with 120+ services, including the most important ones like

  • YouTube
  • Dailymotion
  • MyVideo
  • Vimeo
  • Ustream

etc. With community driven updates this aims to be a complete and up-to-date service wrapper lib.

It uses iframes if possible, and has a fallback on the embed object if necessary.

Demo

https://sandbox.dereuromark.de/sandbox/media-embed

Requirements

Note

Please feel free to join in and help out to further improve or complete it. There are always some providers changing their URLs/API or some new ones which are not yet completed.

Installation

Run

composer require dereuromark/media-embed

This will get the latest tagged version for you.

Documentation

For detailed documentation see /docs.

Credits

Inspired by autoembed.com which already included most of the supported services and laid the foundation of this OOP approach here. There is also this.

media-embed's People

Contributors

adamdburton avatar aleksandrspicyn avatar amaury-tom avatar brendolor avatar cceglia avatar curtisgibby avatar dereuromark avatar deruli avatar drmonkeyninja avatar erikfrerejean avatar erwane avatar jeremib avatar jhuet avatar jozydapozy avatar korenskoy avatar matthewsuan avatar michilehr avatar microstudi avatar netstyler avatar redbastie avatar sammyaxe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

media-embed's Issues

Stable 1.0.0 API

RFC

Discussion around:
How would a stable 1.0 API look like?

Let's start a branch with improvements.
Maybe, instead of arrays, we deal with (value/DTO) objects instead?

Other side effects/benefits:

  • PHP7.2+ for strict typehinting available then

oEmbed fallback / new major

It looks like soundcloud supports oEmbed.
I think it makes sense to implement support for generic oEmbed resources instead of implementing a soundcloud specific solution.
We could use an oembed php library and try to use oEmbed to get the embed code for all unknown services.

(from #43 )

I think we can start a new 0.x major as develop branch with all the necessary improvements there.
What do we want to look out for?
I don't know much about this new oEmbed topic yet.

My main topics for a generic new major would be:

  • try to have value objects for the providers/services/stubs elements
  • allow easier custom injection/overwrite per service if needed (inside this provider collection)
  • more OOP approach then instead of array access and string assoc key arrays.
  • PHP 7.1+ ( #41 ) with typehinting?

The specific oEmbed things are maybe something you can outline.

Using custom providers

Is there a way to add our own providers along with their embed codes via a config file or something?

No way to retrieve embed or iframe src

The library does not allow you to retrieve the src.

I was thinking:

$mediaEmbed = new MediaEmbed;
$object = $mediaEmbed->parseUrl($rl);
$object->getEmbedSrc(); // https://www.youtube.com/embed/qzBGa0OAbfE

Composer is not not installing dereuromark/media-embed

When I run the command you suggested "composer require dereuromark/media-embed" it's showing following error.

_**Your requirements could not be resolved to an installable set of packages.

Problem 1
- The requested package dereuromark/media-embed No version set (parsed as 1.0.0) is satisfiable by dereuromark/media-embed[No version set (parsed as 1.0.0)] but these conflict with your requirements or minimum-stability.**_

How can I resolve this?

Facebook embed not working

Message in the FB player :

href should represent a valid URL

function getEmbed( $id, $host ) {  

        $MediaEmbed = new MediaEmbed();  

        $MediaObject = $MediaEmbed->parseId($id, $host);  

        if (!$MediaObject) {  
            return '';  
        }  
        return $MediaObject->getEmbedCode();  
}

I call the function this way
getEmbed($embed->id(), $embed->slug());

(and I checked, the slug and id are good)

And this is the embed code I got

<iframe src="https://www.facebook.com/plugins/video.php?href=$1&show_text=0&amp;wmode=transparent" type="" width="480" height="295" frameborder="0" allowfullscreen class="embed-responsive-item" data-html5-parameter></iframe>

MediaEmbed->parseUrl is working without a problem with facebook.

Add Soundcloud Support

It would be nice to have support for embedding soundcloud players.
It's a popular audio streaming platform used by musicians, labels and podcasts.

Remove blip.tv

Failing tests now.
Seems to be Maker.tv now and works differently
We should remove support.

Access _stub property OR service name

Hi, Thanks a lot for this library. What's about access the _stub property with a get() public function on the MediaEmbed object ? We can access some properties like id() but here I need to get the host name service. How to proceed ?

PHP 8.2: htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated

Good day, I would like to report error on:

/src/Object/MediaObject.php: line 662
protected function _esc($text) { return htmlspecialchars($text, ENT_QUOTES, '', false); }

When passing NULL value as $text, this triggers error in PHP 8.2:
htmlspecialchars(): Passing null to parameter #1 ($string) of type string is deprecated

This happens when NULL value is passed by code on line 624 (flashvars):
$flashvars = $this->_esc($flashvars)

does not grab youtu.be links

Hi Mark

Congrats for the wonderful Media Ember Class, had something similar stripped off a wordpress plugin and used it in my code but was getting a bit old. Your seems fairly complete so I grabbed it right away and will be using this one :) my clients mostly use vimeo and youtube but all the other services are welcome in there.

i have noticed that links such us http://youtu.be/MKlq4gQKtU0 do not work thought. i tried to modify you regular expression for youtube but it was massive so i gave up :) you might need to update it and include the above as well.

as a workaround just added the below in stubs.php to get it working

    array(
        'name' => 'YouTube Share',
        'website' => 'http://www.youtube.com',
        'url-match' => 'https?://youtu\.be/([0-9a-z-_]{11})',
        'embed-src' => 'https://www.youtube.com/v/$2&rel=0&fs=1&hd=1',
        'embed-width' => '480',
        'embed-height' => '295',
        'image-src' => 'https://img.youtube.com/vi/$2/0.jpg',
        'iframe-player' => 'https://www.youtube.com/embed/$2',
    ),

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.