-
Notifications
You must be signed in to change notification settings - Fork 7
/
audio.php
54 lines (45 loc) · 1.33 KB
/
audio.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
<?php
define('CDN_KEMENAG_RI', 'KEMENAG_RI');
define('CDN_ALQURAN_CLOUD', 'ALQURAN_CLOUD');
define('CDN_LOCAL', 'LOCAL');
class Audio {
public $cdn = CDN_LOCAL;
public function __construct($cdn)
{
$this->cdn = $cdn;
}
public function createAudio($data)
{
$url = "";
switch($this->cdn)
{
case CDN_KEMENAG_RI:
$url = $this->createAudioKemenagRI($data);
break;
case CDN_ALQURAN_CLOUD:
$url = $this->createAudioAlQuranCloud($data);
break;
case CDN_LOCAL:
default:
$url = $this->createAudioLocal($data);
break;
}
return $url;
}
public function createAudioKemenagRI($data)
{
$urlFormat = "https://quran.kemenag.go.id/cmsq/source/s01/%03d%03d.mp3";
return sprintf($urlFormat, $data['surat'], $data['ayat']);
}
public function createAudioAlQuranCloud($data)
{
$bitrate = 128;
$urlFormat = "https://cdn.islamic.network/quran/audio/%d/ar.alafasy/%d.mp3";
return sprintf($urlFormat, $bitrate, $data['ayat_number']);
}
public function createAudioLocal($data)
{
$urlFormat = "sounds/%03d%03d.mp3";
return sprintf($urlFormat, $data['surat'], $data['ayat']);
}
}