ILIAS  release_4-4 Revision
All Data Structures Namespaces Files Functions Variables Modules Pages
ilMediaPlayerGUI Class Reference

User interface for media player. More...

+ Collaboration diagram for ilMediaPlayerGUI:

Public Member Functions

 __construct ($a_id="", $a_event_callback_url="")
 
 setFile ($a_file)
 Set File. More...
 
 getFile ()
 Get File. More...
 
 setAlternativeVideoFile ($a_val)
 Set alternative video file. More...
 
 getAlternativeVideoFile ()
 Get alternative video file. More...
 
 setAlternativeVideoMimeType ($a_val)
 Set alternative video mime type. More...
 
 getAlternativeVideoMimeType ()
 Get alternative video mime type. More...
 
 setDisplayHeight ($dHeight)
 set display height More...
 
 getDisplayHeight ()
 return display height of player. More...
 
 setDisplayWidth ($a_val)
 Set display width. More...
 
 getDisplayWidth ()
 Get display width. More...
 
 setMimeType ($value)
 
 setVideoPreviewPic ($a_val, $a_alt="")
 Set video preview picture. More...
 
 getVideoPreviewPic ()
 Get video preview picture. More...
 
 setTitle ($a_val)
 Set Title. More...
 
 getTitle ()
 Get Title. More...
 
 setDescription ($a_val)
 Set description. More...
 
 getDescription ()
 Get description. More...
 
 setForceAudioPreview ($a_val)
 Set force audio preview. More...
 
 getForceAudioPreview ()
 Get force audio preview. More...
 
 setDownloadLink ($a_val)
 Set download link. More...
 
 getDownloadLink ()
 Get download link. More...
 
 getMp3PlayerHtml ($a_preview=false)
 Get Html for MP3 Player. More...
 
 getPreviewHtml ()
 Get preview html. More...
 

Protected Attributes

 $file
 
 $displayHeight = "480"
 
 $displayWidth = "640"
 
 $mimeType
 
 $current_nr
 
 $title
 
 $description
 
 $event_callback_url = ""
 
 $download_link = ""
 

Static Protected Attributes

static $nr = 1
 
static $lightbox_initialized = false
 

Detailed Description

User interface for media player.

Wraps flash mp3 player and similar tools.

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id$

Definition at line 13 of file class.ilMediaPlayerGUI.php.

Constructor & Destructor Documentation

◆ __construct()

ilMediaPlayerGUI::__construct (   $a_id = "",
  $a_event_callback_url = "" 
)

Definition at line 27 of file class.ilMediaPlayerGUI.php.

28  {
29  $this->id = $a_id;
30  $this->event_callback_url = $a_event_callback_url;
31  $this->current_nr = self::$nr;
32  self::$nr++;
33  }

Member Function Documentation

◆ getAlternativeVideoFile()

ilMediaPlayerGUI::getAlternativeVideoFile ( )

Get alternative video file.

Returns
string alternative video file

Definition at line 70 of file class.ilMediaPlayerGUI.php.

Referenced by getMp3PlayerHtml().

71  {
72  return $this->alt_video_file;
73  }
+ Here is the caller graph for this function:

◆ getAlternativeVideoMimeType()

ilMediaPlayerGUI::getAlternativeVideoMimeType ( )

Get alternative video mime type.

Returns
string alternative video mime type

Definition at line 90 of file class.ilMediaPlayerGUI.php.

Referenced by getMp3PlayerHtml().

91  {
92  return $this->alt_video_mime;
93  }
+ Here is the caller graph for this function:

◆ getDescription()

ilMediaPlayerGUI::getDescription ( )

Get description.

Returns
string description

Definition at line 193 of file class.ilMediaPlayerGUI.php.

References $description.

Referenced by getMp3PlayerHtml().

194  {
195  return $this->description;
196  }
+ Here is the caller graph for this function:

◆ getDisplayHeight()

ilMediaPlayerGUI::getDisplayHeight ( )

return display height of player.

Returns
int

Definition at line 109 of file class.ilMediaPlayerGUI.php.

References $displayHeight.

Referenced by getMp3PlayerHtml().

