This repository has been archived by the owner on Aug 13, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathpnmedia_quicktimeapi.php
145 lines (131 loc) · 5.78 KB
/
pnmedia_quicktimeapi.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
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
<?php
// $Id$
//
// Mediashare by Jorn Wildt (C)
//
class mediashare_quicktimeHandler
{
function getTitle()
{
$dom = ZLanguage::getModuleDomain('mediashare');
return __('Mediashare Quicktime Handler', $dom);
}
function getMediaTypes()
{
return array(
array('mimeType' => 'video/quicktime',
'fileType' => 'mov',
'foundMimeType' => 'video/quicktime',
'foundFileType' => 'mov'),
array('mimeType' => 'video/avi',
'fileType' => 'avi',
'foundMimeType' => 'video/avi',
'foundFileType' => 'avi'),
array('mimeType' => 'audio/wav',
'fileType' => 'wav',
'foundMimeType' => 'audio/wav',
'foundFileType' => 'wav'),
array('mimeType' => 'audio/mpg',
'fileType' => 'mpg',
'foundMimeType' => 'audio/mpeg',
'foundFileType' => 'mpeg'),
array('mimeType' => 'audio/mpeg',
'fileType' => 'mpeg',
'foundMimeType' => 'audio/mpeg',
'foundFileType' => 'mpeg'),
array('mimeType' => 'audio/mpeg3',
'fileType' => 'mpeg3',
'foundMimeType' => 'audio/mpeg3',
'foundFileType' => 'mpeg3'),
array('mimeType' => 'audio/mpg3',
'fileType' => 'mpg3',
'foundMimeType' => 'audio/mpeg3',
'foundFileType' => 'mpeg3'),
array('mimeType' => 'audio/mp3',
'fileType' => 'mp3',
'foundMimeType' => 'audio/mpeg3',
'foundFileType' => 'mpeg3'),
array('mimeType' => 'audio/mpeg4',
'fileType' => 'mpeg4',
'foundMimeType' => 'audio/mpeg4',
'foundFileType' => 'mpeg4'),
array('mimeType' => 'audio/mpg4',
'fileType' => 'mpg4',
'foundMimeType' => 'audio/mpeg4',
'foundFileType' => 'mpeg4'),
array('mimeType' => 'audio/mp4',
'fileType' => 'mp4',
'foundMimeType' => 'audio/mpeg4',
'foundFileType' => 'mpeg4'));
}
function createPreviews($args, $previews)
{
$mediaFilename = $args['mediaFilename'];
$mimeType = $args['mimeType'];
$mediaFileType = $args['fileType'];
$result = array();
foreach ($previews as $preview)
{
if ($preview['isThumbnail']) {
copy('modules/mediashare/pnimages/logo/logo_quicktime_player.png', $preview['outputFilename']);
$imPreview = @imagecreatefrompng($preview['outputFilename']);
$result[] = array('fileType' => 'png',
'mimeType' => 'image/png',
'width' => imagesx($imPreview),
'height' => imagesy($imPreview),
'bytes' => filesize($preview['outputFilename']));
imagedestroy($imPreview);
} else {
$width = $preview['imageSize'];
$height = $preview['imageSize'];
if (isset($args['width']) && (int)$args['width'] > 0 && isset($args['height']) && (int)$args['height'] > 0) {
$w = (int)$args['width'];
$h = (int)$args['height'];
if ($w < $width || $h < $height) {
$width = $w;
$height = $h;
} else if ($w > $h) {
$height = ($h / $w) * $height;
} else {
$width = ($w / $h) * $width;
}
}
$result[] = array('fileType' => $mediaFileType,
'mimeType' => $mimeType,
'width' => $width,
'height' => $height,
'useOriginal' => true,
'bytes' => filesize($preview['outputFilename']));
}
}
$width = (isset($args['width']) && (int)$args['width'] > 0 ? (int)$args['width'] : $preview['imageSize']);
$height = (isset($args['height']) && (int)$args['height'] > 0 ? (int)$args['height'] : $preview['imageSize']);
$result[] = array('fileType' => $mediaFileType,
'mimeType' => $mimeType,
'width' => $width,
'height' => $height,
'bytes' => filesize($mediaFilename));
return $result;
}
function getMediaDisplayHtml($url, $width, $height, $id, $args)
{
$widthHtml = ($width == null ? '' : " width=\"$width\"");
$heightHtml = ($height == null ? '' : " height=\"" . ($height + 16) . "\"");
$output = '<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"'
.' id="'.$id.'"'.$widthHtml.$heightHtml
.' codebase="http://www.apple.com/qtactivex/qtplugin.cab">'
.'<param name="src" value="'.$url.'"/>'
.'<param name="Scale" value="aspect"/>'
.'<param name="AutoPlay" value="false"/>'
.'<param name="Controller" value="true"/>'
.'<embed src="'.$url.'" Autoplay="false" Controller="true"'.$widthHtml.$heightHtml
.' scale="aspect" pluginspage="http://www.apple.com/quicktime/download">'
.'</embed>'
.'</object>';
return $output;
}
}
function mediashare_media_quicktimeapi_buildHandler($args)
{
return new mediashare_quicktimeHandler();
}