ILIAS  eassessment Revision 61809
 All Data Structures Namespaces Files Functions Variables Groups Pages
class.ilMediaPlayerGUI.php
Go to the documentation of this file.
1 <?php
2 /*
3  +-----------------------------------------------------------------------------+
4  | ILIAS open source |
5  +-----------------------------------------------------------------------------+
6  | Copyright (c) 1998-2001 ILIAS open source, University of Cologne |
7  | |
8  | This program is free software; you can redistribute it and/or |
9  | modify it under the terms of the GNU General Public License |
10  | as published by the Free Software Foundation; either version 2 |
11  | of the License, or (at your option) any later version. |
12  | |
13  | This program is distributed in the hope that it will be useful, |
14  | but WITHOUT ANY WARRANTY; without even the implied warranty of |
15  | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
16  | GNU General Public License for more details. |
17  | |
18  | You should have received a copy of the GNU General Public License |
19  | along with this program; if not, write to the Free Software |
20  | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
21  +-----------------------------------------------------------------------------+
22 */
23 
33 {
34  var $file;
36  var $mimeType;
37  static $nr = 1;
38 
39  function __construct()
40  {
41  }
42 
48  function setFile($a_file)
49  {
50  $this->file = $a_file;
51  }
52 
58  function getFile()
59  {
60  return $this->file;
61  }
62 
68  function setDisplayHeight ($dHeight) {
69  $this->displayHeight = $dHeight;
70  }
71 
77  function getDisplayHeight () {
78  return $this->displayHeight;
79  }
80 
81 
82  function setMimeType ($value) {
83  $this->mimeType = $value;
84  }
85 
89  function getMp3PlayerHtml()
90  {
91  global $tpl;
92  require_once 'Services/MediaObjects/classes/class.ilObjMediaObject.php';
93  include_once("./Services/MediaObjects/classes/class.ilExternalMediaAnalyzer.php");
94 
95  // youtube
97  {
99  $html = '<object width="320" height="240">'.
100  '<param name="movie" value="http://www.youtube.com/v/'.$p["v"].'?fs=1">'.
101  '</param><param name="allowFullScreen" value="true"></param>'.
102  '<param name="allowscriptaccess" value="always">'.
103  '</param><embed src="http://www.youtube.com/v/'.$p["v"].'?fs=1" '.
104  'type="application/x-shockwave-flash" allowscriptaccess="always" '.
105  'allowfullscreen="true" width="320" height="240"></embed></object>';
106  return $html;
107  }
108 
109  // vimeo
111  {
113 
114  $html = '<iframe src="http://player.vimeo.com/video/'.$p["id"].'" width="320" height="240" '.
115  'frameborder="0"></iframe>';
116 
117  return $html;
118  }
119 
120  $mimeType = $this->mimeType == "" ? ilObjMediaObject::getMimeType(basename($this->getFile())) : $this->mimeType;
121  if (strpos($mimeType,"flv") === false
122  && strpos($mimeType,"audio/mpeg") === false
123  && strpos($mimeType,"image/png") === false
124  && strpos($mimeType,"image/gif") === false)
125  {
126  $html = '<embed src="'.$this->getFile().'" '.
127  'type="'.$mimeType.'" '.
128  'autoplay="false" autostart="false" '.
129  'width="320" height="240" scale="aspect" ></embed>';
130  return $html;
131  }
132 
133  $tpl->addJavaScript("./Services/MediaObjects/flash_flv_player/swfobject.js");
134  $mp_tpl = new ilTemplate("tpl.flv_player.html", true, true, "Services/MediaObjects");
135  $mp_tpl->setVariable("FILE", urlencode($this->getFile()));
136  $mp_tpl->setVariable("PLAYER_NR", self::$nr);
137  $mp_tpl->setVariable("DISPLAY_HEIGHT", strpos($mimeType,"audio/mpeg") === false ? "240" : "20");
138  $mp_tpl->setVariable("DISPLAY_WIDTH", "320");
139  self::$nr++;
140 
141  return $mp_tpl->get();
142  }
143 }
144 ?>