YaWK  24.1
Yet another WebKit
YAWK\WIDGETS\JPLAYER\VIDEO\jPlayerVideo Class Reference

Public Member Functions

 getPlayerSettings ($db, $widgetID)
 
 getVideoFiles ($mediaFolder, $folder, $poster, $download)
 

Public Attributes

 $download
 
 $downloadJSON
 
 $folder
 
 $mediaFolder
 
 $playerSettings
 
 $poster
 
 $posterJSON
 

Detailed Description

Definition at line 3 of file jplayer_video.class.php.

Member Function Documentation

◆ getPlayerSettings()

YAWK\WIDGETS\JPLAYER\VIDEO\jPlayerVideo::getPlayerSettings (   $db,
  $widgetID 
)

Definition at line 14 of file jplayer_video.class.php.

15  {
16  // ... method call: \YAWK\widgets::getWidgetSettingsIntoArray($db, $widgetID)
17  // return $playerSettingsArray();
18  }

◆ getVideoFiles()

YAWK\WIDGETS\JPLAYER\VIDEO\jPlayerVideo::getVideoFiles (   $mediaFolder,
  $folder,
  $poster,
  $download 
)

Definition at line 20 of file jplayer_video.class.php.

21  {
22  $this->mediaFolder = $mediaFolder;
23  $this->folder = $folder;
24  $this->poster = $poster;
25  $this->download = $download;
26 
27  // optional: add files to array while processing
28  // $filesArray = array();
29 
30  // media folder empty or missing
31  if (!isset($this->mediaFolder) || (empty($this->mediaFolder)))
32  { // set default value
33  $this->mediaFolder = "media/video/";
34  }
35  // user folder empty or missing
36  if (!isset($this->folder) || (empty($this->folder)))
37  {
38  // if no user folder is set: do nothing
39  // in that case, we expect the files to be in mediaFolder
40  }
41  else
42  { // mediafolder AND folder are set, build new mediaFolder string
43  $this->mediaFolder = $this->mediaFolder . $this->folder;
44  }
45  // if poster image is set
46  if (isset($this->poster) && (!empty($this->poster)))
47  {
48  // prepare json poster output...
49  $this->posterJSON = ",poster:\"$this->poster\"";
50  }
51  else
52  { // no poster was set - leave empty
53  $this->posterJSON = "";
54  }
55 
56  // check if download is allowed
57  if (isset($this->download) && (!empty($this->download)))
58  { // download is enabled
59  if ($this->download === "true")
60  {
61  // prepare download link JSON data
62  $this->downloadJSON = ",free:\"$this->download\"";
63  }
64  else
65  { // download not allowed
66  $this->downloadJSON = "";
67  }
68  }
69 
70  // OK, lets go with searching for files...
71  // is it a directory?
72  if (is_dir($this->mediaFolder))
73  {
74  // open media folder
75  if ($dh = opendir($this->mediaFolder))
76  { // loop trough
77  while (($file = readdir($dh)) != false)
78  { // check found element
79  if ($file == "." || $file == ".." || is_dir($file))
80  {
81  // if is dot or folder
82  // do nothing
83  }
84  else // it is a file
85  {
86  // generate title string from filename
87  $title = $file;
88 
89  // process .M4V files
90  if (strpos($file, ".m4v") || (strpos($file, ".M4V")) !== false)
91  { // encode filename
92  $file = rawurlencode($file);
93  // remove file extension from title string
94  $title = rtrim($title, ".m4v");
95  $title = rtrim($title, ".M4V");
96  // output JSON data for M4V files
97  echo "{ name:\"$title\",m4v:\"$this->mediaFolder/$file\" $this->downloadJSON $this->posterJSON },\n\r";
98  // optional: add m4v files to filesArray
99  // $filesArray[] = array("title" => $title, "m4v" => $file);
100  }
101 
102  // process .OGV files
103  else if (strpos($file, ".ogv") || (strpos($file, ".OGV")) !== false)
104  { // encode filename
105  $file = rawurlencode($file);
106  // remove file extension from title string
107  $title = rtrim($title, ".ogv");
108  $title = rtrim($title, ".OGV");
109  // output JSON data for OGV files
110  echo "{ name:\"$title\",ogv:\"$this->mediaFolder/$file\" $this->downloadJSON $this->posterJSON },\n\r";
111  // optional: add ogv files to filesArray
112  // $filesArray[] = array("title" => $title, "ogv" => $file);
113  }
114  // process .FLV files
115  else if (strpos($file, ".flv") || (strpos($file, ".FLV")) !== false)
116  { // encode filename
117  $file = rawurlencode($file);
118  // remove file extension from title string
119  $title = rtrim($title, ".flv");
120  $title = rtrim($title, ".FLV");
121  // output JSON data for FLV files
122  echo "{ name:\"$title\",flv:\"$this->mediaFolder/$file\" $this->downloadJSON $this->posterJSON },\n\r";
123  // optional: add FLV files to filesArray
124  // $filesArray[] = array("title" => $title, "flv" => $file);
125  }
126  // process .MPG files
127  else if (strpos($file, ".mpg") || (strpos($file, ".MPG")) !== false)
128  { // encode filename
129  $file = rawurlencode($file);
130  // remove file extension from title string
131  $title = rtrim($title, ".mpg");
132  $title = rtrim($title, ".MPG");
133  // output JSON data for MPG files
134  echo "{ name:\"$title\",mpg:\"$this->mediaFolder/$file\" $this->downloadJSON $this->posterJSON },\n\r";
135  // optional: add MPG files to filesArray
136  // $filesArray[] = array("title" => $title, "mpg" => $file);
137  }
138  // process .MP4 files
139  else if (strpos($file, ".mp4") || (strpos($file, ".MP4")) !== false)
140  { // encode filename
141  $file = rawurlencode($file);
142  // remove file extension from title string
143  $title = rtrim($title, ".mp4");
144  $title = rtrim($title, ".MP4");
145  // output JSON data for MP4 files
146  echo "{ name:\"$title\",mp4:\"$this->mediaFolder/$file\" $this->downloadJSON $this->posterJSON },\n\r";
147  // optional: add MP4 files to filesArray
148  // $filesArray[] = array("title" => $title, "mp4" => $file);
149  }
150  }
151  }
152  }
153  else
154  { // could not open directory, abort
155  // die ("could not open directory $this->mediaFolder - check permissions!");
156  return false;
157  // \YAWK\alert::draw("danger", "ERROR: Could not open directory $this->mediaFolder", "Please check file and / or folder access permissions!", "", "");
158  }
159  }
160  else
161  { // directory not exists, abort
162  // return false; // die ("folder $this->mediaFolder does not exist!");
163  // \YAWK\alert::draw("danger", "ERROR: Could not open directory $this->mediaFolder", "Directory does not exist!", "", "");
164  }
165  } // end function getFiles