109  {
110  return $this->displayHeight;
111  }
+ Here is the caller graph for this function:

◆ getDisplayWidth()

ilMediaPlayerGUI::getDisplayWidth ( )

Get display width.

Returns
string display width

Definition at line 128 of file class.ilMediaPlayerGUI.php.

References $displayWidth.

Referenced by getMp3PlayerHtml().

129  {
130  return $this->displayWidth;
131  }
+ Here is the caller graph for this function:

◆ getDownloadLink()

ilMediaPlayerGUI::getDownloadLink ( )

Get download link.

Returns
string download link

Definition at line 233 of file class.ilMediaPlayerGUI.php.

References $download_link.

Referenced by getMp3PlayerHtml().

234  {
235  return $this->download_link;
236  }
+ Here is the caller graph for this function:

◆ getFile()

ilMediaPlayerGUI::getFile ( )

Get File.

Returns
string File

Definition at line 50 of file class.ilMediaPlayerGUI.php.

References $file.

Referenced by getMp3PlayerHtml().

51  {
52  return $this->file;
53  }
+ Here is the caller graph for this function:

◆ getForceAudioPreview()

ilMediaPlayerGUI::getForceAudioPreview ( )

Get force audio preview.

Returns
boolean force audio preview picture

Definition at line 213 of file class.ilMediaPlayerGUI.php.

Referenced by getMp3PlayerHtml().

214  {
215  return $this->force_audio_preview;
216  }
+ Here is the caller graph for this function:

◆ getMp3PlayerHtml()

ilMediaPlayerGUI::getMp3PlayerHtml (   $a_preview = false)

Get Html for MP3 Player.

Definition at line 241 of file class.ilMediaPlayerGUI.php.

References $lng, $mimeType, $r, $tpl, getAlternativeVideoFile(), getAlternativeVideoMimeType(), getDescription(), getDisplayHeight(), getDisplayWidth(), getDownloadLink(), getFile(), ilPlayerUtil\getFlashVideoPlayerFilename(), getForceAudioPreview(), ilUtil\getImagePath(), ilObjMediaObject\getMimeType(), getTitle(), getVideoPreviewPic(), ilYuiUtil\initConnection(), and ilPlayerUtil\initMediaElementJs().

Referenced by getPreviewHtml().

