CC-5450 : Refactor Media Management (Classes/DB) in Airtime
creating context menus for the media in their own services.
This commit is contained in:
parent
86b5f68c67
commit
2feac41af7
|
@ -94,25 +94,15 @@ class ApiController extends Zend_Controller_Action
|
||||||
clearstatcache();
|
clearstatcache();
|
||||||
|
|
||||||
if (is_file($filepath)) {
|
if (is_file($filepath)) {
|
||||||
//$full_path = $media->getPropelOrm()->getDbFilepath();
|
|
||||||
|
|
||||||
//$file_base_name = strrchr($full_path, '/');
|
|
||||||
/* If $full_path does not contain a '/', strrchr will return false,
|
|
||||||
* in which case we can use $full_path as the base name.
|
|
||||||
*/
|
|
||||||
//if (!$file_base_name) {
|
|
||||||
// $file_base_name = $full_path;
|
|
||||||
//} else {
|
|
||||||
// $file_base_name = substr($file_base_name, 1);
|
|
||||||
//}
|
|
||||||
|
|
||||||
//Download user left clicks a track and selects Download.
|
//Download user left clicks a track and selects Download.
|
||||||
if ("true" == $this->_getParam('download')) {
|
if ("true" == $this->_getParam('download')) {
|
||||||
//path_info breaks up a file path into seperate pieces of informaiton.
|
//path_info breaks up a file path into seperate pieces of informaiton.
|
||||||
//We just want the basename which is the file name with the path
|
//We just want the basename which is the file name with the path
|
||||||
//information stripped away. We are using Content-Disposition to specify
|
//information stripped away. We are using Content-Disposition to specify
|
||||||
//to the browser what name the file should be saved as.
|
//to the browser what name the file should be saved as.
|
||||||
header('Content-Disposition: attachment; filename="'.$info.'"');
|
$filename = basename($filepath);
|
||||||
|
header('Content-Disposition: attachment; filename="'.$filename.'"');
|
||||||
} else {
|
} else {
|
||||||
//user clicks play button for track and downloads it.
|
//user clicks play button for track and downloads it.
|
||||||
header('Content-Disposition: inline; filename="'.$info.'"');
|
header('Content-Disposition: inline; filename="'.$info.'"');
|
||||||
|
|
|
@ -75,24 +75,8 @@ class LibraryController extends Zend_Controller_Action
|
||||||
$baseUrl = Application_Common_OsPath::getBaseDir();
|
$baseUrl = Application_Common_OsPath::getBaseDir();
|
||||||
$id = intval($this->_getParam('id'));
|
$id = intval($this->_getParam('id'));
|
||||||
|
|
||||||
$menu = array();
|
$mediaService = new Application_Service_MediaService();
|
||||||
|
$menu = $mediaService->createContextMenu($id);
|
||||||
/*
|
|
||||||
$menu["pl_add"] = array(
|
|
||||||
"name" => _("Add to Playlist"),
|
|
||||||
"requestUrl" => $baseUrl."playlist/add-items",
|
|
||||||
"requestType" => "POST",
|
|
||||||
"requestData" => array("ids" => array($id)),
|
|
||||||
"callback" => "AIRTIME.playlist.redrawPlaylist"
|
|
||||||
);
|
|
||||||
*/
|
|
||||||
|
|
||||||
$menu["preview"] = array(
|
|
||||||
"name" => _("Preview"),
|
|
||||||
"icon" => "play",
|
|
||||||
"id" => $id,
|
|
||||||
"callback" => "previewMedia"
|
|
||||||
);
|
|
||||||
|
|
||||||
if (empty($menu)) {
|
if (empty($menu)) {
|
||||||
$menu["noaction"] = array("name"=>_("No action available"));
|
$menu["noaction"] = array("name"=>_("No action available"));
|
||||||
|
|
|
@ -464,4 +464,28 @@ class Application_Service_AudioFileService
|
||||||
|
|
||||||
return ($rv == 0 && !$isError);
|
return ($rv == 0 && !$isError);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function createContextMenu($audioFile) {
|
||||||
|
|
||||||
|
$id = $audioFile->getId();
|
||||||
|
|
||||||
|
$menu = array();
|
||||||
|
|
||||||
|
$menu["preview"] = array(
|
||||||
|
"name" => _("Preview"),
|
||||||
|
"icon" => "play",
|
||||||
|
"id" => $id,
|
||||||
|
"callback" => "previewMedia"
|
||||||
|
);
|
||||||
|
|
||||||
|
$url = $audioFile->getFileUrl().'/download/true';
|
||||||
|
$menu["download"] = array(
|
||||||
|
"name" => _("Download"),
|
||||||
|
"icon" => "download",
|
||||||
|
"url" => $url,
|
||||||
|
"callback" => "downloadMedia"
|
||||||
|
);
|
||||||
|
|
||||||
|
return $menu;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -734,6 +734,16 @@ class Application_Service_MediaService
|
||||||
return new $serviceClass();
|
return new $serviceClass();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function createContextMenu($mediaId) {
|
||||||
|
|
||||||
|
$mediaItem = MediaItemQuery::create()->findPK($mediaId);
|
||||||
|
$obj = $mediaItem->getChildObject();
|
||||||
|
|
||||||
|
$service = self::locateServiceType($mediaItem);
|
||||||
|
|
||||||
|
return $service->createContextMenu($obj);
|
||||||
|
}
|
||||||
|
|
||||||
public function getJPlayerPreviewPlaylist($mediaId) {
|
public function getJPlayerPreviewPlaylist($mediaId) {
|
||||||
|
|
||||||
$mediaItem = MediaItemQuery::create()->findPK($mediaId);
|
$mediaItem = MediaItemQuery::create()->findPK($mediaId);
|
||||||
|
|
|
@ -90,4 +90,20 @@ class Application_Service_WebstreamService
|
||||||
|
|
||||||
WebstreamQuery::create()->findPks($ids)->delete();
|
WebstreamQuery::create()->findPks($ids)->delete();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function createContextMenu($webstream) {
|
||||||
|
|
||||||
|
$id = $webstream->getId();
|
||||||
|
|
||||||
|
$menu = array();
|
||||||
|
|
||||||
|
$menu["preview"] = array(
|
||||||
|
"name" => _("Preview"),
|
||||||
|
"icon" => "play",
|
||||||
|
"id" => $id,
|
||||||
|
"callback" => "previewMedia"
|
||||||
|
);
|
||||||
|
|
||||||
|
return $menu;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -55,7 +55,15 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
table.fnSetFilteringDelay(350);
|
table.fnSetFilteringDelay(350);
|
||||||
}
|
}
|
||||||
|
|
||||||
mod.previewMedia = function(mediaId) {
|
mod.downloadMedia = function(data) {
|
||||||
|
console.log("downloading media " + data.id);
|
||||||
|
|
||||||
|
document.location.href = data.url;
|
||||||
|
};
|
||||||
|
|
||||||
|
mod.previewMedia = function(data) {
|
||||||
|
var mediaId = data.id;
|
||||||
|
|
||||||
console.log("previewing media " + mediaId);
|
console.log("previewing media " + mediaId);
|
||||||
|
|
||||||
AIRTIME.playerPreview.previewMedia(mediaId);
|
AIRTIME.playerPreview.previewMedia(mediaId);
|
||||||
|
@ -64,35 +72,10 @@ var AIRTIME = (function(AIRTIME) {
|
||||||
function sendContextMenuRequest(data) {
|
function sendContextMenuRequest(data) {
|
||||||
|
|
||||||
console.log(data);
|
console.log(data);
|
||||||
mod[data.callback](data.id);
|
|
||||||
|
|
||||||
/*
|
if (data.callback !== undefined) {
|
||||||
var callback = data.callback;
|
mod[data.callback](data);
|
||||||
|
}
|
||||||
data.requestData["format"] = "json";
|
|
||||||
|
|
||||||
$.ajax({
|
|
||||||
url: data.requestUrl,
|
|
||||||
type: data.requestType,
|
|
||||||
data: data.requestData,
|
|
||||||
dataType: "json",
|
|
||||||
async: false,
|
|
||||||
success: function(json) {
|
|
||||||
|
|
||||||
var f = callback.split("."),
|
|
||||||
i,
|
|
||||||
len,
|
|
||||||
obj = window;
|
|
||||||
|
|
||||||
for (i = 0, len = f.length; i < len; i++) {
|
|
||||||
|
|
||||||
obj = obj[f[i]];
|
|
||||||
}
|
|
||||||
|
|
||||||
obj(json);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
*/
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function getActiveTabId() {
|
function getActiveTabId() {
|
||||||
|
|
Loading…
Reference in New Issue