tsdtsdtsd

Markup Plyr HTML5 Media Player

Recommended Posts

Plyr Media Player for ProcessWire

! beta status. This module is "work in progress" v0.2 !

Please be patient as this is my very first public module ^^

This module adds the Plyr HTML5 Media Player (plyr.io) to ProcessWire.

Plyr is basically a wrapper for the natural media interface in modern browsers. It adds the ability for easy styling via CSS and a sprite, while being fully responsive. Also Plyr gives you full controll over the player with its great javascript interface.

MarkupPlyrMediaPlayer incorporates Plyr for ProcessWire. 

-> GitHub


Current capabilities

After installation, you will notice some module configuration options. These are:

 - Automatic Mode

   If enabled, this option will automaticaly add all needed resources into your pages output.

 - Use CDN

   Use the official Plyr CDN (Content Delivery Network) for resources?

The following resource options are only required if you don't wish to use the CDN:

 - Path to CSS file

   (Path to your CSS file, required to style the players.)

 - Path to Plyr library

   (Path to the Plyr javascript library, required for the functionality.)

 - Path to SVG sprite

   (Path to your SVG sprite image file, required to style the players.)

Automatic mode

If automatic mode is enabled, the module hooks after the page rendering and automatically adds the stylesheet to HTML head. Also adds an AJAX call to fetch the SVG sprite and the Plyr javascript library right before the ending body-tag.

Also, while in automatic mode, that extra markup will only be rendered if a template made a render request for a Plyr player. So there will be no unnecessary load on your site.

Get module



$plyr = $modules->get("MarkupPlyrMediaPlayer");


Add a video player to your template



echo $plyr->renderVideoPlayer($poster, $mp4, $webm, $captions);


The $captions-Array contains details of the caption tracks:



$captions = $caption = array();

$caption['label'] # Something like "English captions"
$caption['src'] # http://...movie_captions_en.vtt
$caption['srclang'] # en|de|ru|...
$caption['default'] # true|false

array_push($captions, $caption);


Add an audio player to your template



echo $plyr->renderAudioPlayer($mp3Path, $oggPath);


Add the YouTube-wrapper to your template



echo $plyr->renderYoutubePlayer($videoId);


Manual mode

If automatic mode is disabled, you have to render these parts manualy in your page template. Important: This method will not check if a player was requested.

In the HTML head:



<html>
<head>
...
<?php echo $plyr->renderHeadLink(); // Basicly just a <link rel="stylesheet" href="..."> ?>
</head>
...


And in the footer somewhere before the closing body-tag:



...
echo $plyr->renderScripts; // AJAX call for SVG and JS library inclusion
</body>
</html>


Where is this going?

Before getting a v1.0.0 stable release, this module should be capable of following features:

- [done] Load resources from CDN or local files

- Reliable automatic mode with fallback to local

- Brings specific Inputfields for video, audio and youtube for the backend and frontend markup rendering

- Every Plyr javascript setting can be handled via module configuration

  • Like 10

Share this post


Link to post
Share on other sites

hello and congrats. I was testing this module and get a syntax error on line 40 (path to templates )of the MarkupPlyrMediaPlayer.module

keep up the good work.

Share this post


Link to post
Share on other sites

Hi nfil,

thanks for the report, but could you possibly give me more information? I couldn't reproduce your issue.

There's really not much on line 40, I'm a little puzzled ;)

protected $_pathToTemplates = DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR;

Share this post


Link to post
Share on other sites

For me it is also not working. I have changed it to:

protected $_pathToTemplates = '/templates/';

This is also working under windows. The \ (backslash) in windows only is necessary if you execute shell commands. Otherwise the forwardslashes are converted magically by PHP.

See also: http://php.net/manual/en/dir.constants.php

or here: http://alanhogan.com/tips/php/directory-separator-not-necessary

Edited by horst
added another link

Share this post


Link to post
Share on other sites

Thanks horst. I'll just change it, but still, i'm puzzled and would love to know the cause. 

I couldn't reproduce this, neither on linux nor windows.

Sometimes I just want to slap myself really hard... I did not get the error previously because I'm running PHP 5.6, where my code is allowed, but not in older versions. I'm already so used to 5.6 -.-

Prior to 5.6, properties are not allowed to be expressions (in my case, the concat of constants and strings).

