Youtube와 Vimeo 동영상 재생 버그 수정 (2)
-
- 첨부파일 : bbs.class.php.zip (12.0K) - 다운로드
본문
저의 고객분께서도 매트릭스님과 동일한 문제를 겪고 있었는데, 버그에 대해 말씀드렸더니만... Youtube와 Vimeo에 대해서만이라도 어떤 형태로 입력하든지 상관없이 작동되도로 코드 수정해 달라시네요. 그래서, 다음 5가지 예처럼 어떠한 형태의 Video Link를 입력하더라도 정상적으로 처리되도록 수정하였습니다.
Youtube 영상 링크:
https://www.youtube.com/watch?v=ZIr2vq-qnlA
https://youtu.be/ZIr2vq-qnlA
https://www.youtube.com/embed/ZIr2vq-qnlA
Vimeo 영상 링크
https://vimeo.com/295243428
https://player.vimeo.com/video/295243428
버그 수정된 첨부파일 bbs.class.php를 다운로드하셔서 /eyoom/class/ 폴더로 복사하시면 됩니다.
수정된 쏘스코드의 내용은 다음과 같습니다. 어젯밤에 올린 버그 패치보다 좀 더 신경써서 기존 함수 $this->get_video_key($info)를 이용하였고 youtu.be와 player.vimeo.com를 처리할 수 있는 case를 추가하였습니다.
이윰빌더 4.1.4 버전 기준입니다.
# git diff
diff --git a/eyoom/class/bbs.class.php b/eyoom/class/bbs.class.php
index 360a9ac..e625a0d 100644
--- a/eyoom/class/bbs.class.php
+++ b/eyoom/class/bbs.class.php
@@ -404,21 +404,29 @@ class bbs extends eyoom
/**
* Youtube
*/
+ case 'youtu.be':
case 'youtube.com':
- if ($src[1]) {
- $video['key1'] = $src[1];
- } else {
- $video['key1'] = $query['v'];;
- }
+ if (preg_match("/\/watch/i",$info['path'])) {
+ $video['key1'] = $query['v'];
+ } else {
+ if ($info['path']) {
+ $video['key1'] = $this->get_video_key($info);
+ } else {
+ $video['key1'] = $src[1]; /** Just a legacy history **/
+ }
+ }
break;
/**
* Vimeo
*/
+ case 'player.vimeo.com':
case 'vimeo.com':
if ($src[1] && $src[2]) {
$video['key1'] = $src[1];
$video['key2'] = $src[2];
+ } elseif ($info['path']) {
+ $video['key1'] = $this->get_video_key($info);
} else {
$data = $this->get_video_use_curl($video_url, $host);
$video['key1'] = $data['vid'];
@@ -616,6 +624,7 @@ class bbs extends eyoom
/**
* Vimeo
*/
+ case 'player.vimeo.com':
case 'vimeo.com':
preg_match('/\<meta property=\"og:url\"\scontent=\"(?P<vid>[a-zA-Z0-9:\/\._]+)\"/i', $output, $scrapping);
$out['vid'] = $this->get_video_key($this->eyoom_host($scrapping['vid']));
@@ -730,35 +739,36 @@ class bbs extends eyoom
case 'youtu.be':
case 'youtube.com':
$vlist = $video['key2'] ? '&list='.$video['key2'] : '';
- $source = '<iframe width="'.$video['width'].'" height="'.$video['height'].'" src="http://www.youtube.com/embed/'.$video['key1'].'?wmode=opaque&autohide=1'.$vlist.'" frameborder="0" allowfullscreen></iframe>';
+ $source = '<iframe width="'.$video['width'].'" height="'.$video['height'].'" src="//www.youtube.com/embed/'.$video['key1'].'?wmode=opaque&autohide=1'.$vlist.'" frameborder="0" allowfullscreen></iframe>';
break;
case 'tvcast.naver.com':
case 'tv.naver.com':
- $source = '<iframe width="'.$video['width'].'" height="'.$video['height'].'" src="http://serviceapi.rmcnmv.naver.com/flash/outKeyPlayer.nhn?vid='.$video['key1'].'&outKey='.$video['key2'].'&controlBarMovable=true&jsCallable=true&skinName=tvcast_black" frameborder="no" scrolling="no" marginwidth="0" marginheight="0"></iframe>';
+ $source = '<iframe width="'.$video['width'].'" height="'.$video['height'].'" src="//serviceapi.rmcnmv.naver.com/flash/outKeyPlayer.nhn?vid='.$video['key1'].'&outKey='.$video['key2'].'&controlBarMovable=true&jsCallable=true&skinName=tvcast_black" frameborder="no" scrolling="no" marginwidth="0" marginheight="0"></iframe>';
break;
+ case 'player.vimeo.com':
case 'vimeo.com':
$source = '<iframe src="//player.vimeo.com/video/'.$video['key1'].'" width="'.$video['width'].'" height="'.$video['height'].'" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>';
break;
case 'ted.com':
- $source = '<iframe src="https://embed-ssl.ted.com/talks/'.$video['key1'].'.html" width="'.$video['width'].'" height="'.$video['height'].'" frameborder="0" scrolling="no" allowFullScreen></iframe>';
+ $source = '<iframe src="//embed-ssl.ted.com/talks/'.$video['key1'].'.html" width="'.$video['width'].'" height="'.$video['height'].'" frameborder="0" scrolling="no" allowFullScreen></iframe>';
break;
case 'tvpot.daum.net':
case 'tv.kakao.com':
- $source = '<iframe width="'.$video['width'].'" height="'.$video['height'].'" src="http://videofarm.daum.net/controller/video/viewer/Video.html?vid='.$video['key1'].'&play_loc=undefined&wmode=opaque" frameborder="0" scrolling="no"></iframe>';
+ $source = '<iframe width="'.$video['width'].'" height="'.$video['height'].'" src="//videofarm.daum.net/controller/video/viewer/Video.html?vid='.$video['key1'].'&play_loc=undefined&wmode=opaque" frameborder="0" scrolling="no"></iframe>';
break;
case 'channel.pandora.tv':
case 'pan.best':
- $source = '<iframe width="'.$video['width'].'" height="'.$video['height'].'" src="http://channel.pandora.tv/php/embed.fr1.ptv?userid='.$video['key2'].'&prgid='.$video['key1'].'&skin=1&autoPlay=false&share=on" frameborder="0" allowfullscreen></iframe>';
+ $source = '<iframe width="'.$video['width'].'" height="'.$video['height'].'" src="//channel.pandora.tv/php/embed.fr1.ptv?userid='.$video['key2'].'&prgid='.$video['key1'].'&skin=1&autoPlay=false&share=on" frameborder="0" allowfullscreen></iframe>';
break;
case 'dailymotion.com':
case 'dai.ly':
- $source = '<iframe frameborder="0" width="'.$video['width'].'" height="'.$video['height'].'" src="http://www.dailymotion.com/embed/video/'.$video['key1'].'"></iframe>';
+ $source = '<iframe frameborder="0" width="'.$video['width'].'" height="'.$video['height'].'" src="//www.dailymotion.com/embed/video/'.$video['key1'].'"></iframe>';
break;
case 'facebook.com':
- $source = '<iframe src="https://www.facebook.com/video/embed?video_id='.urlencode($video['key1']).'" width="'.$video['width'].'" height="'.$video['height'].'" frameborder="0"></iframe>';
+ $source = '<iframe src="//www.facebook.com/video/embed?video_id='.urlencode($video['key1']).'" width="'.$video['width'].'" height="'.$video['height'].'" frameborder="0"></iframe>';
break;
case 'slideshare.net':
- $source = '<iframe src="https://www.slideshare.net/slideshow/embed_code/'.$video['key1'].'" width="'.$video['width'].'" height="'.$video['height'].'" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" allowfullscreen></iframe>';
+ $source = '<iframe src="//www.slideshare.net/slideshow/embed_code/'.$video['key1'].'" width="'.$video['width'].'" height="'.$video['height'].'" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" allowfullscreen></iframe>';
break;
case 'sendvid.com':
$source = '<iframe width="'.$video['width'].'" height="'.$video['height'].'" src="//sendvid.com/embed/'.$video['key1'].'" frameborder="0" allowfullscreen></iframe>';
@@ -766,11 +776,11 @@ class bbs extends eyoom
case 'youku.com':
case 'v.youku.com':
case 'player.youku.com':
- $source = '<iframe width="'.$video['width'].'" height="'.$video['height'].'" src="http://player.youku.com/embed/'.$video['key1'].'" frameborder="0" allowfullscreen></iframe>';
+ $source = '<iframe width="'.$video['width'].'" height="'.$video['height'].'" src="//player.youku.com/embed/'.$video['key1'].'" frameborder="0" allowfullscreen></iframe>';
break;
case 'iqiyi.com':
case 'player.video.qiyi.com':
- $source = '<iframe width="'.$video['width'].'" height="'.$video['height'].'" src="http://open.iqiyi.com/developer/player_js/coopPlayerIndex.html?vid='.$video['key1'].'&tvId='.$video['key2'].'" frameborder="0" allowfullscreen></iframe>';
+ $source = '<iframe width="'.$video['width'].'" height="'.$video['height'].'" src="//open.iqiyi.com/developer/player_js/coopPlayerIndex.html?vid='.$video['key1'].'&tvId='.$video['key2'].'" frameborder="0" allowfullscreen></iframe>';
break;
}
if ($source) {
@@ -1621,4 +1631,4 @@ class bbs extends eyoom
return $wr_content;
}
-}
\ No newline at end of file
+}
다음 그림들은 각 Video URL에 따른 Array 변수값을 Dump한 것입니다. 디버깅과 버그 수정에 참고하세요.
https://vimeo.com/295243428
https://player.vimeo.com/video/295243428
https://www.youtube.com/watch?v=ZIr2vq-qnlA
https://youtu.be/ZIr2vq-qnlA
https://www.youtube.com/embed/ZIr2vq-qnlA
댓글목록4
닭발은세개님의 댓글
다음 버전에서 이윰 개발자님들도 참고해 주시리라 믿습니다. ^^
축하합니다. 첫댓글 포인트 36포인트를 획득하였습니다.
이윰IN님의 댓글의 댓글
감사합니다.
이윰IN님의 댓글
JamesShin님 안녕하세요.
이런 도움을 주시다니 너무도 감사드립니다.
검토해 보도록 하겠습니다.
앞으로도 많은 도움 부탁드립니다.
진심으로 큰 힘이 되거든요. ^^b
JamesShin님의 댓글의 댓글