References YAWK\WIDGETS\JPLAYER\VIDEO\jPlayerVideo\$download, YAWK\WIDGETS\JPLAYER\VIDEO\jPlayerVideo\$folder, YAWK\WIDGETS\JPLAYER\VIDEO\jPlayerVideo\$mediaFolder, and YAWK\WIDGETS\JPLAYER\VIDEO\jPlayerVideo\$poster.

Member Data Documentation

◆ $download

YAWK\WIDGETS\JPLAYER\VIDEO\jPlayerVideo::$download

◆ $downloadJSON

YAWK\WIDGETS\JPLAYER\VIDEO\jPlayerVideo::$downloadJSON

Definition at line 11 of file jplayer_video.class.php.

◆ $folder

YAWK\WIDGETS\JPLAYER\VIDEO\jPlayerVideo::$folder

◆ $mediaFolder

YAWK\WIDGETS\JPLAYER\VIDEO\jPlayerVideo::$mediaFolder
  • Parameters
    stringcurrent user name

Definition at line 6 of file jplayer_video.class.php.

Referenced by YAWK\WIDGETS\JPLAYER\VIDEO\jPlayerVideo\getVideoFiles().

◆ $playerSettings

YAWK\WIDGETS\JPLAYER\VIDEO\jPlayerVideo::$playerSettings

Definition at line 12 of file jplayer_video.class.php.

◆ $poster

YAWK\WIDGETS\JPLAYER\VIDEO\jPlayerVideo::$poster

◆ $posterJSON

YAWK\WIDGETS\JPLAYER\VIDEO\jPlayerVideo::$posterJSON

Definition at line 9 of file jplayer_video.class.php.


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