-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathhtml5openplayer.php
More file actions
110 lines (102 loc) · 3.9 KB
/
html5openplayer.php
File metadata and controls
110 lines (102 loc) · 3.9 KB
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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<?php
/**
* @package HTML5_Open_Player
* @version 0.1
*/
/*
Plugin Name: HTML5 Open Player
Plugin URI: http://github.com/darkmega0/wp_html5openplayer
Description: A simple HTML5 Audio Player for Ogg/Vorbis/Theora or WebM format with <video> and <audio> tag compatibles with HTML5 Standard.
Version: 0.1
Author: Joel Peláez Jorge
Author URI: http://darkmegazero.wordpress.com/
License: GPLv3
*/
/*
HTML5 Open Player for Wordpress
Copyright (C) 2012 Joel Peláez Jorge <joelpelaez@gmail.com>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/*
Manage audio5 tag for use only open formats: Ogg
Example use:
[audio5 src="file.ogg" {autoplay="autoplay"} {loop="loop"} {preload="none"|"auto"|"meadata"} ]
*/
function html5audio_shortcode ($attrs, $content = null) {
extract (shortcode_atts (array ('src' => '',
'autoplay' => '',
'loop' => '',
'preload' => ''
), $attrs ));
/* Check mime type */
if (strpos ($src, '.ogg') === FALSE)
return "<br>"
"Error: Cannot open file: It's not a open format.<br>"
"Please Use Ogg/Vorbis format.<br>";
$output = '<audio controls="controls" ';
if ($autoplay == 'autoplay')
$output .= 'autoplay="autoplay" ';
if ($loop == 'loop')
$output .= 'loop="loop" ';
if ($preload != '')
$output .= 'preload="' . $preload . '"';
$output .= '>';
$output .= '<source src="' . $src . '" type="audio/ogg" />';
$output .= '</audio>';
return $output;
}
add_shortcode ('audio5', 'html5audio_shortcode');
/*
Manage video5 tag for use only open formats: Ogg or WebM
Example use:
[video5 src="file.ogg" type="video/openformattype" {height="size"} {width="size"}
{autoplay="autoplay"} {loop="loop"} {preload="none"|"auto"|"meadata"} ]
*/
function html5video_shortcode ($attrs, $content = null) {
extract (shortcode_atts (array ('src' => '',
'type' => '',
'height' => '',
'width' => '',
'autoplay' => '',
'loop' => '',
'preload' => ''
), $attrs ));
/* Check mime type of video. */
if ((strpos ($src, '.ogg')
|| strpos ($src, '.ogv')
|| strpos ($src, '.webm')) === FALSE)
return "<br>"
"Error: Cannot open file: It's not a open format.<br>"
"Use Ogg/Theora or WebM format.<br>";
/* Check mime type used for video5. */
if (($type == "video/ogg") || ($type == "video/webm"))
return "<br>"
"Error setting mime type for video: Actually type is: $type.<br>"
"Please use correct mime type.<br>";
$output = '<video controls="controls" ';
if ($autoplay == 'autoplay')
$output .= 'autoplay="autoplay" ';
if ($loop == 'loop')
$output .= 'loop="loop" ';
if ($preload != '')
$output .= 'preload="' . $preload . '" ';
if ($height != '')
$output .= 'height="' . $height . '" ';
if ($width != '')
$output .= 'width="' . $width . '" ';
$output .= '>';
$output .= '<source src="' . $src . '" type="' . $type . '"/>';
$output .= '</video>';
return $output;
}
add_shortcode ('video5', 'html5video_shortcode');
?>