242  {
243  global $tpl, $lng;
244 
245  include_once("./Services/YUI/classes/class.ilYuiUtil.php");
247 
248  $tpl->addJavascript("./Services/MediaObjects/js/MediaObjects.js");
249 
250  if (!self::$lightbox_initialized)
251  {
252  include_once("./Services/UIComponent/Lightbox/classes/class.ilLightboxGUI.php");
253  $lb = new ilLightboxGUI("media_lightbox");
254  $lb->setWidth("660px");
255  $lb->addLightbox();
256  self::$lightbox_initialized = true;
257  }
258 
259  require_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
260  include_once("./Services/MediaObjects/classes/class.ilExternalMediaAnalyzer.php");
261 
262  // youtube
263 /* if (ilExternalMediaAnalyzer::isYouTube($this->getFile()))
264  {
265  $p = ilExternalMediaAnalyzer::extractYouTubeParameters($this->getFile());
266  $html = '<object width="320" height="240">'.
267  '<param name="movie" value="http://www.youtube.com/v/'.$p["v"].'?fs=1">'.
268  '</param><param name="allowFullScreen" value="true"></param>'.
269  '<param name="allowscriptaccess" value="always">'.
270  '</param><embed src="http://www.youtube.com/v/'.$p["v"].'?fs=1" '.
271  'type="application/x-shockwave-flash" allowscriptaccess="always" '.
272  'allowfullscreen="true" width="320" height="240"></embed></object>';
273  return $html;
274  }
275 
276  // vimeo
277  if (ilExternalMediaAnalyzer::isVimeo($this->getFile()))
278  {
279  $p = ilExternalMediaAnalyzer::extractVimeoParameters($this->getFile());
280 
281  $html = '<iframe src="http://player.vimeo.com/video/'.$p["id"].'" width="320" height="240" '.
282  'frameborder="0"></iframe>';
283 
284  return $html;
285  }
286 */
287  $mimeType = $this->mimeType == "" ? ilObjMediaObject::getMimeType(basename($this->getFile())) : $this->mimeType;
288  include_once("./Services/MediaObjects/classes/class.ilPlayerUtil.php");
289 
290  // video tag
291  if (in_array($mimeType, array("video/mp4", "video/m4v", "video/rtmp",
292  "video/x-flv", "video/webm", "video/youtube", "video/vimeo", "video/ogg")))
293  {
295 
296  if ($mimeType == "video/quicktime")
297  {
298  $mimeType = "video/mov";
299  }
300 
301  $mp_tpl = new ilTemplate("tpl.flv_player.html", true, true, "Services/MediaObjects");
302 
303  // preview
304  if ($a_preview)
305  {
306  if ($this->getDownloadLink() != "")
307  {
308  $mp_tpl->setCurrentBlock("download");
309  $mp_tpl->setVariable("TXT_DOWNLOAD", $lng->txt("download"));
310  $mp_tpl->setVariable("HREF_DOWNLOAD", $this->getDownloadLink());
311  $mp_tpl->parseCurrentBlock();
312  }
313 
314  $mp_tpl->setCurrentBlock("preview");
315  if ($this->getVideoPreviewPic() != "")
316  {
317  $mp_tpl->setVariable("IMG_SRC", $this->getVideoPreviewPic());
318  }
319  else
320  {
321  $mp_tpl->setVariable("IMG_SRC", ilUtil::getImagePath("mcst_preview.png"));
322  }
323  $mp_tpl->setVariable("IMG_ALT", $this->video_preview_pic_alt);
324  $mp_tpl->setVariable("PTITLE", $this->getTitle());
325  $mp_tpl->parseCurrentBlock();
326  }
327 
328  // sources
329  $mp_tpl->setCurrentBlock("source");
330  $mp_tpl->setVariable("FILE", $this->getFile());
331  $mp_tpl->setVariable("MIME", $mimeType);
332  $mp_tpl->parseCurrentBlock();
333 
334  if (in_array($this->getAlternativeVideoMimeType(), array("video/mp4", "video/webm")))
335  {
336  $mp_tpl->setCurrentBlock("source");
337  $mp_tpl->setVariable("FILE", $this->getAlternativeVideoFile());
338  $mp_tpl->setVariable("MIME", $this->getAlternativeVideoMimeType());
339  $mp_tpl->parseCurrentBlock();
340  }
341 
342  $mp_tpl->setCurrentBlock("mejs_video");
343 
344  if ($a_preview)
345  {
346  $mp_tpl->setVariable("CLASS", "ilNoDisplay");
347  }
348 
349  $mp_tpl->setVariable("PLAYER_NR", $this->id."_".$this->current_nr);
350  $mp_tpl->setVariable("EVENT_URL", $this->event_callback_url);
351  $height = $this->getDisplayHeight();
352  $width = $this->getDisplayWidth();
353  if (is_int(strpos($mimeType,"audio/mpeg")))
354  {
355  $height = "30";
356  }
357 
358  $mp_tpl->setVariable("DISPLAY_HEIGHT", $height);
359  $mp_tpl->setVariable("DISPLAY_WIDTH", $width);
360  $mp_tpl->setVariable("PREVIEW_PIC", $this->getVideoPreviewPic());
361  $mp_tpl->setVariable("SWF_FILE", ilPlayerUtil::getFlashVideoPlayerFilename(true));
362  $mp_tpl->setVariable("FFILE", $this->getFile());
363  $mp_tpl->setVariable("TITLE", $this->getTitle());
364  $mp_tpl->setVariable("DESCRIPTION", $this->getDescription());
365  $mp_tpl->parseCurrentBlock();
366  $r = $mp_tpl->get();
367 //echo htmlentities($r);
368  return $r;
369  }
370 
371  // audio/mpeg
372  if (is_int(strpos($mimeType,"audio/mpeg")) ||
373  in_array($mimeType, array("application/ogg", "audio/ogg")))
374  {
376  $mp_tpl = new ilTemplate("tpl.flv_player.html", true, true, "Services/MediaObjects");
377  $preview_output = false;
378  if ($this->getVideoPreviewPic() != "" || $this->getForceAudioPreview())
379  {
380  if ($this->getDownloadLink() != "")
381  {
382  $mp_tpl->setCurrentBlock("adownload");
383  $mp_tpl->setVariable("TXT_DOWNLOAD", $lng->txt("download"));
384  $mp_tpl->setVariable("HREF_DOWNLOAD", $this->getDownloadLink());
385  $mp_tpl->parseCurrentBlock();
386  }
387 
388  $mp_tpl->setCurrentBlock("apreview");
389  if ($this->getVideoPreviewPic() != "")
390  {
391  $mp_tpl->setVariable("IMG_SRC", $this->getVideoPreviewPic());
392  }
393  else
394  {
395  $mp_tpl->setVariable("IMG_SRC", ilUtil::getImagePath("mcst_preview.png"));
396  }
397  $mp_tpl->setVariable("PTITLE", $this->getTitle());
398  $mp_tpl->parseCurrentBlock();
399  $preview_output = true;
400  }
401  $mp_tpl->setCurrentBlock("audio");
402  if ($preview_output)
403  {
404  $mp_tpl->setVariable("ASTYLE", "margin-top:-30px");
405  }
406  $mp_tpl->setVariable("AFILE", $this->getFile());
407  $mp_tpl->setVariable("APLAYER_NR", $this->id."_".$this->current_nr);
408  $mp_tpl->setVariable("AEVENT_URL", $this->event_callback_url);
409  $mp_tpl->setVariable("AHEIGHT", "30");
410  $mp_tpl->setVariable("AWIDTH", "320");
411  $mp_tpl->parseCurrentBlock();
412  return $mp_tpl->get();
413  }
414 
415  // images
416  if (is_int(strpos($mimeType,"image/")))
417  {
418  $mp_tpl = new ilTemplate("tpl.flv_player.html", true, true, "Services/MediaObjects");
419 
420  if ($this->getDownloadLink() != "")
421  {
422  $mp_tpl->setCurrentBlock("idownload");
423  $mp_tpl->setVariable("TXT_DOWNLOAD", $lng->txt("download"));
424  $mp_tpl->setVariable("HREF_DOWNLOAD", $this->getDownloadLink());
425  $mp_tpl->parseCurrentBlock();
426  }
427 
428  $mp_tpl->setCurrentBlock("ipreview");
429  if ($this->getVideoPreviewPic() != "")
430  {
431  $mp_tpl->setVariable("IMG_SRC", $this->getVideoPreviewPic());
432  }
433  else
434  {
435  $mp_tpl->setVariable("IMG_SRC", $this->getFile());
436  }
437  $mp_tpl->setVariable("PTITLE", $this->getTitle());
438  $mp_tpl->parseCurrentBlock();
439 
440  $mp_tpl->setCurrentBlock("image");
441  $mp_tpl->setVariable("IFILE", $this->getFile());
442  $mp_tpl->setVariable("IPLAYER_NR", $this->id."_".$this->current_nr);
443  $mp_tpl->setVariable("ITITLE", $this->getTitle());
444  $mp_tpl->setVariable("IDESCRIPTION", $this->getDescription());
445 
446  $height = $this->getDisplayHeight();
447  $width = $this->getDisplayWidth();
448 
449  $mp_tpl->setVariable("IHEIGHT", $height);
450  $mp_tpl->setVariable("IWIDTH", $width);
451  $mp_tpl->parseCurrentBlock();
452 
453  return $mp_tpl->get();
454  }
455 
456  // fallback, no preview mode
457  $mimeType = $this->mimeType == "" ? ilObjMediaObject::getMimeType(basename($this->getFile())) : $this->mimeType;
458  if (strpos($mimeType,"flv") === false
459  && strpos($mimeType,"audio/mpeg") === false
460  && strpos($mimeType,"image/png") === false
461  && strpos($mimeType,"image/gif") === false)
462  {
463 
464  $html = '<embed src="'.$this->getFile().'" '.
465  'type="'.$mimeType.'" '.
466  'ShowControls="1" '.
467  'autoplay="false" autostart="false" '.
468  'width="320" height="240" scale="aspect" ></embed>';
469  return $html;
470  }
471 
472 return;
473  $tpl->addJavaScript("./Services/MediaObjects/flash_flv_player/swfobject.js");
474  $mp_tpl = new ilTemplate("tpl.flv_player.html", true, true, "Services/MediaObjects");
475  $mp_tpl->setCurrentBlock("default");
476  $mp_tpl->setVariable("FILE", urlencode($this->getFile()));
477  $mp_tpl->setVariable("PLAYER_NR", $this->current_nr);
478  $mp_tpl->setVariable("DISPLAY_HEIGHT", strpos($mimeType,"audio/mpeg") === false ? "240" : "20");
479  $mp_tpl->setVariable("DISPLAY_WIDTH", "320");
480  $mp_tpl->parseCurrentBlock();
481  return $mp_tpl->get();
482  }
getVideoPreviewPic()
Get video preview picture.
getDisplayHeight()
return display height of player.
getDescription()
Get description.
getDownloadLink()
Get download link.
static initConnection()
Init YUI Connection module.
static getFlashVideoPlayerFilename($a_fullpath=false)
Get flash video player file name.
Lighbox handling.
getAlternativeVideoMimeType()
Get alternative video mime type.
static getMimeType($a_file)
get mime type for file
getAlternativeVideoFile()
Get alternative video file.
static getImagePath($img, $module_path="", $mode="output", $offline=false)
get image path (for images located in a template directory)
special template class to simplify handling of ITX/PEAR
static initMediaElementJs($a_tpl=null)
Init mediaelement.js scripts.
if(isset($_FILES['img_file']['size']) && $_FILES['img_file']['size'] > 0) $tpl
global $lng
Definition: privfeed.php:40
getDisplayWidth()
Get display width.
getForceAudioPreview()
Get force audio preview.
$r
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getPreviewHtml()

