Merge branch 'devel' of dev.sourcefabric.org:airtime into devel
This commit is contained in:
commit
00a484d595
|
@ -272,13 +272,21 @@ class AudiopreviewController extends Zend_Controller_Action
|
||||||
'element_id' => ++$position,
|
'element_id' => ++$position,
|
||||||
);
|
);
|
||||||
|
|
||||||
$fileExtension = pathinfo($track['filepath'], PATHINFO_EXTENSION);
|
$elementMap['type'] = $track['type'];
|
||||||
if (strtolower($fileExtension) === 'mp3') {
|
if ($track['type'] == 0) {
|
||||||
$elementMap['element_mp3'] = $track['item_id'];
|
$fileExtension = pathinfo($track['filepath'], PATHINFO_EXTENSION);
|
||||||
} elseif (strtolower($fileExtension) === 'ogg') {
|
if (strtolower($fileExtension) === 'mp3') {
|
||||||
$elementMap['element_oga'] = $track['item_id'];
|
$elementMap['element_mp3'] = $track['item_id'];
|
||||||
|
} elseif (strtolower($fileExtension) === 'ogg') {
|
||||||
|
$elementMap['element_oga'] = $track['item_id'];
|
||||||
|
} else {
|
||||||
|
//the media was neither mp3 or ogg
|
||||||
|
throw new Exception("Unknown file type");
|
||||||
|
}
|
||||||
|
|
||||||
|
$elementMap['uri'] = "/api/get-media/file/".$track['item_id'];
|
||||||
} else {
|
} else {
|
||||||
//the media was neither mp3 or ogg
|
$elementMap['uri'] = $track['path'];
|
||||||
}
|
}
|
||||||
$result[] = $elementMap;
|
$result[] = $elementMap;
|
||||||
}
|
}
|
||||||
|
|
|
@ -154,40 +154,67 @@ class Application_Model_Playlist
|
||||||
public function getContents($filterFiles=false)
|
public function getContents($filterFiles=false)
|
||||||
{
|
{
|
||||||
Logging::log("Getting contents for playlist {$this->id}");
|
Logging::log("Getting contents for playlist {$this->id}");
|
||||||
|
|
||||||
$files = array();
|
$files = array();
|
||||||
/*
|
|
||||||
$query = CcPlaylistcontentsQuery::create()
|
|
||||||
->filterByDbPlaylistId($this->id);
|
|
||||||
|
|
||||||
if ($filterFiles) {
|
$sql = <<<SQL
|
||||||
$query->useCcFilesQuery()
|
(SELECT *
|
||||||
->filterByDbFileExists(true)
|
FROM (
|
||||||
->endUse();
|
(SELECT pc.id AS id,
|
||||||
}
|
pc.type,
|
||||||
$query->orderByDbPosition()
|
pc.position,
|
||||||
->filterByDbType(0)
|
pc.cliplength AS LENGTH,
|
||||||
->leftJoinWith('CcFiles');
|
pc.cuein,
|
||||||
$rows = $query->find($this->con);
|
pc.cueout,
|
||||||
*/
|
pc.fadein,
|
||||||
$sql = <<<"EOT"
|
pc.fadeout,
|
||||||
(SELECT * FROM
|
f.id AS item_id,
|
||||||
((SELECT pc.id as id, pc.type, pc.position, pc.cliplength as length, pc.cuein, pc.cueout, pc.fadein, pc.fadeout,
|
f.track_title,
|
||||||
f.id as item_id, f.track_title, f.artist_name as creator, f.file_exists as exists, f.filepath as path FROM cc_playlistcontents AS pc
|
f.artist_name AS creator,
|
||||||
JOIN cc_files AS f ON pc.file_id=f.id WHERE pc.playlist_id = {$this->id} AND type = 0)
|
f.file_exists AS EXISTS,
|
||||||
UNION ALL
|
f.filepath AS path
|
||||||
(SELECT pc.id as id, pc.type, pc.position, pc.cliplength as length, pc.cuein, pc.cueout, pc.fadein, pc.fadeout,
|
FROM cc_playlistcontents AS pc
|
||||||
ws.id as item_id, (ws.name || ': ' || ws.url) as title, sub.login as creator, 't'::boolean as exists, ws.url as path FROM cc_playlistcontents AS pc
|
JOIN cc_files AS f ON pc.file_id=f.id
|
||||||
JOIN cc_webstream AS ws on pc.stream_id=ws.id
|
WHERE pc.playlist_id = {$this->id}
|
||||||
LEFT JOIN cc_subjs as sub on sub.id = ws.creator_id
|
AND TYPE = 0)
|
||||||
WHERE pc.playlist_id = {$this->id} AND pc.type = 1)
|
UNION ALL
|
||||||
UNION ALL
|
(SELECT pc.id AS id,
|
||||||
(SELECT pc.id as id, pc.type, pc.position, pc.cliplength as length, pc.cuein, pc.cueout, pc.fadein, pc.fadeout,
|
pc.TYPE, pc.position,
|
||||||
bl.id as item_id, bl.name as title, sbj.login as creator, 't'::boolean as exists, NULL::text as path FROM cc_playlistcontents AS pc
|
pc.cliplength AS LENGTH,
|
||||||
JOIN cc_block AS bl on pc.block_id=bl.id
|
pc.cuein,
|
||||||
JOIN cc_subjs as sbj ON bl.creator_id=sbj.id WHERE pc.playlist_id = {$this->id} AND pc.type = 2)) as temp
|
pc.cueout,
|
||||||
ORDER BY temp.position);
|
pc.fadein,
|
||||||
EOT;
|
pc.fadeout,
|
||||||
|
ws.id AS item_id,
|
||||||
|
(ws.name || ': ' || ws.url) AS title,
|
||||||
|
sub.login AS creator,
|
||||||
|
't'::boolean AS EXISTS,
|
||||||
|
ws.url AS path
|
||||||
|
FROM cc_playlistcontents AS pc
|
||||||
|
JOIN cc_webstream AS ws ON pc.stream_id=ws.id
|
||||||
|
LEFT JOIN cc_subjs AS sub ON sub.id = ws.creator_id
|
||||||
|
WHERE pc.playlist_id = {$this->id}
|
||||||
|
AND pc.TYPE = 1)
|
||||||
|
UNION ALL
|
||||||
|
(SELECT pc.id AS id,
|
||||||
|
pc.TYPE, pc.position,
|
||||||
|
pc.cliplength AS LENGTH,
|
||||||
|
pc.cuein,
|
||||||
|
pc.cueout,
|
||||||
|
pc.fadein,
|
||||||
|
pc.fadeout,
|
||||||
|
bl.id AS item_id,
|
||||||
|
bl.name AS title,
|
||||||
|
sbj.login AS creator,
|
||||||
|
't'::boolean AS EXISTS,
|
||||||
|
NULL::text AS path
|
||||||
|
FROM cc_playlistcontents AS pc
|
||||||
|
JOIN cc_block AS bl ON pc.block_id=bl.id
|
||||||
|
JOIN cc_subjs AS sbj ON bl.creator_id=sbj.id
|
||||||
|
WHERE pc.playlist_id = {$this->id}
|
||||||
|
AND pc.TYPE = 2)) AS temp
|
||||||
|
ORDER BY temp.position);
|
||||||
|
SQL;
|
||||||
|
|
||||||
$con = Propel::getConnection();
|
$con = Propel::getConnection();
|
||||||
$rows = $con->query($sql)->fetchAll();
|
$rows = $con->query($sql)->fetchAll();
|
||||||
|
|
||||||
|
@ -198,7 +225,7 @@ EOT;
|
||||||
$offset_cliplength = Application_Common_DateHelper::secondsToPlaylistTime($offset);
|
$offset_cliplength = Application_Common_DateHelper::secondsToPlaylistTime($offset);
|
||||||
|
|
||||||
//format the length for UI.
|
//format the length for UI.
|
||||||
if ($row['type'] == 2){
|
if ($row['type'] == 2) {
|
||||||
$bl = new Application_Model_Block($row['item_id']);
|
$bl = new Application_Model_Block($row['item_id']);
|
||||||
$formatter = new LengthFormatter($bl->getFormattedLength());
|
$formatter = new LengthFormatter($bl->getFormattedLength());
|
||||||
} else {
|
} else {
|
||||||
|
@ -210,28 +237,6 @@ EOT;
|
||||||
$row['offset'] = $formatter->format();
|
$row['offset'] = $formatter->format();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
$i = 0;
|
|
||||||
$offset = 0;
|
|
||||||
foreach ($rows as $row) {
|
|
||||||
Logging::log($row);
|
|
||||||
$files[$i] = $row->toArray(BasePeer::TYPE_FIELDNAME, true, true);
|
|
||||||
|
|
||||||
$clipSec = Application_Common_DateHelper::playlistTimeToSeconds($files[$i]['cliplength']);
|
|
||||||
$offset += $clipSec;
|
|
||||||
$offset_cliplength = Application_Common_DateHelper::secondsToPlaylistTime($offset);
|
|
||||||
|
|
||||||
//format the length for UI.
|
|
||||||
$formatter = new LengthFormatter($files[$i]['cliplength']);
|
|
||||||
$files[$i]['cliplength'] = $formatter->format();
|
|
||||||
|
|
||||||
$formatter = new LengthFormatter($offset_cliplength);
|
|
||||||
$files[$i]['offset'] = $formatter->format();
|
|
||||||
|
|
||||||
$i++;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
return $rows;
|
return $rows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -653,9 +653,8 @@ class Application_Model_ShowInstance
|
||||||
WHERE s.instance_id = '{$this->_instanceId}' AND s.playout_status >= 0
|
WHERE s.instance_id = '{$this->_instanceId}' AND s.playout_status >= 0
|
||||||
ORDER BY starts";
|
ORDER BY starts";
|
||||||
|
|
||||||
//Logging::log($sql);
|
|
||||||
|
|
||||||
$results = $con->query($sql)->fetchAll();
|
$results = $con->query($sql)->fetchAll(PDO::FETCH_ASSOC);
|
||||||
|
|
||||||
foreach ($results as &$row) {
|
foreach ($results as &$row) {
|
||||||
|
|
||||||
|
|
|
@ -111,8 +111,9 @@ function playAllShow(p_showID, p_index) {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This function will call the AudiopreviewController to get the contents of either a show or playlist
|
* This function will call the AudiopreviewController to get the contents of
|
||||||
* Looping throught the returned contents and creating media for each track.
|
* either a show or playlist Looping throught the returned contents and
|
||||||
|
* creating media for each track.
|
||||||
*
|
*
|
||||||
* Then trigger the jplayer to play the list.
|
* Then trigger the jplayer to play the list.
|
||||||
*/
|
*/
|
||||||
|
@ -123,8 +124,7 @@ function buildplaylist(p_url, p_playIndex) {
|
||||||
var media;
|
var media;
|
||||||
var index;
|
var index;
|
||||||
var total = 0;
|
var total = 0;
|
||||||
for(index in data){
|
for(index in data) {
|
||||||
|
|
||||||
if (data[index]['type'] == 0) {
|
if (data[index]['type'] == 0) {
|
||||||
if (data[index]['element_mp3'] != undefined){
|
if (data[index]['element_mp3'] != undefined){
|
||||||
media = {title: data[index]['element_title'],
|
media = {title: data[index]['element_title'],
|
||||||
|
@ -146,8 +146,8 @@ function buildplaylist(p_url, p_playIndex) {
|
||||||
if (media) {
|
if (media) {
|
||||||
myPlaylist[index] = media;
|
myPlaylist[index] = media;
|
||||||
}
|
}
|
||||||
// we should create a map according to the new position in the player itself
|
// we should create a map according to the new position in the
|
||||||
// total is the index on the player
|
// player itself total is the index on the player
|
||||||
_idToPostionLookUp[data[index]['element_id']] = total;
|
_idToPostionLookUp[data[index]['element_id']] = total;
|
||||||
total++;
|
total++;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue