Commit 049e44fd authored by SpinShare's avatar SpinShare

added mp3 support

parent 63ee1f89
......@@ -167,6 +167,7 @@ class SongController extends AbstractController
try {
$coverFiles = glob($this->getParameter('cover_path').DIRECTORY_SEPARATOR.$result->getFileReference().".png");
$oggFiles = glob($this->getParameter('audio_path').DIRECTORY_SEPARATOR.$result->getFileReference()."_*.ogg");
$mp3Files = glob($this->getParameter('audio_path').DIRECTORY_SEPARATOR.$result->getFileReference()."_*.mp3");
$zip = new \ZipArchive;
$zip->open($zipLocation.$zipName, \ZipArchive::CREATE);
......@@ -180,6 +181,12 @@ class SongController extends AbstractController
$zip->addFile($oggFile, "AudioClips".DIRECTORY_SEPARATOR.$result->getFileReference()."_".$oggIndex.".ogg");
}
}
if(count($mp3Files) > 0) {
foreach($mp3Files as $mp3File) {
$mp3Index = explode(".", explode("_", $mp3File)[2])[0];
$zip->addFile($mp3File, "AudioClips".DIRECTORY_SEPARATOR.$result->getFileReference()."_".$mp3Index.".mp3");
}
}
$zip->close();
$response = new Response(file_get_contents($zipLocation.$zipName));
......@@ -275,6 +282,16 @@ class SongController extends AbstractController
}
// Remove .mp3 files
try {
$mp3Files = glob($this->getParameter('audio_path').DIRECTORY_SEPARATOR.$song->getFileReference()."_*.mp3");
foreach($mp3Files as $mp3File) {
@unlink($mp3File);
}
} catch(FileNotFoundException $e) {
}
try {
try {
// get backup data
......@@ -409,10 +426,15 @@ class SongController extends AbstractController
$assetName = $clipItem->clipAssetReference->assetName;
$newAssetName = $song->getFileReference()."_".$clipIndex;
$oggLocation = $extractionPath.DIRECTORY_SEPARATOR."AudioClips".DIRECTORY_SEPARATOR.$assetName.".ogg";
$mp3Location = $extractionPath.DIRECTORY_SEPARATOR."AudioClips".DIRECTORY_SEPARATOR.$assetName.".mp3";
if(is_file($oggLocation)) {
$clipInfo[$clipIndex]->clipAssetReference->assetName = $newAssetName;
rename($oggLocation, $this->getParameter('audio_path').DIRECTORY_SEPARATOR.$newAssetName.".ogg");
}
if(is_file($mp3Location)) {
$clipInfo[$clipIndex]->clipAssetReference->assetName = $newAssetName;
rename($mp3Location, $this->getParameter('audio_path').DIRECTORY_SEPARATOR.$newAssetName.".mp3");
}
}
} catch(Exception $e) {
var_dump($e);
......@@ -513,6 +535,16 @@ class SongController extends AbstractController
}
// Remove .mp3 files
try {
$mp3Files = glob($this->getParameter('audio_path').DIRECTORY_SEPARATOR.$result->getFileReference()."_*.mp3");
foreach($mp3Files as $mp3File) {
@unlink($mp3File);
}
} catch(FileNotFoundException $e) {
}
// remove the entity
$em->remove($result);
......
......@@ -221,10 +221,15 @@ class UploadController extends AbstractController
$assetName = $clipItem->clipAssetReference->assetName;
$newAssetName = $song->getFileReference()."_".$clipIndex;
$oggLocation = $extractionPath.DIRECTORY_SEPARATOR."AudioClips".DIRECTORY_SEPARATOR.$assetName.".ogg";
$mp3Location = $extractionPath.DIRECTORY_SEPARATOR."AudioClips".DIRECTORY_SEPARATOR.$assetName.".mp3";
if(is_file($oggLocation)) {
$clipInfo[$clipIndex]->clipAssetReference->assetName = $newAssetName;
rename($oggLocation, $this->getParameter('audio_path').DIRECTORY_SEPARATOR.$newAssetName.".ogg");
}
if(is_file($mp3Location)) {
$clipInfo[$clipIndex]->clipAssetReference->assetName = $newAssetName;
rename($mp3Location, $this->getParameter('audio_path').DIRECTORY_SEPARATOR.$newAssetName.".mp3");
}
}
} catch(Exception $e) {
$this->addFlash('error', 'Uploading failed. Please report back to our development team!');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment