video_filter.codecs.inc 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638
  1. <?php
  2. /**
  3. * @file
  4. * This file contains all codecs provided by Video Filter.
  5. */
  6. /**
  7. * Implements hook_codec_info().
  8. */
  9. function video_filter_codec_info() {
  10. $codecs = array();
  11. $codecs['archive'] = array(
  12. 'name' => t('Archive.org'),
  13. 'sample_url' => 'http://www.archive.org/details/DrupalconBoston2008-TheStateOfDrupal',
  14. 'callback' => 'video_filter_archive',
  15. 'html5_callback' => 'video_filter_archive',
  16. 'regexp' => '/archive\.org\/details\/([\w-_]+)/i',
  17. 'ratio' => 4 / 3,
  18. );
  19. $codecs['bliptv'] = array(
  20. 'name' => t('Blip.tv'),
  21. 'sample_url' => 'http://blip.tv/file/123456',
  22. 'callback' => 'video_filter_bliptv',
  23. 'regexp' => array(
  24. '@blip\.tv/rss/flash/([^"\&\?/]+)@i',
  25. '@blip\.tv/file/view/([^"\&\?/]+)@i',
  26. '@blip\.tv/file/([^"\&\?/]+)@i',
  27. '@blip\.tv/play/([^"\&\?/]+)@i',
  28. ),
  29. 'ratio' => 16 / 9,
  30. 'control_bar_height' => 30,
  31. );
  32. $codecs['candidcareer'] = array(
  33. 'name' => t('Candid Career'),
  34. 'sample_url' => 'https://www.candidcareer.com/embed.php?vkey=ed5fdd900a274930252f&shared=CandidCareer&uid=30',
  35. 'callback' => 'video_filter_candidcareer',
  36. 'regexp' => '/candidcareer\.com\/embed\.php\?vkey=([a-zA-Z0-9\-_&;]+)shared=([a-zA-Z0-9\-_&;]+)uid=([a-zA-Z0-9\-_&;]+)/',
  37. 'ratio' => 16 / 9,
  38. 'control_bar_height' => 20,
  39. );
  40. $codecs['capped'] = array(
  41. 'name' => t('Capped'),
  42. 'sample_url' => 'http://capped.tv/playeralt.php?vid=some-title',
  43. 'callback' => 'video_filter_capped',
  44. 'regexp' => '/capped\.tv\/([a-zA-Z0-9\-_]+)/',
  45. 'ratio' => 425 / 355,
  46. );
  47. $codecs['collegehumor'] = array(
  48. 'name' => t('College Humor'),
  49. 'sample_url' => 'http://www.collegehumor.com/video:1234567890',
  50. 'callback' => 'video_filter_collegehumor',
  51. 'regexp' => '/collegehumor\.com\/video\:([0-9]+)/',
  52. 'ratio' => 16 / 9,
  53. 'control_bar_height' => 0,
  54. );
  55. $codecs['dailymotion'] = array(
  56. 'name' => t('DailyMotion'),
  57. 'sample_url' => 'http://www.dailymotion.com/video/some_video_title',
  58. 'callback' => 'video_filter_dailymotion',
  59. 'regexp' => '/dailymotion\.com\/video\/([a-z0-9\-_]+)/i',
  60. 'ratio' => 4 / 3,
  61. 'control_bar_height' => 20,
  62. );
  63. $codecs['flickr_slideshows'] = array(
  64. 'name' => t('Flickr Slideshows'),
  65. 'sample_url' => 'http://www.flickr.com/photos/username/sets/1234567890/show/',
  66. 'callback' => 'video_filter_flickr_slideshows',
  67. 'regexp' => '/flickr\.com\/photos\/([a-zA-Z0-9@_\-]+)\/sets\/([0-9]+)\/?[show]?\/?/i',
  68. 'ratio' => 4 / 3,
  69. 'control_bar_height' => 0,
  70. );
  71. $codecs['flickr_video'] = array(
  72. 'name' => t('Flickr Video'),
  73. 'sample_url' => 'http://www.flickr.com/photos/hansnilsson/1234567890/',
  74. 'callback' => 'video_filter_flickr_video',
  75. 'regexp' => '/flickr\.com\/photos\/([a-zA-Z0-9@_\-]+)\/([0-9]+)/',
  76. 'ratio' => 4 / 3,
  77. 'control_bar_height' => 0,
  78. );
  79. $codecs['gametrailers'] = array(
  80. 'name' => t('Game Trailers'),
  81. 'sample_url' => 'http://www.gametrailers.com/video/some-title/12345',
  82. 'callback' => 'video_filter_gametrailers',
  83. 'regexp' => array(
  84. '/gametrailers\.com\/player\/([0-9]+)/',
  85. '/gametrailers\.com\/video\/([a-z0-9\-_]+)\/([0-9]+)/',
  86. ),
  87. 'ratio' => 16 / 9,
  88. );
  89. $codecs['gamevideos'] = array(
  90. 'name' => t('Game Videos'),
  91. 'sample_url' => 'http://gamevideos.1up.com/video/id/12345',
  92. 'callback' => 'video_filter_gamevideos',
  93. 'regexp' => '/gamevideos\.1up\.com\/video\/id\/([0-9]+)/',
  94. 'ratio' => 500 / 319,
  95. );
  96. $codecs['godtube'] = array(
  97. 'name' => t('GodTube'),
  98. 'sample_url' => 'http://www.godtube.com/watch/?v=123abc',
  99. 'callback' => 'video_filter_godtube',
  100. 'regexp' => '/godtube\.com\/watch\/\?v=([a-z0-9\-_]+)/i',
  101. 'ratio' => 400 / 283,
  102. 'control_bar_height' => 40,
  103. );
  104. $codecs['google'] = array(
  105. 'name' => t('Google Video'),
  106. 'sample_url' => 'http://video.google.com/videoplay?docid=-uN1qUeId',
  107. 'callback' => 'video_filter_google',
  108. 'regexp' => '/video\.google\.[a-z]+\.?[a-z]+?\/videoplay\?docid=(\-?[0-9]+)/',
  109. 'ratio' => 400 / 326,
  110. );
  111. $codecs['metacafe'] = array(
  112. 'name' => t('Meta Cafe'),
  113. 'sample_url' => 'http://www.metacafe.com/watch/1234567890/some_title/',
  114. 'callback' => 'video_filter_metacafe',
  115. 'regexp' => '/metacafe\.com\/watch\/([a-z0-9\-_]+)\/([a-z0-9\-_]+)/i',
  116. 'ratio' => 400 / 313,
  117. 'control_bar_height' => 32,
  118. );
  119. $codecs['myspace'] = array(
  120. 'name' => t('MySpace'),
  121. 'sample_url' => 'http://myspace.com/video/vid/1234567890',
  122. 'callback' => 'video_filter_myspace',
  123. 'regexp' => array(
  124. '/vids\.myspace\.com\/.*VideoID=([0-9]+)/i',
  125. '/myspace\.com\/video\/([a-z])+\/([0-9]+)/i',
  126. '/myspace\.com\/video\/([a-z0-9\-_]+)\/([a-z0-9\-_]+)\/([a-z0-9]+)/i',
  127. '/myspace\.com\/([a-z0-9\-_]+)\/videos\/([a-z0-9\-_]+)\/([a-z0-9]+)/i',
  128. ),
  129. 'ratio' => 620 / 400,
  130. 'control_bar_height' => 40,
  131. );
  132. $codecs['picasa_slideshows'] = array(
  133. 'name' => t('Picasa Slideshows'),
  134. 'sample_url' => 'http://picasaweb.google.com/data/feed/base/user/USER_NAME/albumid/5568104935784209834?alt=rss&amp;kind=photo&amp;hl=en_US',
  135. 'callback' => 'video_filter_picasa_slideshows',
  136. 'instructions' => t('You must use the URL of the RSS feed for the Picasa album:') .
  137. '<ol>' .
  138. '<li>' . t('View the album in Picasa (you should see thumbnails, not a slideshow).') . '</li>' .
  139. '<li>' . t('Find the "RSS" link and click it.') . '</li>' .
  140. '<li>' . t('Copy the resulting URL from the browser address bar. Example:') . '<br />' .
  141. '<code>[video: http://picasaweb.google.com/data/feed/base/user/USER_NAME/albumid/5568104935784209834?alt=rss&amp;kind=photo&amp;hl=en_US]</code>' .
  142. '</li>' .
  143. '</ol>',
  144. 'regexp' => '/picasaweb\.google\.com\/data\/feed\/base\/user\/([a-zA-Z0-9@_\-\.]+)\/albumid\/([a-z0-9]+)/i',
  145. 'ratio' => 800 / 600,
  146. );
  147. $codecs['slideshare'] = array(
  148. 'name' => t('Slideshare'),
  149. 'sample_url' => 'http://slideshare.net/1759622',
  150. 'callback' => 'video_filter_slideshare',
  151. 'instructions' => t('You need to construct your own URL, using the "Wordpress Embed" code from Slideshare, extract the "id", and form the URL like this: slideshare.net/1759622'),
  152. 'regexp' => array(
  153. '/slideshare\.net\/\?id=([a-z0-9]+)/',
  154. '/slideshare\.net\/([a-z0-9]+)/',
  155. ),
  156. 'ratio' => 425 / 355,
  157. );
  158. $codecs['streamhoster'] = array(
  159. 'name' => t('Streamhoster'),
  160. 'sample_url' => 'http://web26.streamhoster.com/username/filename.flv',
  161. 'callback' => 'video_filter_streamhoster',
  162. 'regexp' => '/([a-z0-9]+)\:\/\/([a-z0-9\-_]+)\.streamhoster\.com\/([a-z0-9\-_]+)\/([a-z0-9\-_\.]+)/i',
  163. 'ratio' => 480 / 360,
  164. );
  165. $codecs['teachertube'] = array(
  166. 'name' => t('Teachertube'),
  167. 'sample_url' => 'http://www.teachertube.com/viewVideo.php?video_id=VIDEOID',
  168. 'callback' => 'video_filter_teachertube',
  169. 'regexp' => '/teachertube\.com\/viewVideo.php\?video_id\=([0-9]+)/i',
  170. 'ratio' => 16 / 9,
  171. );
  172. $codecs['vimeo'] = array(
  173. 'name' => t('Vimeo'),
  174. 'sample_url' => 'http://www.vimeo.com/123456',
  175. 'callback' => 'video_filter_vimeo',
  176. 'html5_callback' => 'video_filter_vimeo_html5',
  177. 'regexp' => '/vimeo\.com\/([0-9]+)/',
  178. 'ratio' => 16 / 9,
  179. 'control_bar_height' => 0,
  180. );
  181. $codecs['wistia'] = array(
  182. 'name' => t('Wistia'),
  183. 'sample_url' => 'http://wistia.com/medias/9pj9n6ftlk',
  184. 'callback' => 'video_filter_wistia_html5',
  185. 'html5_callback' => 'video_filter_wistia_html5',
  186. 'regexp' => '@https?://(.+\.)?(wistia\.(com|net)|wi\.st)/((m|medias|projects)|embed/(iframe|playlists))/([a-zA-Z0-9]+)@',
  187. );
  188. $codecs['youtube'] = array(
  189. 'name' => t('YouTube'),
  190. 'sample_url' => 'http://www.youtube.com/watch?v=uN1qUeId',
  191. 'callback' => 'video_filter_youtube',
  192. 'html5_callback' => 'video_filter_youtube_html5',
  193. 'regexp' => array(
  194. '/youtube\.com\/watch\?.*?v=([a-z0-9\-_]+)/i',
  195. '/youtu.be\/([a-z0-9\-_]+)/i',
  196. '/youtube\.com\/v\/([a-z0-9\-_]+)/i',
  197. '/youtube\.com\/embed\/([a-z0-9\-_]+)/i',
  198. ),
  199. 'ratio' => 16 / 9,
  200. 'control_bar_height' => 25,
  201. );
  202. $codecs['youtube_playlist'] = array(
  203. 'name' => t('YouTube (Playlist)'),
  204. 'sample_url' => 'http://www.youtube.com/playlist?list=uN1qUeId',
  205. 'callback' => 'video_filter_youtube_playlist_html5',
  206. 'regexp' => array(
  207. '/youtube\.com\/playlist\?list=([a-z0-9\-_]+)/i',
  208. ),
  209. 'ratio' => 16 / 9,
  210. 'control_bar_height' => 25,
  211. );
  212. return $codecs;
  213. }
  214. /**
  215. * Callback for Archive.org codec.
  216. *
  217. * @see video_filter_codec_info()
  218. */
  219. function video_filter_archive($video) {
  220. $video['source'] = '//www.archive.org/embed/' . $video['codec']['matches'][1];
  221. return video_filter_iframe($video);
  222. }
  223. /**
  224. * Callback for Blip.tv codec.
  225. *
  226. * @see video_filter_codec_info()
  227. */
  228. function video_filter_bliptv($video) {
  229. $id = $video['codec']['matches'][1];
  230. // Since video ID in URL is different than in embed code, use API to lookup
  231. // the embed code video ID. Adapted from emfield.module.
  232. $result = drupal_http_request('http://blip.tv/file/' . $id . '?skin=api');
  233. if ($result->code == 200) {
  234. $parser = drupal_xml_parser_create($result->data);
  235. $vals = array();
  236. $index = array();
  237. xml_parse_into_struct($parser, $result->data, $vals, $index);
  238. xml_parser_free($parser);
  239. $response = array();
  240. // @todo: What's $arghash supposed to be? It's undefined.
  241. $response['_emfield_arghash'] = $arghash;
  242. $level = array();
  243. $start_level = 1;
  244. foreach ($vals as $xml_elem) {
  245. if ($xml_elem['type'] == 'open') {
  246. if (array_key_exists('attributes', $xml_elem)) {
  247. list($level[$xml_elem['level']], $extra) = array_values($xml_elem['attributes']);
  248. }
  249. else {
  250. $level[$xml_elem['level']] = $xml_elem['tag'];
  251. }
  252. }
  253. if ($xml_elem['type'] == 'complete') {
  254. $php_stmt = '$response';
  255. while ($start_level < $xml_elem['level']) {
  256. $php_stmt .= '[$level[' . $start_level . ']]';
  257. $start_level++;
  258. }
  259. $php_stmt .= '[$xml_elem[\'tag\']][] = $xml_elem[\'value\'];' . $php_stmt . '[$xml_elem[\'tag\']][] = $xml_elem[\'attributes\'];';
  260. eval($php_stmt);
  261. $start_level--;
  262. }
  263. }
  264. $id = $response['EMBEDLOOKUP'][0];
  265. // Protect from XSS.
  266. if (preg_match("/[^A-Za-z0-9]/", $id, $matches)) {
  267. watchdog('Video Filter', 'A faulty Blip.tv ID has been detected.');
  268. $id = 0;
  269. }
  270. }
  271. $video['source'] = '//blip.tv/play/' . $id;
  272. $params = array(
  273. 'allowscriptaccess' => 'always',
  274. );
  275. return video_filter_flash($video, $params);
  276. }
  277. /**
  278. * Callback for Candid Career codec.
  279. *
  280. * @see video_filter_codec_info()
  281. */
  282. function video_filter_candidcareer($video) {
  283. // Their urls contain & symbols which Drupal is encoding, so decode those.
  284. $decoded = decode_entities($video['codec']['matches'][0]);
  285. $video['source'] = '//' . $decoded;
  286. $video['attributes']['marginwidth'] = 0;
  287. $video['attributes']['marginheight'] = 0;
  288. return video_filter_iframe($video);
  289. }
  290. /**
  291. * Callback for Capped codec.
  292. *
  293. * @see video_filter_codec_info()
  294. */
  295. function video_filter_capped($video) {
  296. $video['source'] = '//capped.micksam7.com/playeralt.swf?vid=' . $video['codec']['matches'][1];
  297. return video_filter_flash($video);
  298. }
  299. /**
  300. * Callback for College Humor codec.
  301. *
  302. * @see video_filter_codec_info()
  303. */
  304. function video_filter_collegehumor($video) {
  305. $video['source'] = '//www.collegehumor.com/moogaloop/moogaloop.swf?clip_id=' . $video['codec']['matches'][1] . '&amp;fullscreen=1';
  306. return video_filter_flash($video);
  307. }
  308. /**
  309. * Callback for DailyMotion codec.
  310. *
  311. * @see video_filter_codec_info()
  312. */
  313. function video_filter_dailymotion($video) {
  314. $video['source'] = '//www.dailymotion.com/swf/' . $video['codec']['matches'][1];
  315. return video_filter_flash($video);
  316. }
  317. /**
  318. * Callback for Flickr Slideshows codec.
  319. *
  320. * @see video_filter_codec_info()
  321. */
  322. function video_filter_flickr_slideshows($video) {
  323. $slideshow_player_url = 'http://www.flickr.com/apps/slideshow/show.swf?v=67348';
  324. $video['source'] = $slideshow_player_url . ($video['autoplay'] ? '&amp;autoplay=1' : '');
  325. $user_name = $video['codec']['matches'][1];
  326. $set_id = $video['codec']['matches'][2];
  327. $params['flashvars'] = "&amp;offsite=true&amp;lang=en-us&amp;page_show_url=%2Fphotos%2F$user_name%2Fsets%2F$set_id%2Fshow%2F&amp;page_show_back_url=%2Fphotos%2F$user_name%2Fsets%2F$set_id%2F&amp;set_id=$set_id&amp;jump_to=";
  328. return video_filter_flash($video, $params);
  329. }
  330. /**
  331. * Callback for Flickr Video codec.
  332. *
  333. * @see video_filter_codec_info()
  334. */
  335. function video_filter_flickr_video($video) {
  336. $video['source'] = '//www.flickr.com/apps/video/stewart.swf?v=1.161';
  337. $params['flashvars'] = '&amp;photo_id=' . $video['codec']['matches'][2] . '&amp;flickr_show_info_box=true';
  338. return video_filter_flash($video, $params);
  339. }
  340. /**
  341. * Callback for Game Trailers codec.
  342. *
  343. * @see video_filter_codec_info()
  344. */
  345. function video_filter_gametrailers($video) {
  346. if (is_numeric($video['codec']['matches'][1])) {
  347. $match = $video['codec']['matches'][1];
  348. }
  349. elseif (is_numeric($video['codec']['matches'][2])) {
  350. $match = $video['codec']['matches'][2];
  351. }
  352. $video['source'] = '//media.mtvnservices.com/embed/mgid:moses:video:gametrailers.com:' . $match;
  353. return video_filter_iframe($video);
  354. }
  355. /**
  356. * Callback for Game Videos codec.
  357. *
  358. * @see video_filter_codec_info()
  359. */
  360. function video_filter_gamevideos($video) {
  361. $video['source'] = '//gamevideos.1up.com/swf/gamevideos12.swf?embedded=1&amp;fullscreen=1&amp;autoplay=0&amp;src=http://gamevideos.1up.com/do/videoListXML%3Fid%3D' . $video['codec']['matches'][1];
  362. return video_filter_flash($video);
  363. }
  364. /**
  365. * Callback for GodTube codec.
  366. *
  367. * @see video_filter_codec_info()
  368. */
  369. function video_filter_godtube($video) {
  370. $video['source'] = '//www.godtube.com/embed/watch/' . $video['codec']['matches'][1];
  371. return video_filter_iframe($video);
  372. }
  373. /**
  374. * Callback for Google Video codec.
  375. *
  376. * @see video_filter_codec_info()
  377. */
  378. function video_filter_google($video) {
  379. $video['source'] = '//video.google.com/googleplayer.swf?docId=' . $video['codec']['matches'][1];
  380. return video_filter_flash($video);
  381. }
  382. /**
  383. * Callback for Meta Cafe codec.
  384. *
  385. * @see video_filter_codec_info()
  386. */
  387. function video_filter_metacafe($video) {
  388. $video['source'] = '//metacafe.com/fplayer/' . $video['codec']['matches'][1] . '/' . $video['codec']['matches'][2] . '.swf';
  389. return video_filter_flash($video);
  390. }
  391. /**
  392. * Callback for MySpace codec.
  393. *
  394. * @see video_filter_codec_info()
  395. */
  396. function video_filter_myspace($video) {
  397. // The last match is the ID we need.
  398. $last = count($video['codec']['matches']);
  399. $video['source'] = '//mediaservices.myspace.com/services/media/embed.aspx/m=' . $video['codec']['matches'][$last - 1];
  400. return video_filter_flash($video, $params);
  401. }
  402. /**
  403. * Callback for Picasa Slideshows codec.
  404. *
  405. * @see video_filter_codec_info()
  406. */
  407. function video_filter_picasa_slideshows($video) {
  408. $video['source'] = '//picasaweb.google.com/s/c/bin/slideshow.swf';
  409. $user_name = $video['codec']['matches'][1];
  410. $set_id = $video['codec']['matches'][2];
  411. $params['flashvars'] = "host=picasaweb.google.com&amp;&amp;feat=flashalbum&amp;RGB=0x000000&amp;feed=http%3A%2F%2Fpicasaweb.google.com%2Fdata%2Ffeed%2Fapi%2Fuser%2F" . $user_name . "%2Falbumid%2F" . $set_id . "%3Falt%3Drss%26kind%3Dphoto%26" . ($video['autoplay'] ? '' : '&amp;noautoplay=1');
  412. return video_filter_flash($video, $params);
  413. }
  414. /**
  415. * Callback for Slideshare codec.
  416. *
  417. * @see video_filter_codec_info()
  418. */
  419. function video_filter_slideshare($video) {
  420. $video['source'] = '//www.slideshare.net/slideshow/embed_code/' . $video['codec']['matches'][1];
  421. return video_filter_iframe($video);
  422. }
  423. /**
  424. * Callback for Streamhoster codec.
  425. *
  426. * @see video_filter_codec_info()
  427. */
  428. function video_filter_streamhoster($video) {
  429. $video['source'] = '//public.streamhoster.com/Resources/Flash/JWFLVMediaPlayer/mediaplayer.swf';
  430. $params = array('allowscriptaccess' => 'always');
  431. $protocol = $video['codec']['matches'][1];
  432. if ($protocol == 'rtmp') {
  433. $params['flashvars'] = 'file=' . urlencode('/' . $video['codec']['matches'][4]);
  434. $params['flashvars'] .= '&amp;streamer=' . urlencode('rtmp://' . $video['codec']['matches'][2] . '.streamhoster.com/' . $video['codec']['matches'][3]);
  435. $params['flashvars'] .= '&amp;type=rtmp';
  436. }
  437. elseif ($protocol == 'http') {
  438. $params['flashvars'] = 'file=' . urlencode('http://' . $video['codec']['matches'][2] . '.streamhoster.com/' . $video['codec']['matches'][3] . '/' . $video['codec']['matches'][4]);
  439. $params['flashvars'] .= '&amp;type=video';
  440. }
  441. $params['flashvars'] .= '&amp;width=' . $video['width'];
  442. $params['flashvars'] .= '&amp;height=' . $video['height'];
  443. $params['flashvars'] .= !empty($video['autoplay']) ? '&amp;autostart=true' : '&amp;autostart=false';
  444. return video_filter_flash($video, $params);
  445. }
  446. /**
  447. * Callback for Teachertube codec.
  448. *
  449. * @see video_filter_codec_info()
  450. */
  451. function video_filter_teachertube($video) {
  452. $video['source'] = '//www.teachertube.com/embed/player.swf';
  453. $params['flashvars'] = 'file=http://www.teachertube.com/embedFLV.php?pg=video_' . $video['codec']['matches'][1] . '&amp;menu=false&amp;frontcolor=ffffff&amp;lightcolor=FF0000&amp;logo=http://www.teachertube.com/www3/images/greylogo.swf&amp;skin=http://www.teachertube.com/embed/overlay.swf&amp;volume=80&amp;controlbar=over&amp;displayclick=link&amp;viral.link=http://www.teachertube.com/viewVideo.php?video_id=' . $video['codec']['matches'][1] . '&amp;stretching=exactfit&amp;plugins=viral-2&amp;viral.callout=none&amp;viral.onpause=false';
  454. return video_filter_flash($video, $params);
  455. }
  456. /**
  457. * Callback for Vimeo codec.
  458. *
  459. * @see video_filter_codec_info()
  460. */
  461. function video_filter_vimeo($video) {
  462. $video['source'] = '//www.vimeo.com/moogaloop.swf?clip_id=' . $video['codec']['matches'][1] . '&amp;server=www.vimeo.com&amp;fullscreen=1&amp;show_title=1&amp;show_byline=1&amp;show_portrait=0&amp;color=&amp;autoplay=' . $video['autoplay'];
  463. return video_filter_flash($video);
  464. }
  465. /**
  466. * HTML5 callback for Vimeo codec.
  467. *
  468. * @see video_filter_codec_info()
  469. */
  470. function video_filter_vimeo_html5($video) {
  471. $video['source'] = '//player.vimeo.com/video/' . $video['codec']['matches'][1] . ($video['autoplay'] ? '?autoplay=1' : '');
  472. return video_filter_iframe($video);
  473. }
  474. /**
  475. * Callback for YouTube codec.
  476. *
  477. * @see video_filter_codec_info()
  478. */
  479. function video_filter_youtube($video) {
  480. $attributes = array(
  481. 'rel' => $video['related'] ? 'rel=1' : 'rel=0',
  482. 'autoplay' => $video['autoplay'] ? 'autoplay=1' : 'autoplay=0',
  483. 'fs' => 'fs=1',
  484. );
  485. $video['source'] = '//www.youtube.com/v/' . $video['codec']['matches'][1] . '?' . implode('&amp;', $attributes);
  486. $params['wmode'] = 'opaque';
  487. return video_filter_flash($video, $params);
  488. }
  489. /**
  490. * HTML5 callback for YouTube codec.
  491. *
  492. * @see video_filter_codec_info()
  493. */
  494. function video_filter_youtube_html5($video) {
  495. $attributes = array(
  496. 'html5' => 'html5=1',
  497. 'rel' => $video['related'] ? 'rel=1' : 'rel=0',
  498. 'autoplay' => $video['autoplay'] ? 'autoplay=1' : 'autoplay=0',
  499. 'wmode' => 'wmode=opaque',
  500. );
  501. $video['source'] = '//www.youtube.com/embed/' . $video['codec']['matches'][1] . '?' . implode('&amp;', $attributes);
  502. return video_filter_iframe($video);
  503. }
  504. /**
  505. * HTML5 callback for YouTube (Playlist) codec.
  506. *
  507. * @see video_filter_codec_info()
  508. */
  509. function video_filter_youtube_playlist_html5($video) {
  510. $attributes = array(
  511. 'rel' => $video['related'] ? 'rel=1' : 'rel=0',
  512. 'autoplay' => $video['autoplay'] ? 'autoplay=1' : 'autoplay=0',
  513. 'wmode' => 'wmode=opaque',
  514. );
  515. $video['source'] = '//www.youtube.com/embed/videoseries?list=' . $video['codec']['matches'][1] . '&amp;' . implode('&amp;', $attributes);
  516. return video_filter_iframe($video);
  517. }
  518. /**
  519. * Callback for Wistia codec.
  520. *
  521. * Adapted from the media_wistia module.
  522. *
  523. * @see video_filter_codec_info()
  524. */
  525. function video_filter_wistia_html5($video) {
  526. $video_code = $video['codec']['matches'][7];
  527. $matches = $video['codec']['matches'];
  528. $embed_type = ($matches[4] == 'projects' || $matches[6] == 'playlists') ? 'playlists' : 'iframe';
  529. // Get embed code via oEmbed.
  530. $endpoint = 'http://fast.wistia.com/oembed';
  531. $options = array(
  532. 'url' => "http://fast.wistia.com/embed/{$embed_type}/{$video_code}",
  533. 'width' => $video['width'],
  534. 'height' => $video['height'],
  535. );
  536. $data = video_filter_oembed_request($endpoint, $options);
  537. $html = $data['html'];
  538. // See if the video source is already an iframe src.
  539. $pattern = '@https?://fast.wistia.(com|net)/embed/(iframe|playlists)/[a-zA-Z0-9]+\?+.+@';
  540. $matches = array();
  541. if (preg_match($pattern, $video['source'], $matches)) {
  542. // Replace the oEmbed iframe src with that provided in the token, in order
  543. // to support embed builder URLs.
  544. $pattern = '@https?://fast.wistia.(com|net)/embed/(iframe|playlists)/[a-zA-Z0-9]+\?[^"]+@';
  545. $replacement = $matches[0];
  546. $html = preg_replace($pattern, $replacement, $html);
  547. }
  548. return $html;
  549. }