ILIAS  release_4-3 Revision
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilMediaPlayerGUI Class Reference

User interface for media player. More...

+ Collaboration diagram for ilMediaPlayerGUI:

Public Member Functions

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

Protected Attributes

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

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

ilMediaPlayerGUI::__construct (   $a_id = "")

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

References $nr.

{
$this->id = $a_id;
$this->current_nr = self::$nr;
self::$nr++;
}

Member Function Documentation

ilMediaPlayerGUI::getAlternativeVideoFile ( )

Get alternative video file.

Returns
string alternative video file

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

Referenced by getMp3PlayerHtml().

{
return $this->alt_video_file;
}

+ Here is the caller graph for this function:

ilMediaPlayerGUI::getAlternativeVideoMimeType ( )

Get alternative video mime type.

Returns
string alternative video mime type

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

Referenced by getMp3PlayerHtml().

{
return $this->alt_video_mime;
}

+ Here is the caller graph for this function:

ilMediaPlayerGUI::getDescription ( )

Get description.

Returns
string description

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

References $description.

Referenced by getMp3PlayerHtml().

{
}

+ Here is the caller graph for this function:

ilMediaPlayerGUI::getDisplayHeight ( )

return display height of player.

Returns
int

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

References $displayHeight.

Referenced by getMp3PlayerHtml().

{
}

+ Here is the caller graph for this function:

ilMediaPlayerGUI::getDisplayWidth ( )

Get display width.

Returns
string display width

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

References $displayWidth.

Referenced by getMp3PlayerHtml().

{
}

+ Here is the caller graph for this function:

ilMediaPlayerGUI::getFile ( )

Get File.

Returns
string File

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

References $file.

Referenced by getMp3PlayerHtml().

{
return $this->file;
}

+ Here is the caller graph for this function:

ilMediaPlayerGUI::getForceAudioPreview ( )

Get force audio preview.

Returns
boolean force audio preview picture

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

Referenced by getMp3PlayerHtml().

{
return $this->force_audio_preview;
}

+ Here is the caller graph for this function:

ilMediaPlayerGUI::getMp3PlayerHtml (   $a_preview = false)

Get Html for MP3 Player.

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

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

Referenced by getPreviewHtml().

