YaWK  24.1
Yet another WebKit
YAWK\WIDGETS\PLYR\PLAYER\plyr Class Reference

Plyr HTML5 Media Player Widget. More...

+ Inheritance diagram for YAWK\WIDGETS\PLYR\PLAYER\plyr:

Public Member Functions

 __construct ($db)
 Load all widget settings from database and fill object. More...
 
 checkMediaFileType ()
 Check and set media file type. More...
 
 checkTextTrack ()
 
 embedPlyr ()
 
 init ()
 Init example widget and call a function for demo purpose. More...
 
 setPoster ()
 
- Public Member Functions inherited from YAWK\widget
 getHeading ($heading, $subtext)
 Get widget heading and subtext, return headline. More...
 
 getWidgetSettingsArray ($db)
 Get widget settings and return it as array. More...
 
 printObject ()
 Print all object data. More...
 

Public Attributes

 $plyrAutoplay = false
 
 $plyrClickToPlay = true
 
 $plyrDisableContextMenu = true
 
 $plyrFiletype = ''
 
 $plyrHeading = ''
 
 $plyrHideControls = true
 
 $plyrMediaFile = ''
 
 $plyrPoster = ''
 
 $plyrPosterHtml = ''
 
 $plyrShowPosterOnEnd = false
 
 $plyrSubtext = ''
 
 $plyrTextTrackFile = ''
 
 $plyrTextTrackFileHtmlOutput = ''
 
 $plyrTextTrackLabel = ''
 
 $plyrTextTrackSrcLang = ''
 
 $plyrWidth = '100%'
 
 $widget = ''
 
- Public Attributes inherited from YAWK\widget
 $data
 
 $date_publish
 
 $date_unpublish
 
 $folder
 
 $id
 
 $marginBottom
 
 $marginTop
 
 $name
 
 $pageID
 
 $position
 
 $published
 
 $sort
 
 $widgetTitle
 
 $widgetType
 

Additional Inherited Members

- Static Public Member Functions inherited from YAWK\widget
static getAllSettingsIntoArray ($db, $widgetID)
 Returns an array with all widget settings data. More...
 
static getAllWidgetTypes ($db)
 Return all widget types as associative array. More...
 
static getCurrentWidgetPath ($db)
 return current widget path More...
 
static getFacebookLikeBox ()
 return the facebook likebox widget More...
 
static getLoginBox ()
 return the user login box widget More...
 
static loadWidgetsOfPage ($db, $page)
 Returns an array of all widgets that are linked with given page->id. More...
 

Detailed Description

Plyr HTML5 Media Player Widget.

Plyr Widget - html5 based video player

Plyr is a a simple, accessible and customisable and wide-known media player for HTML 5 Video, Audio, YouTube, and Vimeo. All you need is the url to your media file. As you wish, you can set some settings like width, height, poster image, media control functions, autoplay and much more.

Author
Daniel Retzl danie.nosp@m.lret.nosp@m.zl@gm.nosp@m.ail..nosp@m.com
Version
1.0.0

Definition at line 17 of file plyr.php.

Constructor & Destructor Documentation

◆ __construct()

YAWK\WIDGETS\PLYR\PLAYER\plyr::__construct (   $db)

Load all widget settings from database and fill object.

Parameters
object$dbDatabase Object

Load all widget settings on object init.

Definition at line 59 of file plyr.php.

