From 03329ad2cffad9d87471ecc9963d95013e650367 Mon Sep 17 00:00:00 2001 From: Daniel Franklin Date: Thu, 2 Feb 2012 14:44:14 -0500 Subject: [PATCH] CC-2065: Fade times longer than Airtime supports can be set in Playlist Builder and Preferences - Updated the logic in the fade in/out loggic so the Time format 00:00:00 appears as the more practical seconds format 00. - I also updated the error message so it includes the time unit seconds in the message. --- .../application/forms/GeneralPreferences.php | 6 +-- airtime_mvc/application/models/Playlist.php | 50 ++++++++++++++++--- .../views/scripts/playlist/index.phtml | 4 +- airtime_mvc/public/js/airtime/library/spl.js | 8 +-- 4 files changed, 52 insertions(+), 16 deletions(-) diff --git a/airtime_mvc/application/forms/GeneralPreferences.php b/airtime_mvc/application/forms/GeneralPreferences.php index a3da6f30a..ace81ab44 100644 --- a/airtime_mvc/application/forms/GeneralPreferences.php +++ b/airtime_mvc/application/forms/GeneralPreferences.php @@ -11,7 +11,7 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm $defaultFade = Application_Model_Preference::GetDefaultFade(); if($defaultFade == ""){ - $defaultFade = '00:00:00.500000'; + $defaultFade = '00.500000'; } //Station name @@ -33,8 +33,8 @@ class Application_Form_GeneralPreferences extends Zend_Form_SubForm 'required' => false, 'filters' => array('StringTrim'), 'validators' => array(array('regex', false, - array('/^[0-2][0-3]:[0-5][0-9]:[0-5][0-9](\.\d{1,6})?$/', - 'messages' => 'enter a time 00:00:00{.000000}'))), + array('/^[0-5][0-9](\.\d{1,6})?$/', + 'messages' => 'enter a time in seconds 00{.000000}'))), 'value' => $defaultFade, 'decorators' => array( 'ViewHelper' diff --git a/airtime_mvc/application/models/Playlist.php b/airtime_mvc/application/models/Playlist.php index 98d6aaa06..ee92a5436 100644 --- a/airtime_mvc/application/models/Playlist.php +++ b/airtime_mvc/application/models/Playlist.php @@ -409,12 +409,39 @@ class Application_Model_Playlist { $files[$i]['cliplength'] = Application_Model_Playlist::secondsToPlaylistTime($clipSec); $offset += $clipSec; $files[$i]['offset'] = Application_Model_Playlist::secondsToPlaylistTime($offset); + + #For issue CC-2065 - update fade in and out values between playlst elements + #modified from the db default format of 00:00:00 to the more practical + #00.000000 format which is for only seconds. + $files[$i]['fadein'] = $this->normalizeFade($files[$i]['fadein']); + $files[$i]['fadeout'] = $this->normalizeFade($files[$i]['fadeout']); + $i++; } return $files; } + /** + * The database stores fades in 00:00:00 Time format with optional millisecond resolution .000000 + * but this isn't practical since fades shouldn't be very long usuall 1 second or less. This function + * will normalize the fade so that it looks like 00.000000 to the user. + **/ + public function normalizeFade($fade) { + //First get rid of the first six characters 00:00: which will be added back later for db update + $fade = substr($fade, 6); + + //Second add .000000 if the fade does't have milliseconds format already + $dbFadeStrPos = strpos( $fade, '.' ); + if ( $dbFadeStrPos === False ) + $fade .= '.000000'; + else + while( strlen( $fade ) < 8 ) + $fade .= '0'; + //done, just need to set back the formated values + return $fade; + } + public function getLength() { $res = CcPlaylistQuery::create() ->findPK($this->id) @@ -496,9 +523,9 @@ class Application_Model_Playlist { * @param string $p_position * optional, Which position in the playlist to insert the audio clip * @param string $p_fadeIn - * optional, in time format hh:mm:ss.ssssss - total duration + * optional, in time format ss.ssssss - total duration * @param string $p_fadeOut - * optional, in time format hh:mm:ss.ssssss - total duration + * optional, in time format ss.ssssss - total duration * @param string $p_clipLength * optional length in in time format hh:mm:ss.ssssss - * for webstream (or for overrule length of audioclip) @@ -612,7 +639,13 @@ class Application_Model_Playlist { $fadeIn = $row->getDbFadein(); $fadeOut = $row->getDbFadeout(); - return array($fadeIn, $fadeOut); + #For issue CC-2065, fade in and out values are for the Playlist itself and must be + #modified from the db default format of 00:00:00 to the more practical + #00.000000 format which is for only seconds. + $fadeIn = $this->normalizeFade($fadeIn); + $fadeOut = $this->normalizeFade($fadeOut); + + return array($fadeIn, $fadeOut); } /** @@ -628,6 +661,10 @@ class Application_Model_Playlist { */ public function changeFadeInfo($pos, $fadeIn, $fadeOut) { + #See issue CC-2065, pad the fadeIn and fadeOut so that it is TIME compatable with the DB schema + $fadeIn = '00:00:'.$fadeIn; + $fadeOut = '00:00:'.$fadeOut; + $errArray= array(); $con = Propel::getConnection(CcPlaylistPeer::DATABASE_NAME); @@ -651,7 +688,6 @@ class Application_Model_Playlist { //"Fade In can't be larger than overall playlength."; $fadeIn = $clipLength; } - $row->setDbFadein($fadeIn); } if(!is_null($fadeOut)){ @@ -662,7 +698,6 @@ class Application_Model_Playlist { //Fade Out can't be larger than overall playlength."; $fadeOut = $clipLength; } - $row->setDbFadeout($fadeOut); } @@ -987,13 +1022,13 @@ class Application_Model_Playlist { if($defaultFade != "") $fadeIn = $defaultFade; else - $fadeIn = '00:00:00.000'; + $fadeIn = '00.000000'; } if(is_null($fadeOut)) { if($defaultFade != "") $fadeOut = $defaultFade; else - $fadeOut = '00:00:00.000'; + $fadeOut = '00.000000'; } $row = new CcPlaylistcontents(); @@ -1004,6 +1039,7 @@ class Application_Model_Playlist { $row->setDbCliplength($clipLength); $row->setDbCuein($cuein); + $row->setDbCueout($cueout); $row->setDbFadein($fadeIn); $row->setDbFadeout($fadeOut); diff --git a/airtime_mvc/application/views/scripts/playlist/index.phtml b/airtime_mvc/application/views/scripts/playlist/index.phtml index 134cfa047..6f4d6836b 100644 --- a/airtime_mvc/application/views/scripts/playlist/index.phtml +++ b/airtime_mvc/application/views/scripts/playlist/index.phtml @@ -34,10 +34,10 @@
Fade in:
-
00:00:00
+
00
Fade out:
-
00:00:00
+
00/span>
diff --git a/airtime_mvc/public/js/airtime/library/spl.js b/airtime_mvc/public/js/airtime/library/spl.js index 1e73592b3..95add5127 100644 --- a/airtime_mvc/public/js/airtime/library/spl.js +++ b/airtime_mvc/public/js/airtime/library/spl.js @@ -109,7 +109,7 @@ function changeFadeIn(event) { unqid = li.attr("unqid"); if(!isTimeValid(fadeIn)){ - showError(span, "please put in a time '00:00:00 (.000000)'"); + showError(span, "please put in a time in seconds '00 (.000000)'"); return; } @@ -141,7 +141,7 @@ function changeFadeOut(event) { unqid = li.attr("unqid"); if(!isTimeValid(fadeOut)){ - showError(span, "please put in a time '00:00:00 (.000000)'"); + showError(span, "please put in a time in seconds '00 (.000000)'"); return; } @@ -482,7 +482,7 @@ function setUpSPL() { fadeIn = $.trim(span.text()); if(!isTimeValid(fadeIn)){ - showError(span, "please put in a time '00:00:00 (.000000)'"); + showError(span, "please put in a time in seconds '00 (.000000)'"); return; } @@ -508,7 +508,7 @@ function setUpSPL() { fadeOut = $.trim(span.text()); if(!isTimeValid(fadeOut)){ - showError(span, "please put in a time '00:00:00 (.000000)'"); + showError(span, "please put in a time in seconds '00 (.000000)'"); return; }