{
global $tpl;
$tpl->addJavascript("./Services/MediaObjects/js/MediaObjects.js");
if (!self::$lightbox_initialized)
{
include_once("./Services/UIComponent/Lightbox/classes/class.ilLightboxGUI.php");
$lb = new ilLightboxGUI("media_lightbox");
$lb->setWidth("660px");
$lb->addLightbox();
self::$lightbox_initialized = true;
}
require_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
include_once("./Services/MediaObjects/classes/class.ilExternalMediaAnalyzer.php");
// youtube
/* if (ilExternalMediaAnalyzer::isYouTube($this->getFile()))
{
$p = ilExternalMediaAnalyzer::extractYouTubeParameters($this->getFile());
$html = '<object width="320" height="240">'.
'<param name="movie" value="http://www.youtube.com/v/'.$p["v"].'?fs=1">'.
'</param><param name="allowFullScreen" value="true"></param>'.
'<param name="allowscriptaccess" value="always">'.
'</param><embed src="http://www.youtube.com/v/'.$p["v"].'?fs=1" '.
'type="application/x-shockwave-flash" allowscriptaccess="always" '.
'allowfullscreen="true" width="320" height="240"></embed></object>';
return $html;
}
// vimeo
if (ilExternalMediaAnalyzer::isVimeo($this->getFile()))
{
$p = ilExternalMediaAnalyzer::extractVimeoParameters($this->getFile());
$html = '<iframe src="http://player.vimeo.com/video/'.$p["id"].'" width="320" height="240" '.
'frameborder="0"></iframe>';
return $html;
}
*/
$mimeType = $this->mimeType == "" ? ilObjMediaObject::getMimeType(basename($this->getFile())) : $this->mimeType;
include_once("./Services/MediaObjects/classes/class.ilPlayerUtil.php");
// video tag
if (in_array($mimeType, array("video/mp4", "video/m4v", "video/rtmp",
"video/x-flv", "video/webm", "video/youtube", "video/vimeo", "video/ogg")))
{
if ($mimeType == "video/quicktime")
{
$mimeType = "video/mov";
}
$mp_tpl = new ilTemplate("tpl.flv_player.html", true, true, "Services/MediaObjects");
// preview
if ($a_preview)
{
$mp_tpl->setCurrentBlock("preview");
if ($this->getVideoPreviewPic() != "")
{
$mp_tpl->setVariable("IMG_SRC", $this->getVideoPreviewPic());
}
else
{
$mp_tpl->setVariable("IMG_SRC", ilUtil::getImagePath("mcst_preview.png"));
}
$mp_tpl->setVariable("IMG_ALT", $this->video_preview_pic_alt);
$mp_tpl->setVariable("PTITLE", $this->getTitle());
$mp_tpl->parseCurrentBlock();
}
// sources
$mp_tpl->setCurrentBlock("source");
$mp_tpl->setVariable("FILE", $this->getFile());
$mp_tpl->setVariable("MIME", $mimeType);
$mp_tpl->parseCurrentBlock();
if (in_array($this->getAlternativeVideoMimeType(), array("video/mp4", "video/webm")))
{
$mp_tpl->setCurrentBlock("source");
$mp_tpl->setVariable("FILE", $this->getAlternativeVideoFile());
$mp_tpl->setVariable("MIME", $this->getAlternativeVideoMimeType());
$mp_tpl->parseCurrentBlock();
}
$mp_tpl->setCurrentBlock("mejs_video");
if ($a_preview)
{
$mp_tpl->setVariable("CLASS", "ilNoDisplay");
}
$mp_tpl->setVariable("PLAYER_NR", $this->current_nr);
$height = $this->getDisplayHeight();
$width = $this->getDisplayWidth();
if (is_int(strpos($mimeType,"audio/mpeg")))
{
$height = "30";
}
$mp_tpl->setVariable("DISPLAY_HEIGHT", $height);
$mp_tpl->setVariable("DISPLAY_WIDTH", $width);
$mp_tpl->setVariable("PREVIEW_PIC", $this->getVideoPreviewPic());
$mp_tpl->setVariable("SWF_FILE", ilPlayerUtil::getFlashVideoPlayerFilename(true));
$mp_tpl->setVariable("FFILE", $this->getFile());
$mp_tpl->setVariable("TITLE", $this->getTitle());
$mp_tpl->setVariable("DESCRIPTION", $this->getDescription());
$mp_tpl->parseCurrentBlock();
$r = $mp_tpl->get();
//echo htmlentities($r);
return $r;
}
// audio/mpeg
if (is_int(strpos($mimeType,"audio/mpeg")) ||
in_array($mimeType, array("application/ogg", "audio/ogg")))
{
$mp_tpl = new ilTemplate("tpl.flv_player.html", true, true, "Services/MediaObjects");
$preview_output = false;
if ($this->getVideoPreviewPic() != "" || $this->getForceAudioPreview())
{
$mp_tpl->setCurrentBlock("apreview");
if ($this->getVideoPreviewPic() != "")
{
$mp_tpl->setVariable("IMG_SRC", $this->getVideoPreviewPic());
}
else
{
$mp_tpl->setVariable("IMG_SRC", ilUtil::getImagePath("mcst_preview.png"));
}
$mp_tpl->setVariable("PTITLE", $this->getTitle());
$mp_tpl->parseCurrentBlock();
$preview_output = true;
}
$mp_tpl->setCurrentBlock("audio");
if ($preview_output)
{
$mp_tpl->setVariable("ASTYLE", "margin-top:-30px");
}
$mp_tpl->setVariable("AFILE", $this->getFile());
$mp_tpl->setVariable("APLAYER_NR", $this->current_nr);
$mp_tpl->setVariable("AHEIGHT", "30");
$mp_tpl->setVariable("AWIDTH", "320");
$mp_tpl->parseCurrentBlock();
return $mp_tpl->get();
}
// images
if (is_int(strpos($mimeType,"image/")))
{
$mp_tpl = new ilTemplate("tpl.flv_player.html", true, true, "Services/MediaObjects");
$mp_tpl->setCurrentBlock("ipreview");
if ($this->getVideoPreviewPic() != "")
{
$mp_tpl->setVariable("IMG_SRC", $this->getVideoPreviewPic());
}
else
{
$mp_tpl->setVariable("IMG_SRC", $this->getFile());
}
$mp_tpl->setVariable("PTITLE", $this->getTitle());
$mp_tpl->parseCurrentBlock();
$mp_tpl->setCurrentBlock("image");
$mp_tpl->setVariable("IFILE", $this->getFile());
$mp_tpl->setVariable("IPLAYER_NR", $this->current_nr);
$mp_tpl->setVariable("ITITLE", $this->getTitle());
$mp_tpl->setVariable("IDESCRIPTION", $this->getDescription());
$height = $this->getDisplayHeight();
$width = $this->getDisplayWidth();
$mp_tpl->setVariable("IHEIGHT", $height);
$mp_tpl->setVariable("IWIDTH", $width);
$mp_tpl->parseCurrentBlock();
return $mp_tpl->get();
}
// fallback, no preview mode
$mimeType = $this->mimeType == "" ? ilObjMediaObject::getMimeType(basename($this->getFile())) : $this->mimeType;
if (strpos($mimeType,"flv") === false
&& strpos($mimeType,"audio/mpeg") === false
&& strpos($mimeType,"image/png") === false
&& strpos($mimeType,"image/gif") === false)
{
$html = '<embed src="'.$this->getFile().'" '.
'type="'.$mimeType.'" '.
'ShowControls="1" '.
'autoplay="false" autostart="false" '.
'width="320" height="240" scale="aspect" ></embed>';
return $html;
}
return;
$tpl->addJavaScript("./Services/MediaObjects/flash_flv_player/swfobject.js");
$mp_tpl = new ilTemplate("tpl.flv_player.html", true, true, "Services/MediaObjects");
$mp_tpl->setCurrentBlock("default");
$mp_tpl->setVariable("FILE", urlencode($this->getFile()));
$mp_tpl->setVariable("PLAYER_NR", $this->current_nr);
$mp_tpl->setVariable("DISPLAY_HEIGHT", strpos($mimeType,"audio/mpeg") === false ? "240" : "20");
$mp_tpl->setVariable("DISPLAY_WIDTH", "320");
$mp_tpl->parseCurrentBlock();
return $mp_tpl->get();
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ilMediaPlayerGUI::getPreviewHtml ( )

Get preview html.

Parameters
@return

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

References getMp3PlayerHtml().

{
return $this->getMp3PlayerHtml(true);
}

+ Here is the call graph for this function:

ilMediaPlayerGUI::getTitle ( )

Get Title.

Returns
string title

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

References $title.

Referenced by getMp3PlayerHtml().

{
return $this->title;
}

+ Here is the caller graph for this function:

ilMediaPlayerGUI::getVideoPreviewPic ( )

Get video preview picture.

Returns
string video preview picture

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

Referenced by getMp3PlayerHtml().

{
return $this->video_preview_pic;
}

+ Here is the caller graph for this function:

ilMediaPlayerGUI::setAlternativeVideoFile (   $a_val)

Set alternative video file.

Parameters
string$a_valalternative video file

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

{
$this->alt_video_file = $a_val;
}
ilMediaPlayerGUI::setAlternativeVideoMimeType (   $a_val)

Set alternative video mime type.

Parameters
string$a_valalternative video mime type

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

{
$this->alt_video_mime = $a_val;
}
ilMediaPlayerGUI::setDescription (   $a_val)

Set description.

Parameters
string$a_valdescription

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

{
$this->description = $a_val;
}
ilMediaPlayerGUI::setDisplayHeight (   $dHeight)

set display height

Parameters
int$dHeight

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

{
$this->displayHeight = $dHeight;
}
ilMediaPlayerGUI::setDisplayWidth (   $a_val)

Set display width.

Parameters
string$a_valdisplay width

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

{
$this->displayWidth = $a_val;
}
ilMediaPlayerGUI::setFile (   $a_file)

Set File.

Parameters
string$a_fileFile

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

{
$this->file = $a_file;
}
ilMediaPlayerGUI::setForceAudioPreview (   $a_val)

Set force audio preview.

Parameters
boolean$a_valforce audio preview picture

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

{
$this->force_audio_preview = $a_val;
}
ilMediaPlayerGUI::setMimeType (   $value)

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

{
$this->mimeType = $value;
}
ilMediaPlayerGUI::setTitle (   $a_val)

Set Title.

Parameters
string$a_valtitle

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

{
$this->title = $a_val;
}
ilMediaPlayerGUI::setVideoPreviewPic (   $a_val,
  $a_alt = "" 
)

Set video preview picture.

Parameters
string$a_valvideo preview picture

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

{
$this->video_preview_pic = $a_val;
$this->video_preview_pic_alt = $a_alt;
}

Field Documentation

ilMediaPlayerGUI::$current_nr
protected

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

ilMediaPlayerGUI::$description
protected

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

Referenced by getDescription().

ilMediaPlayerGUI::$displayHeight = "480"
protected

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

Referenced by getDisplayHeight().

ilMediaPlayerGUI::$displayWidth = "640"
protected

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

Referenced by getDisplayWidth().

ilMediaPlayerGUI::$file
protected

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

Referenced by getFile().

ilMediaPlayerGUI::$lightbox_initialized = false
staticprotected

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

ilMediaPlayerGUI::$mimeType
protected

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

Referenced by getMp3PlayerHtml().

ilMediaPlayerGUI::$nr = 1
staticprotected

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

Referenced by __construct().

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: