/** * 视频信息 */ public function getVideo($videoId) { $tblVideo = new DB_Haodu_CourseVideo(); $video = $tblVideo->fetchRow($videoId); if ($video) { $video['url'] = Common_Config::getVideoUrl($videoId); $video['image'] = Common_Config::getVideoImageUrl($video['image']); $video['duration_fmt'] = sprintf("%'.02d", floor($video['duration'] / 60)) . ":" . sprintf("%'.02d", $video['duration'] % 60); $video['comment_num'] = $this->getVideoCommentNum($video['id']); return $video; } return false; }
/** * 章节列表array('chapter_id'=> array(array(节信息)) */ public function getSectionList($cid) { $tblSection = new DB_Haodu_CourseSection(); $list = $tblSection->fetchAll("id, video_id, course_id, parent_id as chapter_id, name, seq", "where course_id = {$cid} and parent_id > 0", "order by seq asc"); $tblVideo = new DB_Haodu_CourseVideo(); foreach ($list as &$section) { $video = $tblVideo->fetchRow($section['video_id'], "duration"); $section['duration'] = $video['duration']; $section['duration_fmt'] = sprintf("%'.02d", floor($video['duration'] / 60)) . ":" . sprintf("%'.02d", $video['duration'] % 60); } $list = $tblSection->map($list, "chapter_id"); return $list; }