ilMediaPlayerGUI::getPreviewHtml ( )

Get preview html.

Parameters

Definition at line 490 of file class.ilMediaPlayerGUI.php.

References getMp3PlayerHtml().

491  {
492  return $this->getMp3PlayerHtml(true);
493  }
getMp3PlayerHtml($a_preview=false)
Get Html for MP3 Player.
+ Here is the call graph for this function:

◆ getTitle()

ilMediaPlayerGUI::getTitle ( )

Get Title.

Returns
string title

Definition at line 173 of file class.ilMediaPlayerGUI.php.

References $title.

Referenced by getMp3PlayerHtml().

174  {
175  return $this->title;
176  }
+ Here is the caller graph for this function:

◆ getVideoPreviewPic()

ilMediaPlayerGUI::getVideoPreviewPic ( )

Get video preview picture.

Returns
string video preview picture

Definition at line 153 of file class.ilMediaPlayerGUI.php.

Referenced by getMp3PlayerHtml().

154  {
155  return $this->video_preview_pic;
156  }
+ Here is the caller graph for this function:

◆ setAlternativeVideoFile()

ilMediaPlayerGUI::setAlternativeVideoFile (   $a_val)

Set alternative video file.

Parameters
string$a_valalternative video file

Definition at line 60 of file class.ilMediaPlayerGUI.php.

