decryptKMSDataKey($CipherText); } /** * 调用SubmitTranscodeJobs提交媒体转码作业,开始异步转码处理。 * @param $videoId 视频ID * @param $TemplateGroupId 视频转码时使用的转码组ID * @return mixed */ public static function submitTranscodeJobs($videoId,$TemplateGroupId){ $generateKMSDataKey = \addons\alivod\library\Alivod::generateKMSDataKey(); $CiphertextBlob = $generateKMSDataKey->CiphertextBlob; global $_W; if(defined('TUZHI_SYSTEM_TYPE') && TUZHI_SYSTEM_TYPE == 'single'){ $DecryptKeyUri = $_W['siteroot'].'/index.php?i=1&route=addons/alivod/index/decode&CipherText='.$CiphertextBlob; }else{ $DecryptKeyUri = $_W['siteroot'].'/app/index.php?i='.$_W['uniacid'].'&c=entry&m=tuzi_v1&do=index&route=addons/alivod/index/decode&CipherText='.$CiphertextBlob; } $EncryptConfig = '{"CipherText":"'.$CiphertextBlob.'","DecryptKeyUri":"'.$DecryptKeyUri.'","KeyServiceType":"KMS"}'; $playService = new \ShaoZeMing\AliVod\Services\TranscodeService(); return $playService->submitTranscodeJobs($videoId,$TemplateGroupId,$EncryptConfig); } /** * 调用SubmitTranscodeJobs提交媒体转码作业,开始异步转码处理。 * @param $videoId 视频ID * @param $TemplateGroupId 视频转码时使用的转码组ID * @return mixed */ public static function generateKMSDataKey(){ $playService = new \ShaoZeMing\AliVod\Services\TranscodeService(); return $playService->generateKMSDataKey(); } /** * 通过音视频ID直接获取媒体文件(支持视频和音频)的播放地址。 * @param $videoId * @return mixed */ public static function getPlayInfo($videoId){ $playService = new \ShaoZeMing\AliVod\Services\PlayService(); return $playService->getPlayInfo($videoId); } /** * 查询转码任务列表 * @param $videoId * @return mixed */ public static function getListTranscodeTask($videoId){ $playService = new \ShaoZeMing\AliVod\Services\TranscodeService(); return $playService->getListTranscodeTask($videoId); } /** * 获取音视频播放时所需的播放凭证。 * @param $videoId * @return mixed */ public static function getVideoPlayAuth($videoId){ $playService = new \ShaoZeMing\AliVod\Services\PlayService(); return $playService->getVideoPlayAuth($videoId); } /** * 解析阿里云点播标签 * @param $content * @return array|string|string[]|null */ public static function parseAliovdTag($content){ //判断是否包含标签 if(strpos($content, "") !== false){ // 使用正则表达式匹配标签及其内容 $content = html_entity_decode($content); $pattern = '/(.*?)<\/alivod>/'; $content = preg_replace_callback($pattern, array(__CLASS__, 'getPlayUrl'), $content); return $content; } return self::getPlayUrl($content); } /** * 解析富文本内容中的阿里云点播标签 * @param $content * @return array|string|string[]|null */ public static function parseContentAliovdTag($content){ //判断是否包含标签 if(strpos($content, "") !== false){ // 使用正则表达式匹配标签及其内容 $content = html_entity_decode($content); $pattern = '/(.*?)<\/alivod>/'; $content = preg_replace_callback($pattern, array(__CLASS__, 'getPlayUrl'), $content); return $content; } return $content; } /** * 获取源文件信息 * @remark 获取音视频的源文件信息,包括文件地址、分辨率、码率等。 * @params $tag 附件保存的阿里云点播文件标签 * @return void */ public static function getMezzanineInfo($tag){ $content = html_entity_decode($tag); $pattern = '/(.*?)<\/alivod>/'; //正则获取$pattern过滤后的内容 preg_match($pattern, $content, $matches); $playService = new \ShaoZeMing\AliVod\Services\FileService(); return $playService->getMezzanineInfo($matches[1]); } /** * 获取播放地址 * @param $match * @return string */ public static function getPlayUrl($match) { $link = ''; $url = ''; try{ $url = is_array($match) ? $match[1] : $match; // $cacheData = \think\Cache::get(\app\common\constant\cache\Keys::VOD_PLAY_URL($url)); // if($cacheData){ // return $cacheData; // } $data = \addons\alivod\library\Alivod::getPlayInfo($url); foreach ($data->PlayInfoList->PlayInfo as $item){ if($item->EncryptType == 'HLSEncryption'){ $link = $item->PlayURL; break; } } }catch (\Exception $e){} // 在实际应用中,你可以根据匹配的内容进行解析和替换 // if($url && $link){ // \think\Cache::tag(\app\common\constant\cache\Keys::VOD_TAG)->set(\app\common\constant\cache\Keys::VOD_PLAY_URL($url),$link); // } return $link; } }