YaWK  24.1
Yet another WebKit
jplayer.php
Go to the documentation of this file.
1 <?php
2  if (!isset($jPlayer) || (empty($jPlayer)))
3  { // include player class
4  require_once ("system/widgets/jplayer/classes/jplayer.class.php");
5  // create new player object
7  }
8 ?>
9 <?php
10 // set default values
11 $jPlayerRootMediaFolder = 'media/audio/';
16 $jPlayerWidth = "100%";
17 $jPlayerSkin = "light";
18 $heading = '';
19 $subtext = '';
20 
21 // $_GET['widgetID'] will be generated in \YAWK\widget\loadWidgets($db, $position)
22 if (isset($_GET['widgetID']))
23 {
24  // widget ID
25  $widgetID = $_GET['widgetID'];
26 
27  // make sure, the player got it's own instance ID
28  $jPlayerInstance = $_GET['widgetID'];
29 
30  // get widget settings from db
31  $res = $db->query("SELECT * FROM {widget_settings}
32  WHERE widgetID = '".$widgetID."'
33  AND activated = '1'");
34  while($row = mysqli_fetch_assoc($res))
35  { // set widget properties and values into vars
36  $w_property = $row['property'];
37  $w_value = $row['value'];
38  $w_widgetType = $row['widgetType'];
39  $w_activated = $row['activated'];
40  /* end of get widget properties */
41 
42  /* filter and load those widget properties */
43  if (isset($w_property)){
44  switch($w_property)
45  {
46  /* url of the video to stream */
47  case 'jPlayerUserMediaFolder';
48  $jPlayerUserMediaFolder = $w_value;
49  break;
50 
51  /* width */
52  case 'jPlayerWidth';
53  $jPlayerWidth = $w_value;
54  break;
55 
56  /* height */
57  case 'jPlayerSkin';
58  $jPlayerSkin = $w_value;
59  $jPlayerSkin = mb_strtolower($jPlayerSkin);
60  break;
61 
62  /* heading */
63  case 'jPlayerHeading';
64  $heading = $w_value;
65  break;
66 
67  /* subtext */
68  case 'jPlayerSubtext';
69  $subtext = $w_value;
70  break;
71 
72  /* initial volume */
73  case 'jPlayerDefaultVolume';
74  $jPlayerDefaultVolume = $w_value;
75  break;
76 
77  /* initial mute true|false */
78  case 'jPlayerInitialMute';
79  $jPlayerInitialMute = $w_value;
80  break;
81  }
82  } /* END LOAD PROPERTIES */
83  } // end while fetch row (fetch widget settings)
84 }
85 
86 
87 // if a heading is set and not empty
88 if (isset($heading) && (!empty($heading)))
89 { // add a h1 tag to heading string
90  $heading = "$heading";
91 
92  // if subtext is set, add <small> subtext to string
93  if (isset($subtext) && (!empty($subtext)))
94  { // build a headline with heading and subtext
95  $subtext = "<small>$subtext</small>";
96  $headline = "<h1>$heading&nbsp;"."$subtext</h1>";
97  }
98  else
99  { // build just a headline - without subtext
100  $headline = "<h1>$heading</h1>"; // draw just the heading
101  }
102 }
103 else
104 { // leave empty if it's not set
105  $headline = '';
106 }
107 echo $headline;
108 ?>
109  <!-- jplayer -->
110  <link type="text/css" href="system/widgets/jplayer/skins/<?php echo $jPlayerSkin; ?>/jplayer.<?php echo $jPlayerSkin; ?>.css" rel="stylesheet">
111  <script type="text/javascript" src="system/widgets/jplayer/js/jquery.jplayer.min.js"></script>
112  <script type="text/javascript" src="system/widgets/jplayer/js/jplayer.playlist.min.js"></script>
113  <script type="text/javascript" src="system/widgets/jplayer/js/browser.js"></script>
114  <script type="text/javascript">
115  //<![CDATA[
116  $(document).ready(function(){
117 
118  var Playlist = function(instance, playlist, options) {
119  var self = this;
120 
121  this.instance = instance; // String: To associate specific HTML with this playlist
122  this.playlist = playlist; // Array of Objects: The playlist
123  this.options = options; // Object: The jPlayer constructor options for this playlist
124 
125  this.current = 0;
126 
127  this.cssId = {
128  jPlayer: "jquery_jplayer_",
129  interface: "jp_interface_",
130  playlist: "jp_playlist_"
131  };
132  this.cssSelector = {};
133 
134  $.each(this.cssId, function(entity, id) {
135  self.cssSelector[entity] = "#" + id + self.instance;
136  });
137 
138  if(!this.options.cssSelectorAncestor) {
139  this.options.cssSelectorAncestor = this.cssSelector.interface;
140  }
141 
142  $(this.cssSelector.jPlayer).jPlayer(this.options);
143 
144  $(this.cssSelector.interface + " .jp-previous").click(function() {
145  self.playlistPrev();
146  $(this).blur();
147  return false;
148  });
149 
150  $(this.cssSelector.interface + " .jp-next").click(function() {
151  self.playlistNext();
152  $(this).blur();
153  return false;
154  });
155  };
156 
157  Playlist.prototype = {
158  displayPlaylist: function() {
159  var self = this;
160  $(this.cssSelector.playlist + " ul").empty();
161  for (i=0; i < this.playlist.length; i++) {
162  var listItem = (i === this.playlist.length-1) ? "<li class='jp-playlist-last'>" : "<li>";
163  listItem += "<a href='#' id='" + this.cssId.playlist + this.instance + "_item_" + i +"' tabindex='1'>"+ this.playlist[i].name +"</a>";
164 
165  // Create links to free media
166  if(this.playlist[i].free) {
167  var first = true;
168  listItem += "<div class='jp-free-media'>(";
169  $.each(this.playlist[i], function(property,value) {
170  if($.jPlayer.prototype.format[property]) { // Check property is a media format.
171  if(first) {
172  first = false;
173  } else {
174  listItem += " | ";
175  }
176  listItem += "<a id='" + self.cssId.playlist + self.instance + "_item_" + i + "_" + property + "' href='" + value + "' tabindex='1'>" + property + "</a>";
177  }
178  });
179  listItem += ")</span>";
180  }
181 
182  listItem += "</li>";
183 
184  // Associate playlist items with their media
185  $(this.cssSelector.playlist + " ul").append(listItem);
186  $(this.cssSelector.playlist + "_item_" + i).data("index", i).click(function() {
187  var index = $(this).data("index");
188  if(self.current !== index) {
189  self.playlistChange(index);
190  } else {
191  $(self.cssSelector.jPlayer).jPlayer("play");
192  }
193  $(this).blur();
194  return false;
195  });
196 
197  // Disable free media links to force access via right click
198  if(this.playlist[i].free) {
199  $.each(this.playlist[i], function(property,value) {
200  if($.jPlayer.prototype.format[property]) { // Check property is a media format.
201  $(self.cssSelector.playlist + "_item_" + i + "_" + property).data("index", i).click(function() {
202  var index = $(this).data("index");
203  $(self.cssSelector.playlist + "_item_" + index).click();
204  $(this).blur();
205  return false;
206  });
207  }
208  });
209  }
210  }
211  },
212  playlistInit: function(autoplay) {
213  if(autoplay) {
214  this.playlistChange(this.current);
215  } else {
216  this.playlistConfig(this.current);
217  }
218  },
219  playlistConfig: function(index) {
220  $(this.cssSelector.playlist + "_item_" + this.current).removeClass("jp-playlist-current").parent().removeClass("jp-playlist-current");
221  $(this.cssSelector.playlist + "_item_" + index).addClass("jp-playlist-current").parent().addClass("jp-playlist-current");
222  this.current = index;
223  $(this.cssSelector.jPlayer).jPlayer("setMedia", this.playlist[this.current]);
224  },
225  playlistChange: function(index) {
226  this.playlistConfig(index);
227  $(this.cssSelector.jPlayer).jPlayer("play");
228  },
229  playlistNext: function() {
230  var index = (this.current + 1 < this.playlist.length) ? this.current + 1 : 0;
231  this.playlistChange(index);
232  },
233  playlistPrev: function() {
234  var index = (this.current - 1 >= 0) ? this.current - 1 : this.playlist.length - 1;
235  this.playlistChange(index);
236  }
237  };
238 
239 
240  var audioPlaylist = new Playlist("<?php echo $jPlayerInstance; ?>", [<?php echo $jPlayer->getFiles("$jPlayerRootMediaFolder", "$jPlayerUserMediaFolder"); ?>], {
241  ready: function() {
242  audioPlaylist.displayPlaylist();
243  audioPlaylist.playlistInit(false); // Parameter is a boolean for autoplay.
244  },
245  ended: function() {
246  audioPlaylist.playlistNext();
247  },
248  play: function() {
249  $(this).jPlayer("pauseOthers");
250  },
251  swfPath: "system/widgets/jplayer/js", // path for swf fallback
252  supplied: "mp3, oga, wav", // supported formats
253  volume: "<?php echo $jPlayerDefaultVolume; ?>", // intial volume value from 0 to 1 eg 0.3
254  muted: <?php echo $jPlayerInitialMute; ?> // inital mute? false | true
255  });
256  });
257  //]]>
258  </script>
259 
260 
261  <div id="jquery_jplayer_<?php echo $jPlayerInstance; ?>" class="jp-jplayer"></div>
262  <div class="jp-audio" style="width: <?php echo $jPlayerWidth;?>;">
263  <div class="jp-type-playlist">
264  <div id="jp_interface_<?php echo $jPlayerInstance; ?>" class="jp-interface">
265  <ul class="jp-controls">
266  <li><a href="#" class="jp-play" tabindex="1">play</a></li>
267  <li><a href="#" class="jp-pause" tabindex="1">pause</a></li>
268  <li><a href="#" class="jp-stop" tabindex="1">stop</a></li>
269  <li><a href="#" class="jp-mute" tabindex="1">mute</a></li>
270  <li><a href="#" class="jp-unmute" tabindex="1">unmute</a></li>
271  <li><a href="#" class="jp-previous" tabindex="1">previous</a></li>
272  <li><a href="#" class="jp-next" tabindex="1">next</a></li>
273  </ul>
274  <div class="jp-progress">
275  <div class="jp-seek-bar">
276  <div class="jp-play-bar"></div>
277  </div>
278  </div>
279  <div class="jp-volume-bar">
280  <div class="jp-volume-bar-value"></div>
281  </div>
282  <div class="jp-current-time"></div>
283  <div class="jp-duration"></div>
284  </div>
285  <div id="jp_playlist_<?php echo $jPlayerInstance; ?>" class="jp-playlist">
286  <ul>
287  <!-- The method Playlist.displayPlaylist() uses this unordered list -->
288  <li></li>
289  </ul>
290  </div>
291  </div>
292  </div>
293 <?php
294 // } // end namespace
295 ?>
if(!isset($jPlayer)||(empty($jPlayer))) $jPlayerRootMediaFolder
Definition: jplayer.php:11
$subtext
Definition: jplayer.php:19
$heading
Definition: jplayer.php:18
$jPlayerUserMediaFolder
Definition: jplayer.php:12
$jPlayerSkin
Definition: jplayer.php:17
$jPlayerInstance
Definition: jplayer.php:13
$jPlayerInitialMute
Definition: jplayer.php:14
$jPlayerWidth
Definition: jplayer.php:16
$jPlayerDefaultVolume
Definition: jplayer.php:15
function a
Definition: browser.js:14
c jPlayer pause
c jPlayer
type
Definition: menu-new.php:35
print $_GET['id']
Definition: page-edit.php:357
function i(e, t)
Definition: plyr.js:1
document ready(function() { $('a[data-confirm]').click(function(ev) { modal='#dataConfirmModal';var href=$(this).attr('href');var title=$(this).attr('title');var icon=$(this).attr('data-icon');if(!icon) { icon='fa fa-trash-o';} if(!$(modal).length) { $('body').append('< div id="dataConfirmModal" class="modal fade" role="dialog" aria-labelledby="dataConfirmLabel" aria-hidden="true">< div class="modal-dialog">< div class="modal-content">< div class="modal-header">< button type="button" class="close" data-dismiss="modal" aria-hidden="true">< i class="fa fa-times"></i ></button >< br >< div class="col-md-1">< h3 class="modal-title">< i class="'+icon+'"></i ></h3 ></div >< div class="col-md-11">< h3 class="modal-title" id="dataConfirmLabel">'+title+'</h3 ></div ></h3 ></div >< div class="modal-body"></div >< div class="modal-footer">< button type="button" class="btn btn-default" data-dismiss="modal" aria-hidden="true">Abbrechen</button >< a type="button" class="btn btn-danger" id="dataConfirmOK">< i class="'+icon+'"></i > L &ouml;schen</a ></div ></div ></div ></div >');} $(modal).find('.modal-body').text($(this).attr('data-confirm'));$('#dataConfirmOK').attr('href', href);$(modal).modal({show:true});return false;});$('#terminateUser').click(function() { var terminate=window.confirm("ACHTUNG!\nDas wird Deinen Account permanent deaktivieren.\n"+"Bist Du Dir sicher, dass Du das tun willst?");if(terminate===true) { var terminateUser=window.confirm("Bist Du Dir wirklich ganz sicher?\n"+"Diese Aktion kann nicht rueckgaengig gemacht werden.");if(terminateUser===true) { $.get('system/templates/YaWK-bootstrap3/js/terminate-user.php', function(data) { if(data==="true") { setTimeout("window.location='logout.html'", 0);} else { alert("Fehler: "+data);} });} } });function dismissNotifications() { $.ajax({ url:'js/dismiss-notifications.php', type:'POST', success:function(data) { if(!data) { alert('Something went wrong!');return false;} } });$("#bell-label").fadeOut();$('#notification-header').html('You have 0 notifications');$('#notification-menu').fadeOut();} $("#dismiss").click(function() { dismissNotifications();});function disableButtons(delay) { $('#loginButton').removeClass().addClass('btn btn-success disabled').attr('id', 'LOGIN_FORBIDDEN');$('#resetPasswordButton').removeClass().addClass('btn btn-danger disabled');setTimeout(function() { $('#LOGIN_FORBIDDEN').attr('id', 'loginButton').removeClass().addClass('btn btn-success');$('#resetPasswordButton').removeClass().addClass('btn btn-danger');}, delay);} $("#loginButton").click(function(){ if($('#loginButton').length > 0) { if($('#loginButton').hasClass('btn') &&$('#loginButton').hasClass('btn-success') &&$('#loginButton').hasClass('disabled')) { } else { $("#loginForm").submit();disableButtons(10000);} } else if($('#LOGIN_FORBIDDEN').length > 0) { if($('#LOGIN_FORBIDDEN').hasClass('btn') &&$('#LOGIN_FORBIDDEN').hasClass('btn-success') &&$('#LOGIN_FORBIDDEN').hasClass('disabled')) { } else { } } });$("#blockedBtn").hover(function() { $("#blockedBtn").hide();$("#askBtn").fadeIn(820);});})