moveAudioClipInPlaylist method added to GreenBox.

This commit is contained in:
tomas 2005-03-09 02:55:31 +00:00
parent a41b58b751
commit 4a83ede603
2 changed files with 81 additions and 15 deletions

View File

@ -23,7 +23,7 @@
Author : $Author: tomas $
Version : $Revision: 1.52 $
Version : $Revision: 1.53 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/GreenBox.php,v $
------------------------------------------------------------------------------*/
@ -35,7 +35,7 @@ require_once "BasicStor.php";
* LiveSupport file storage module
*
* @author $Author: tomas $
* @version $Revision: 1.52 $
* @version $Revision: 1.53 $
* @see BasicStor
*/
class GreenBox extends BasicStor{
@ -506,6 +506,9 @@ class GreenBox extends BasicStor{
}
$res = $pl->addAudioClip($acId, $fadeIn, $fadeOut);
if(PEAR::isError($res)) return $res;
// recalculate offsets and total length:
$r = $pl->recalculateTimes();
if(PEAR::isError($r)){ return $r; }
return $res;
}
@ -513,9 +516,7 @@ class GreenBox extends BasicStor{
* Remove audioclip from playlist
*
* @param token string, playlist access token
* <span style="color:green">
* @param plElGunid string, global id of deleted playlistElement
* </span>
* @param sessid string, session ID
* @return boolean
*/
@ -526,11 +527,14 @@ class GreenBox extends BasicStor{
if(PEAR::isError($pl)) return $pl;
$res = $pl->delAudioClip($plElGunid);
if(PEAR::isError($res)) return $res;
// recalculate offsets and total length:
$r = $pl->recalculateTimes();
if(PEAR::isError($r)){ return $r; }
return $res;
}
/**
* <span style="color:red">Change fadInfo values</span>
* Change fadeInfo values
*
* @param token string, playlist access token
* @param plElGunid string, global id of deleted playlistElement
@ -546,7 +550,32 @@ class GreenBox extends BasicStor{
if(PEAR::isError($pl)) return $pl;
$res = $pl->changeFadeInfo($plElGunid, $fadeIn, $fadeOut);
if(PEAR::isError($res)) return $res;
return $res;
// recalculate offsets and total length:
$r = $pl->recalculateTimes();
if(PEAR::isError($r)){ return $r; }
return TRUE;
}
/**
* <span style="color:green">Move audioClip to the new position in the playlist</span>
*
* @param token string, playlist access token
* @param plElGunid string, global id of deleted playlistElement
* @param newPos int - new position in playlist
* @param sessid string, session ID
* @return boolean
*/
function moveAudioClipInPlaylist($token, $plElGunid, $newPos, $sessid)
{
require_once"Playlist.php";
$pl =& Playlist::recallByToken($this, $token);
if(PEAR::isError($pl)) return $pl;
$res = $pl->moveAudioClip($plElGunid, $newPos);
if(PEAR::isError($res)) return $res;
// recalculate offsets and total length:
$r = $pl->recalculateTimes();
if(PEAR::isError($r)){ return $r; }
return TRUE;
}
/**

View File

@ -23,7 +23,7 @@
Author : $Author: tomas $
Version : $Revision: 1.5 $
Version : $Revision: 1.6 $
Location : $Source: /home/paul/cvs2svn-livesupport/newcvsrepo/livesupport/modules/storageServer/var/Playlist.php,v $
------------------------------------------------------------------------------*/
@ -303,9 +303,6 @@ class Playlist extends StoredFile{
$r = $this->md->insertMetadataEl($acId, 'accessToken', $acToken, 'A');
if(PEAR::isError($r)){ return $r; }
*/
// recalculate offsets and total length:
$r = $this->recalculateTimes();
if(PEAR::isError($r)){ return $r; }
return $plElGunid;
}
@ -361,9 +358,6 @@ class Playlist extends StoredFile{
" ($plElGunid)"
);
}
// recalculate offsets and total length:
$r = $this->recalculateTimes();
if(PEAR::isError($r)){ return $r; }
return TRUE;
}
@ -409,8 +403,51 @@ class Playlist extends StoredFile{
$fadeOutId, $fadeOut, $fiMid, 'fadeOut');
if(PEAR::isError($r)){ return $r; }
}
$r = $this->recalculateTimes();
if(PEAR::isError($r)){ return $r; }
return TRUE;
}
/**
* Move audioClip to the new position in the playlist
*
* @param plElGunid string - playlistElement gunid
* @param newPos int - new position in playlist
* @return
*/
function moveAudioClip($plElGunid, $newPos)
{
$plGunid = $this->gunid;
$arr = $this->md->genPhpArray();
$els =& $arr['children'];
foreach($els as $i=>$el){
if($el['elementname'] != 'playlistelement'){
$metadata = array_splice($els, $i, 1);
continue;
}
}
foreach($els as $i=>$el){
if($el['attrs']['id'] == $plElGunid){
$movedi = $i;
}
$r = $this->delAudioClip($el['attrs']['id']);
if(PEAR::isError($r)){ return $r; }
}
$movedel = array_splice($els, $movedi, 1);
array_splice($els, $newPos, 0, $movedel);
// var_dump($els);
foreach($els as $i=>$el){
foreach($el['children'] as $j=>$af){
if($af['elementname'] == 'audioclip'){
$acGunid = $af['attrs']['id'];
}elseif($af['elementname'] == 'fadeinfo'){
$fadeIn = $af['attrs']['fadein'];
$fadeOut = $af['attrs']['fadeout'];
}else{
}
}
$acId = $this->gb->_idFromGunid($acGunid);
$r = $this->addAudioClip($acId, $fadeIn, $fadeOut);
if(PEAR::isError($r)){ return $r; }
}
return TRUE;
}