X-Git-Url: http://p2p-next.cs.pub.ro/gitweb/?p=living-lab-site.git;a=blobdiff_plain;f=application%2Fhelpers%2Fvideo_helper.php;h=a172183f65d2c9ce592f2506da0b8916b3b03361;hp=67ede1af76a20112f9249aeafc7dfaf6875c703c;hb=038c14e7fb3d5de1399310651c97b1b8c892e145;hpb=8b8928b4cc25af9867c397ba5ef4b1129a8df5b5 diff --git a/application/helpers/video_helper.php b/application/helpers/video_helper.php index 67ede1a..a172183 100644 --- a/application/helpers/video_helper.php +++ b/application/helpers/video_helper.php @@ -100,11 +100,50 @@ function get_closest_res($haystack, $needle, $access_function = NULL) return $i_min; } +/** + * "Private" function used by get_av_info which returns the value from a + * "key=value" formatted string. + * + * @param string $str_key_value a string formatted as key=value + * @return string + */ +function _parse_value($str_key_value) +{ + return trim(substr( + $str_key_value, + strpos($str_key_value, '=') + 1, + strlen($str_key_value) + )); +} + +/** + * Formats the floating number of seconds to a string with format [HH:]mm:ss . + * + * @param float $secs + * @return string + */ +function format_duration($secs) +{ + $secs = intval(round($secs)); + + $h = intval(floor($secs / 3600)); + $m = intval(floor(($secs % 3600) / 60)); + $s = $secs % 3600 % 60; + + $duration = sprintf('%02d', $m) . ':' . sprintf('%02d', $s); + + if ($h > 0) + return sprintf('%02d', $h) . ':' . $duration; + + return $duration; +} + /** * Returns information about an Audio/Video file. * * @param string $file_name Audio/Video file - * @return dictionary a dictionary of audio/video properties with keys: + * @return dictionary FALSE on error or a dictionary of audio/video properties + * with the following keys otherwise: *