Download the PHP package ride/lib-media without Composer
On this page you can find all versions of the php package ride/lib-media. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ride/lib-media
More information about ride/lib-media
Files in ride/lib-media
Package lib-media
Short Description Library for abstraction of media services in the Ride framework
License MIT
Informations about the package lib-media
ride/lib-media
This library adds support for custom media items, like Youtube videos, Soundcloud music or plain URL's.
MediaItem classes live in the item/
directory, and their factories in the factory
directory.
What's In This Library
MediaItemFactory
The MediaItemFactory class is the interface for all media item factories. This factory has two responsibilities:
- check a given URL if it is valid for the assosiated MediaItem class
- instantiate a new MediaItem class
The AbstractMediaItemFactory
has a default implementation for the createFormUrl
, createFromId
and setClientId
methods.
Its constructor requires an instance of ride\library\http\client\Client
.
The isValidUrl
method should always be implemented in the child class, and should contain logic in order to determine if an URL is parseable for the related media item.
MediaItem
The MediaItem class is the interface for all media items.
There is an abstract implementation called AbstractMediaItem
from which all classes can extend.
Each MediaItem class should implement at least following methods:
The parseUrl
method will take a given URL and parse it for this specific MediaItem implementation.
It can be assumed that this URL is parseable because of the check done in the MediaItemFactory.
Each media item needs a factory for the MediaFactory to be able to use it.
MediaFactory
The MediaFactory interface glues all the MediaItemFactory instances together into an easy facade. It will use specific media item factories to test if a given URL can be parsed.
A generic implementation is provided through the SimpleMediaFactory class.
Code sample
You can check the following code sample to see some of the possibilities of this library:
Related Modules
Installation
You can use Composer to install this library.