61  {
62  $this->alt_video_file = $a_val;
63  }

◆ setAlternativeVideoMimeType()

ilMediaPlayerGUI::setAlternativeVideoMimeType (   $a_val)

Set alternative video mime type.

Parameters
string$a_valalternative video mime type

Definition at line 80 of file class.ilMediaPlayerGUI.php.

81  {
82  $this->alt_video_mime = $a_val;
83  }

◆ setDescription()

ilMediaPlayerGUI::setDescription (   $a_val)

Set description.

Parameters
string$a_valdescription

Definition at line 183 of file class.ilMediaPlayerGUI.php.

184  {
185  $this->description = $a_val;
186  }

◆ setDisplayHeight()

ilMediaPlayerGUI::setDisplayHeight (   $dHeight)

set display height

Parameters
int$dHeight

Definition at line 100 of file class.ilMediaPlayerGUI.php.

100  {
101  $this->displayHeight = $dHeight;
102  }

◆ setDisplayWidth()

ilMediaPlayerGUI::setDisplayWidth (   $a_val)

Set display width.

Parameters
string$a_valdisplay width

Definition at line 118 of file class.ilMediaPlayerGUI.php.

119  {
120  $this->displayWidth = $a_val;
121  }

◆ setDownloadLink()

ilMediaPlayerGUI::setDownloadLink (   $a_val)

