Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
freebsd
GitHub Repository: freebsd/phabricator
Path: blob/master/src/applications/files/document/PhabricatorAudioDocumentEngine.php
12241 views
1
<?php
2
3
final class PhabricatorAudioDocumentEngine
4
extends PhabricatorDocumentEngine {
5
6
const ENGINEKEY = 'audio';
7
8
public function getViewAsLabel(PhabricatorDocumentRef $ref) {
9
return pht('View as Audio');
10
}
11
12
protected function getDocumentIconIcon(PhabricatorDocumentRef $ref) {
13
return 'fa-file-sound-o';
14
}
15
16
protected function getByteLengthLimit() {
17
return null;
18
}
19
20
protected function canRenderDocumentType(PhabricatorDocumentRef $ref) {
21
$file = $ref->getFile();
22
if ($file) {
23
return $file->isAudio();
24
}
25
26
$viewable_types = PhabricatorEnv::getEnvConfig('files.viewable-mime-types');
27
$viewable_types = array_keys($viewable_types);
28
29
$audio_types = PhabricatorEnv::getEnvConfig('files.audio-mime-types');
30
$audio_types = array_keys($audio_types);
31
32
return
33
$ref->hasAnyMimeType($viewable_types) &&
34
$ref->hasAnyMimeType($audio_types);
35
}
36
37
protected function newDocumentContent(PhabricatorDocumentRef $ref) {
38
$file = $ref->getFile();
39
if ($file) {
40
$source_uri = $file->getViewURI();
41
} else {
42
throw new PhutilMethodNotImplementedException();
43
}
44
45
$mime_type = $ref->getMimeType();
46
47
$audio = phutil_tag(
48
'audio',
49
array(
50
'controls' => 'controls',
51
),
52
phutil_tag(
53
'source',
54
array(
55
'src' => $source_uri,
56
'type' => $mime_type,
57
)));
58
59
$container = phutil_tag(
60
'div',
61
array(
62
'class' => 'document-engine-audio',
63
),
64
$audio);
65
66
return $container;
67
}
68
69
}
70
71