-
Notifications
You must be signed in to change notification settings - Fork 2
/
mod_jw_radiowave_player.php
69 lines (60 loc) · 2.2 KB
/
mod_jw_radiowave_player.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
/**
* @version 2.1
* @package Radiowave Generic Player (module)
* @author JoomlaWorks - https://www.joomlaworks.net
* @copyright Copyright (c) 2006 - 2020 JoomlaWorks Ltd. All rights reserved.
* @license GNU/GPL license: https://www.gnu.org/licenses/gpl.html
*/
// no direct access
defined('_JEXEC') or die;
// API
$app = JFactory::getApplication();
$document = JFactory::getDocument();
// Assign paths
$sitePath = JPATH_SITE;
$siteUrl = substr(JURI::base(), 0, -1);
// Module parameters
$moduleclass_sfx = $params->get('moduleclass_sfx', '');
$stream = $params->get('stream_id', 'https://listen.radionomy.com/abc-jazz');
$autoplay = $params->get('autoplay', 0);
$autoplay = ($autoplay) ? '.jPlayer("play")' : '';
$template = $params->get('template', 'Default');
$mod_name = "mod_jw_radiowave_player";
// JS
JHtml::_('jquery.framework');
$document->addScript($siteUrl.'/modules/mod_jw_radiowave_player/includes/dist/jplayer/jquery.jplayer.min.js');
$document->addScriptDeclaration('
/* Radiowave Generic Player */
(function($) {
$(document).ready(function() {
var stream = {
mp3: "'.$stream.'"
},
ready = false;
$("#jquery_jplayer_'.$module->id.'").jPlayer({
ready: function(event) {
ready = true;
$(this).jPlayer("setMedia", stream)'.$autoplay.';
},
pause: function() {
$(this).jPlayer("clearMedia");
},
error: function(event) {
if (ready && event.jPlayer.error.type === $.jPlayer.error.URL_NOT_SET) {
$(this).jPlayer("setMedia", stream).jPlayer("play");
}
},
swfPath: "../dist/jplayer",
supplied: "mp3",
preload: "none",
wmode: "window",
useStateClassSkin: true,
autoBlur: false,
keyEnabled: true
});
});
})(jQuery);
');
// Output content with template
require(JModuleHelper::getLayoutPath($mod_name, $template.'/default'));