Set download link.

Parameters
string$a_valdownload link

Definition at line 223 of file class.ilMediaPlayerGUI.php.

224  {
225  $this->download_link = $a_val;
226  }

◆ setFile()

ilMediaPlayerGUI::setFile (   $a_file)

Set File.

Parameters
string$a_fileFile

Definition at line 40 of file class.ilMediaPlayerGUI.php.

Referenced by ilObjMediaCastGUI\showGallery().

41  {
42  $this->file = $a_file;
43  }
+ Here is the caller graph for this function:

◆ setForceAudioPreview()

ilMediaPlayerGUI::setForceAudioPreview (   $a_val)

Set force audio preview.

Parameters
boolean$a_valforce audio preview picture

Definition at line 203 of file class.ilMediaPlayerGUI.php.

204  {
205  $this->force_audio_preview = $a_val;
206  }

◆ setMimeType()

ilMediaPlayerGUI::setMimeType (   $value)

Definition at line 133 of file class.ilMediaPlayerGUI.php.

133  {
134  $this->mimeType = $value;
135  }

◆ setTitle()

ilMediaPlayerGUI::setTitle (   $a_val)

Set Title.

Parameters
string$a_valtitle

Definition at line 163 of file class.ilMediaPlayerGUI.php.

164  {
165  $this->title = $a_val;
166  }

◆ setVideoPreviewPic()

ilMediaPlayerGUI::setVideoPreviewPic (   $a_val,
  $a_alt = "" 
)

Set video preview picture.

Parameters
string$a_valvideo preview picture

Definition at line 142 of file class.ilMediaPlayerGUI.php.

143  {
144  $this->video_preview_pic = $a_val;
145  $this->video_preview_pic_alt = $a_alt;
146  }

Field Documentation

◆ $current_nr

ilMediaPlayerGUI::$current_nr
protected

Definition at line 21 of file class.ilMediaPlayerGUI.php.

◆ $description

ilMediaPlayerGUI::$description
protected

Definition at line 23 of file class.ilMediaPlayerGUI.php.

Referenced by getDescription().

◆ $displayHeight

ilMediaPlayerGUI::$displayHeight = "480"
protected

Definition at line 16 of file class.ilMediaPlayerGUI.php.

Referenced by getDisplayHeight().

◆ $displayWidth

ilMediaPlayerGUI::$displayWidth = "640"
protected

Definition at line 17 of file class.ilMediaPlayerGUI.php.

Referenced by getDisplayWidth().

◆ $download_link

ilMediaPlayerGUI::$download_link = ""
protected

Definition at line 25 of file class.ilMediaPlayerGUI.php.

Referenced by getDownloadLink().

◆ $event_callback_url

ilMediaPlayerGUI::$event_callback_url = ""
protected

Definition at line 24 of file class.ilMediaPlayerGUI.php.

◆ $file

ilMediaPlayerGUI::$file
protected

Definition at line 15 of file class.ilMediaPlayerGUI.php.

Referenced by getFile().

◆ $lightbox_initialized

ilMediaPlayerGUI::$lightbox_initialized = false
staticprotected

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

◆ $mimeType

ilMediaPlayerGUI::$mimeType
protected

Definition at line 18 of file class.ilMediaPlayerGUI.php.

Referenced by getMp3PlayerHtml().

◆ $nr

ilMediaPlayerGUI::$nr = 1
staticprotected

Definition at line 19 of file class.ilMediaPlayerGUI.php.

◆ $title

ilMediaPlayerGUI::$title
protected

Definition at line 22 of file class.ilMediaPlayerGUI.php.

Referenced by getTitle().


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