Thanks guys & cheers

  • Like 1

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By Anssi
      A simple module to enable easy navigation between the public and the admin side of the site. After installation a green bar will appear to the upper side of the screen, containing a few navigation elements and displaying the PW version number.
      Heavily inspired by @apeisa's great AdminBar (Thanks!). I needed a bit simpler tool for my projects and as a result, this was made. Available on GitHub .

    • By Sebi
      I've created a small module which lets you define a timestamp after which a page should be accessible. In addition you can define a timestamp when the release should end and the page should not be accessable any more.
      Github: https://github.com/Sebiworld/PageAccessReleasetime
      Usage
      PageAccessReleasetime can be installed like every other module in ProcessWire. Check the following guide for detailed information: How-To Install or Uninstall Modules
      After that, you will find checkboxes for activating the releasetime-fields at the settings-tab of each page. You don't need to add the fields to your templates manually.
      Check e.g. the checkbox "Activate Releasetime from?" and fill in a date in the future. The page will not be accessable for your users until the given date is reached.
      If you have $config->pagefileSecure = true, the module will protect files of unreleased pages as well.
      How it works
      This module hooks into Page::viewable to prevent users to access unreleased pages:
      public function hookPageViewable($event) { $page = $event->object; $viewable = $event->return; if($viewable){ // If the page would be viewable, additionally check Releasetime and User-Permission $viewable = $this->canUserSee($page); } $event->return = $viewable; } To prevent access to the files of unreleased pages, we hook into Page::isPublic and ProcessPageView::sendFile.
      public function hookPageIsPublic($e) { $page = $e->object; if($e->return && $this->isReleaseTimeSet($page)) { $e->return = false; } } The site/assets/files/ directory of pages, which isPublic() returns false, will get a '-' as prefix. This indicates ProcessWire (with activated $config->pagefileSecure) to check the file's permissions via PHP before delivering it to the client.
      The check wether a not-public file should be accessable happens in ProcessPageView::sendFile. We throw an 404 Exception if the current user must not see the file.
      public function hookProcessPageViewSendFile($e) { $page = $e->arguments[0]; if(!$this->canUserSee($page)) { throw new Wire404Exception('File not found'); } } Additionally we hook into ProcessPageEdit::buildForm to add the PageAccessReleasetime fields to each page and move them to the settings tab.
      Limitations
      In the current version, releasetime-protected pages will appear in wire('pages')->find() queries. If you want to display a list of pages, where pages could be releasetime-protected, you should double-check with $page->viewable() wether the page can be accessed. $page->viewable() returns false, if the page is not released yet.
      If you have an idea how unreleased pages can be filtered out of ProcessWire selector queries, feel free to write an issue, comment or make a pull request!
    • By David Karich
      Thanks to the great Pro module "RepeaterMatrix" I have the possibility to create complex repeater items. With it I have created a quite powerful page builder. Many different content modules, with many more possible design options. The RepeaterMatrix module supports the cloning of items, but only within the same page. Now I often have the case that very design-intensive pages and items are created. If you want to use this module on a different page (e.g. in the same design), you have to rebuild each item manually every time.
      With this proof of concept I have created a module which adds the feature to copy a repeater item to the clipboard so that you can paste this item to another page with the same repeater field. The module has been developed very rudimentarily so far. It is currently not possible to copy nested items. There is also no check of Min/Max. You can also only copy items that have the same field on different pages. And surely you can solve all this more elegantly with AJAX. But personally I lack the deeper understanding of the repeaters. Also missing on the Javascript side are event triggers for the repeaters, which would make it easier. Like e.g. RepeaterItemInitReady or similar.
      it would be great if @ryan would implement this functionality in the core of RepeaterMatrix. I think he has better ways to implement this. Or what do you think, Ryan?
      Everybody is welcome to work on this module and improve it, if it should not be integrated into the matrix core. Therefore I put it for testing and as download on GitHub: https://github.com/FlipZoomMedia/InputfieldRepeaterMatrixDublicate
      You can best see the functionality in the screencast: 
       
    • By anderson
      Hi,
      Please take a look at this:
      https://templatemag.com/demo/Good/
      The upper nav bar, including dropdowns like "pages" and "portfolios", what do you call this whole thing? At first I guess it's called "dropdown nav bar", but seems not.
      AND of course, what's the simplest way/module to achieve this in PW?
      Thanks in advance.
    • By Sebi2020
      Hey, I'm new and I created a simple module for tagging pages because I didn't found a module for it (sadly this is not a core feature). This module is licensed under the GPL3 and cames with absolutly no warranty at all. You should test the module before using it in production environments. Currently it's an alpha release. if you like the module or have ideas for improvements feel free to post a comment. Currently this fieldtype is only compatible with the Inputfield I've created to because I haven't found  an Inputfield yet, that returns arrays from a single html input.
      Greetings Sebi2020
      FieldtypeTags.zip.asc
      InputfieldTagify.zip
      InputfieldTagify.zip.asc
      FieldtypeTags.zip