묻고답하기
page_full_width" class="col-xs-12" |cond="$__Context->page_full_width">
preg_match이용 유튜브 비메오 감별소스 질문..
2015.02.11 20:12
<?
if(preg_match('/[^.]*.?youtube.com/(embed|v)/([^?]+).*/', $oDocument->getExtraEidValue("video_url"), $video_match)){
// 유튜브 동영상 섬네일 처리 (2-1)
echo ($video_match);
} else if(preg_match('/[^.]*.?vimeo.com/(video/|moogaloop.swf?clip_id=)([^&]+).*/', $src, $video_match)){
// 비메오 동영상 섬네일 처리 (2-2)
echo ($video_match);
}
?>
안녕하세요..
다름이 아니오라 preg_match이용 유튜브 비메오 감별소스 질문 드립니다.
http://01_1__1001_1.amazingbutuseless.net/coding_for_life/5
블로그의 글을 참고하여 필요하다 생각되는 부분만 뽑아냈습니다.
필요한 기능은 preg_match로 확장변수 video_url에서
유튜브 또는 비메오의 id만 빼내서.. 그걸 플레이어로 띄워주는 기능입니다.
http://www.nemocultures.com/board_nemocultures_2015/5916
처럼 만들고 싶습니다.
그런데 위 소스가 들어가면 게시판이 아예 작동을 안하네요..ㅜㅜ
부디 고수님들 한수만 보여주세요 ㅜㅜ
감사합니다
<figure class="player"> {@ $video_eid = $oDocument->getExtraEidValue("video"); //동영상 정보 출력코드 $media_type = str_replace('http://','',$video_eid); $media_type = str_replace('https://','',$media_type); $media_type = str_replace('www.','',$media_type); $media_type = substr($media_type, 0, 5); } <!--@if($media_type=="youtu")--> {@ $youtube_vid = str_replace('www.','',$video_eid); $youtube_vid = str_replace('http://youtu.be/','',$youtube_vid); $youtube_vid = str_replace('https://youtu.be/','',$youtube_vid); $youtube_vid = strstr($youtube_vid, 'v='); $youtube_vid = str_replace("v=","",$youtube_vid); $video_play_url = 'http://www.youtube.com/embed/'.$youtube_vid.'?autoplay=0&rel=0&vq=hd720&version=3'; $video_autoplay_url = 'http://www.youtube.com/embed/'.$youtube_vid.'?autoplay=1&rel=0&vq=hd720&version=3'; $video_iframe = '<iframe id="video_iframe" width="1170" height="658" src="'.$video_play_url.'" frameborder="0" allowfullscreen></iframe>'; } <!--@elseif($media_type=="vimeo")--> {@ $vimeo_vid = str_replace('www.','',$video_eid); $vimeo_vid = str_replace('http://vimeo.com/','',$vimeo_vid); $vimeo_vid = str_replace('https://vimeo.com/','',$vimeo_vid); $video_play_url = '//player.vimeo.com/video/'.$vimeo_vid; $video_autoplay_url = '//player.vimeo.com/video/'.$vimeo_vid.'?autoplay=1'; $video_iframe = '<iframe id="video_iframe" width="1170" height="658" src="'.$video_play_url.'" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>'; } <!--@end--> {$video_iframe} </figure>