[44] | 1 | <?php
|
---|
| 2 | /**
|
---|
| 3 | * Copyright 2006, 2007, 2008, 2009 Eric D. Hough (http://ehough.com)
|
---|
| 4 | *
|
---|
| 5 | * This file is part of TubePress (http://tubepress.org)
|
---|
| 6 | *
|
---|
| 7 | * TubePress is free software: you can redistribute it and/or modify
|
---|
| 8 | * it under the terms of the GNU General Public License as published by
|
---|
| 9 | * the Free Software Foundation, either version 3 of the License, or
|
---|
| 10 | * (at your option) any later version.
|
---|
| 11 | *
|
---|
| 12 | * TubePress is distributed in the hope that it will be useful,
|
---|
| 13 | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 14 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 15 | * GNU General Public License for more details.
|
---|
| 16 | *
|
---|
| 17 | * You should have received a copy of the GNU General Public License
|
---|
| 18 | * along with TubePress. If not, see <http://www.gnu.org/licenses/>.
|
---|
| 19 | *
|
---|
| 20 | */
|
---|
| 21 |
|
---|
| 22 | function_exists('tubepress_load_classes')
|
---|
| 23 | || require(dirname(__FILE__) . '/../../../../tubepress_classloader.php');
|
---|
| 24 | tubepress_load_classes(array('net_php_pear_HTML_Template_IT',
|
---|
| 25 | 'org_tubepress_embedded_impl_AbstractEmbeddedPlayerService',
|
---|
| 26 | 'net_php_pear_Net_URL2',
|
---|
| 27 | 'org_tubepress_options_category_Embedded'));
|
---|
| 28 |
|
---|
| 29 | /**
|
---|
| 30 | * Represents an HTML-embeddable YouTube player
|
---|
| 31 | *
|
---|
| 32 | */
|
---|
| 33 | class org_tubepress_embedded_impl_YouTubeEmbeddedPlayerService extends org_tubepress_embedded_impl_AbstractEmbeddedPlayerService
|
---|
| 34 | {
|
---|
| 35 | /**
|
---|
| 36 | * Spits back the text for this embedded player
|
---|
| 37 | *
|
---|
| 38 | * @return string The text for this embedded player
|
---|
| 39 | */
|
---|
| 40 | public function toString($videoId)
|
---|
| 41 | {
|
---|
| 42 | $tpl = new net_php_pear_HTML_Template_IT(dirname(__FILE__) . "/../../../../../ui/embedded/youtube/html_templates");
|
---|
| 43 | if (!$tpl->loadTemplatefile("object.tpl.html", true, true)) {
|
---|
| 44 | throw new Exception("Couldn't load embedded template");
|
---|
| 45 | }
|
---|
| 46 |
|
---|
| 47 | $link = new net_php_pear_Net_URL2(sprintf("http://www.youtube.com/v/%s", $videoId));
|
---|
| 48 |
|
---|
| 49 | $tpom = $this->getOptionsManager();
|
---|
| 50 |
|
---|
| 51 | $color1 = $this->_safeColorValue($tpom->get(org_tubepress_options_category_Embedded::PLAYER_COLOR), "999999");
|
---|
| 52 | $color2 = $this->_safeColorValue($tpom->get(org_tubepress_options_category_Embedded::PLAYER_HIGHLIGHT), "FFFFFF");
|
---|
| 53 | $showRelated = $tpom->get(org_tubepress_options_category_Embedded::SHOW_RELATED);
|
---|
| 54 | $autoPlay = $tpom->get(org_tubepress_options_category_Embedded::AUTOPLAY);
|
---|
| 55 | $loop = $tpom->get(org_tubepress_options_category_Embedded::LOOP);
|
---|
| 56 | $genie = $tpom->get(org_tubepress_options_category_Embedded::GENIE);
|
---|
| 57 | $border = $tpom->get(org_tubepress_options_category_Embedded::BORDER);
|
---|
| 58 | $width = $tpom->get(org_tubepress_options_category_Embedded::EMBEDDED_WIDTH);
|
---|
| 59 | $height = $tpom->get(org_tubepress_options_category_Embedded::EMBEDDED_HEIGHT);
|
---|
| 60 | $quality = $tpom->get(org_tubepress_options_category_Embedded::QUALITY);
|
---|
| 61 | $fullscreen = $tpom->get(org_tubepress_options_category_Embedded::FULLSCREEN);
|
---|
| 62 | $showInfo = $tpom->get(org_tubepress_options_category_Embedded::SHOW_INFO);
|
---|
| 63 |
|
---|
| 64 | if (!($color1 == "999999" && $color2 == "FFFFFF")) {
|
---|
| 65 | $link->setQueryVariable("color2", "0x" . $color1);
|
---|
| 66 | $link->setQueryVariable("color1", "0x" . $color2);
|
---|
| 67 | }
|
---|
| 68 | $link->setQueryVariable("rel", $showRelated ? "1" : "0");
|
---|
| 69 | $link->setQueryVariable("autoplay", $autoPlay ? "1" : "0");
|
---|
| 70 | $link->setQueryVariable("loop", $loop ? "1" : "0");
|
---|
| 71 | $link->setQueryVariable("egm", $genie ? "1" : "0");
|
---|
| 72 | $link->setQueryVariable("border", $border ? "1" : "0");
|
---|
| 73 | $link->setQueryVariable("fs", $fullscreen ? "1" : "0");
|
---|
| 74 |
|
---|
| 75 | $link->setQueryVariable("showinfo", $showInfo ? "1" : "0");
|
---|
| 76 |
|
---|
| 77 | switch ($quality) {
|
---|
| 78 | case "high":
|
---|
| 79 | $link->setQueryVariable("ap", "%26");
|
---|
| 80 | $link->setQueryVariable("fmt", "6");
|
---|
| 81 | break;
|
---|
| 82 | case "higher":
|
---|
| 83 | $link->setQueryVariable("ap", "%26");
|
---|
| 84 | $link->setQueryVariable("fmt", "18");
|
---|
| 85 | break;
|
---|
| 86 | case "highest":
|
---|
| 87 | $link->setQueryVariable("ap", "%26");
|
---|
| 88 | $link->setQueryVariable("fmt", "22");
|
---|
| 89 | break;
|
---|
| 90 | }
|
---|
| 91 |
|
---|
| 92 | $link = $link->getURL(true);
|
---|
| 93 |
|
---|
| 94 | $tpl->setVariable('URL', $link);
|
---|
| 95 | $tpl->setVariable('WIDTH', $width);
|
---|
| 96 | $tpl->setVariable('HEIGHT', $height);
|
---|
| 97 | $tpl->setVariable('FULLSCREEN', $fullscreen ? "true" : "false");
|
---|
| 98 |
|
---|
| 99 | $embedSrc = $tpl->get();
|
---|
| 100 |
|
---|
| 101 | return str_replace("?", "&", $embedSrc);
|
---|
| 102 | }
|
---|
| 103 | } |
---|