61  {
62  // load this widget settings from db
63  $this->widget = new \YAWK\widget();
64  $settings = $this->widget->getWidgetSettingsArray($db);
65  foreach ($settings as $property => $value) {
66  $this->$property = $value;
67  }
if(isset($_POST['save'])) $settings
$value

References $db, $settings, $value, and YAWK\widget\getWidgetSettingsArray().

Member Function Documentation

◆ checkMediaFileType()

YAWK\WIDGETS\PLYR\PLAYER\plyr::checkMediaFileType ( )

Check and set media file type.

check and set media file type

Definition at line 90 of file plyr.php.

92  {
93  if (isset($this->plyrMediaFile) && (!empty($this->plyrMediaFile)))
94  {
95  if (strpos($this->plyrMediaFile, '.mp4') !== false)
96  {
97  $this->plyrFiletype = "video/mp4";
98  }
99  if (strpos($this->plyrMediaFile, '.webm') !== false)
100  {
101  $this->plyrFiletype = "video/webm";
102  }
103  }
104  else
105  {
106  echo "Plyr Error: unable to detect media file type - no file was set!";
107  }

Referenced by YAWK\WIDGETS\PLYR\PLAYER\plyr\init().

◆ checkTextTrack()

YAWK\WIDGETS\PLYR\PLAYER\plyr::checkTextTrack ( )

Definition at line 121 of file plyr.php.

123  {
124  // check if text track file, language and label are set
125  if (isset($this->plyrTextTrackFile) && (!empty($this->plyrTextTrackFile)))
126  { // language not found
127  if (!isset($this->plyrTextTrackSrcLang) || (empty($this->plyrTextTrackSrcLang)))
128  { // set default language:
129  $this->plyrTextTrackSrcLang = "en";
130  }
131  // label is not set
132  if (!isset($this->plyrTextTrackLabel) || (empty($this->plyrTextTrackLabel)))
133  { // set default label:
134  $this->plyrTextTrackLabel = "English";
135  }
136  // output text track html...
137  $this->plyrTextTrackFileHtmlOutput = "<track kind=\"captions\" label=\"$this->plyrTextTrackLabel\" srclang=\"$this->plyrTextTrackSrcLang\" src=\"$this->plyrTextTrackFile\" default>";
138  }
139  else
140  { // no text track is set, output nothing
141  $this->plyrTextTrackFileHtmlOutput = '';
142  }

Referenced by YAWK\WIDGETS\PLYR\PLAYER\plyr\init().

◆ embedPlyr()

YAWK\WIDGETS\PLYR\PLAYER\plyr::embedPlyr ( )

Definition at line 144 of file plyr.php.

146  {
147  echo '
148  <!-- output plyr html player -->
149  <section>
150  <video '.$this->plyrPosterHtml.' controls style="width: '.$this->plyrWidth.'">
151  <source src="'.$this->plyrMediaFile.'" type="'.$this->plyrFiletype.'">
152  <!-- Text track file -->
153  '.$this->plyrTextTrackFileHtmlOutput.'
154  <!-- Fallback for browsers that dont support the <video> element -->
155  <a href="'.$this->plyrMediaFile.'" download>Download</a>
156  </video>
157  </section>
158 
159  <!-- plyr js -->
160  <script src="system/widgets/plyr/js/plyr.js"></script>
161  <!-- run plyr -->
162  <script>
163  plyr.setup({
164  "autoplay":'.$this->plyrAutoplay.',
165  "disableContextMenu": '.$this->plyrDisableContextMenu.',
166  "hideControls": '.$this->plyrHideControls.',
167  "showPosterOnEnd": '.$this->plyrShowPosterOnEnd.',
168  "clickToPlay": '.$this->plyrClickToPlay.'
169  });
170  </script>
171  <!-- plyr css -->
172  <link type="text/css" rel="stylesheet" href="system/widgets/plyr/js/plyr.css">
173 
174  <!-- Rangetouch to fix <input type="range"> on touch devices (see https://rangetouch.com) -->
175  <script src="system/widgets/plyr/js/rangetouch.js" async></script>';

Referenced by YAWK\WIDGETS\PLYR\PLAYER\plyr\init().

◆ init()

YAWK\WIDGETS\PLYR\PLAYER\plyr::init ( )

Init example widget and call a function for demo purpose.

Example Widget Init

Definition at line 73 of file plyr.php.

75  { // call any functions or methods you have previously defined in this class
76  echo $this->getHeading($this->plyrHeading, $this->plyrSubtext);
77  // check and set media file type
78  $this->checkMediaFileType();
79  // check and set poster image
80  $this->setPoster();
81  // check and set text track
82  $this->checkTextTrack();
83  // finally: embed plyr media player
84  $this->embedPlyr();
checkMediaFileType()
Check and set media file type.
Definition: plyr.php:90
getHeading($heading, $subtext)
Get widget heading and subtext, return headline.
Definition: widget.php:669

References YAWK\WIDGETS\PLYR\PLAYER\plyr\checkMediaFileType(), YAWK\WIDGETS\PLYR\PLAYER\plyr\checkTextTrack(), YAWK\WIDGETS\PLYR\PLAYER\plyr\embedPlyr(), YAWK\widget\getHeading(), and YAWK\WIDGETS\PLYR\PLAYER\plyr\setPoster().

◆ setPoster()

YAWK\WIDGETS\PLYR\PLAYER\plyr::setPoster ( )

Definition at line 109 of file plyr.php.

111  {
112  if (isset($this->plyrPoster) && (!empty($this->plyrPoster)))
113  { // poster is set...
114  $this->plyrPosterHtml = "poster=\"$this->plyrPoster\"";
115  }
116  else
117  { // no poster set, leave output empty
118  $this->plyrPosterHtml = "poster=\"\"";
119  }

Referenced by YAWK\WIDGETS\PLYR\PLAYER\plyr\init().

Member Data Documentation

◆ $plyrAutoplay

YAWK\WIDGETS\PLYR\PLAYER\plyr::$plyrAutoplay = false
Parameters
boolAutoplay true|false

Definition at line 44 of file plyr.php.

◆ $plyrClickToPlay

YAWK\WIDGETS\PLYR\PLAYER\plyr::$plyrClickToPlay = true
Parameters
boolClick to play true|false

Definition at line 46 of file plyr.php.

◆ $plyrDisableContextMenu

YAWK\WIDGETS\PLYR\PLAYER\plyr::$plyrDisableContextMenu = true
Parameters
boolContext Menus enabled?

Definition at line 48 of file plyr.php.

◆ $plyrFiletype

YAWK\WIDGETS\PLYR\PLAYER\plyr::$plyrFiletype = ''
Parameters
stringThe media file type

Definition at line 28 of file plyr.php.

◆ $plyrHeading

YAWK\WIDGETS\PLYR\PLAYER\plyr::$plyrHeading = ''
Parameters
stringTitle that will be shown above widget

Definition at line 22 of file plyr.php.

◆ $plyrHideControls

YAWK\WIDGETS\PLYR\PLAYER\plyr::$plyrHideControls = true
Parameters
boolHide player controls true|false

Definition at line 50 of file plyr.php.

◆ $plyrMediaFile

YAWK\WIDGETS\PLYR\PLAYER\plyr::$plyrMediaFile = ''
Parameters
stringURL of the media file to play

Definition at line 26 of file plyr.php.

◆ $plyrPoster

YAWK\WIDGETS\PLYR\PLAYER\plyr::$plyrPoster = ''
Parameters
stringPoster Image

Definition at line 32 of file plyr.php.

◆ $plyrPosterHtml

YAWK\WIDGETS\PLYR\PLAYER\plyr::$plyrPosterHtml = ''
Parameters
stringPoster Html Markup

Definition at line 34 of file plyr.php.

◆ $plyrShowPosterOnEnd

YAWK\WIDGETS\PLYR\PLAYER\plyr::$plyrShowPosterOnEnd = false
Parameters
boolDisplay poster on video end true|false

Definition at line 52 of file plyr.php.

◆ $plyrSubtext

YAWK\WIDGETS\PLYR\PLAYER\plyr::$plyrSubtext = ''
Parameters
stringSubtext will be displayed beside title

Definition at line 24 of file plyr.php.

◆ $plyrTextTrackFile

YAWK\WIDGETS\PLYR\PLAYER\plyr::$plyrTextTrackFile = ''
Parameters
stringText Track File

Definition at line 36 of file plyr.php.

◆ $plyrTextTrackFileHtmlOutput

YAWK\WIDGETS\PLYR\PLAYER\plyr::$plyrTextTrackFileHtmlOutput = ''
Parameters
stringText Track Html Markup

Definition at line 38 of file plyr.php.

◆ $plyrTextTrackLabel

YAWK\WIDGETS\PLYR\PLAYER\plyr::$plyrTextTrackLabel = ''
Parameters
stringText Track Label

Definition at line 40 of file plyr.php.

◆ $plyrTextTrackSrcLang

YAWK\WIDGETS\PLYR\PLAYER\plyr::$plyrTextTrackSrcLang = ''
Parameters
stringText Track Src Language

Definition at line 42 of file plyr.php.

◆ $plyrWidth

YAWK\WIDGETS\PLYR\PLAYER\plyr::$plyrWidth = '100%'
Parameters
stringPlayer width in pixel or %

Definition at line 30 of file plyr.php.

◆ $widget

YAWK\WIDGETS\PLYR\PLAYER\plyr::$widget = ''
Parameters
objectglobal widget object data

Definition at line 20 of file plyr.php.


The documentation for this class was generated from the following file: