{"id":1748,"date":"2009-01-17T17:49:46","date_gmt":"2009-01-18T01:49:46","guid":{"rendered":"http:\/\/www.krunk4ever.com\/blog\/?p=1748"},"modified":"2009-01-20T11:29:16","modified_gmt":"2009-01-20T19:29:16","slug":"updated-gallery2-to-use-jw-flv-media-player","status":"publish","type":"post","link":"https:\/\/www.krunk4ever.com\/blog\/2009\/01\/17\/updated-gallery2-to-use-jw-flv-media-player\/","title":{"rendered":"Updated Gallery2 to Use JW FLV Media Player"},"content":{"rendered":"<p>So this little exercise started with the fact I was introduced to the <a href=\"http:\/\/www.longtailvideo.com\/players\/jw-flv-player\/\"><strong>JW FLV Media Player<\/strong><\/a> a few weeks back. Today, I wanted to share an flash video and thought it would be a good time to hack Gallery2 to use this flv video player.<\/p>\n<p>If you&#8217;ve seen flash videos in my <a href=\"http:\/\/gallery.krunk4ever.com\/\">Gallery<\/a> before, you&#8217;ve noticed it was using the default G2flv (Gallery2 Flash Video) player:<\/p>\n<p><img decoding=\"async\" loading=\"lazy\" src=\"http:\/\/gallery.krunk4ever.com\/d\/18388-2\/g2flv-player.png\" alt=\"G2flv Player\" width=\"512\" height=\"274\" \/><\/p>\n<p>One of the things I disliked about it was that it didn&#8217;t have a full screen mode, and it&#8217;s double-size feature behaved differently in IE and Firefox.<\/p>\n<p>So I downloaded the latest version of JW FLV Media Player (currently at 4.3) and uploaded into the libs folder: \/modules\/flashvideo\/lib<\/p>\n<p>Then I had to modify modules\/flashvideo\/classes\/FlashVideoRenderer.class to tell it to use the new flv player. I would highly recommend you back up that file before you modify it. Here&#8217;s a copy of what my resulting FlashVideoRenderer.class looks like: <a href=\"http:\/\/gallery.krunk4ever.com\/modules\/flashvideo\/classes\/FlashVideoRenderer.class\">FlashVideoRenderer.class using JW FLV Media Player<\/a>.<\/p>\n<p>I&#8217;ll explain the changes I made.<\/p>\n<p>I disabled <em>forceSessionId<\/em> as the url generated wasn&#8217;t like by the script. I&#8217;m guessing it did not like the &#8216;?&#8217;. I also added a pointer to the new .js file and updated the playerUrl.<\/p>\n<p><code>$urlGenerator =& $gallery->getUrlGenerator();<br \/>\n$src = $urlGenerator->generateUrl(<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; array(&#39;view&#39; => &#39;core.DownloadItem&#39;,<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#39;itemId&#39; => $entity->getId(),<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#39;serialNumber&#39; => $entity->getSerialNumber()),<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; array(&#39;forceFullUrl&#39; => true,&#39;forceSessionId&#39; => <strong>false<\/strong>,<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &#39;htmlEntities&#39; => false));<br \/>\nlist ($width, $height, $title) =<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; array($entity->getWidth(), $entity->getHeight(),<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; $item->getTitle());<br \/>\nGalleryCoreApi::requireOnce(<br \/>\n&nbsp; &nbsp; &#39;lib\/smarty_plugins\/modifier.markup.php&#39;);<br \/>\n$title = smarty_modifier_markup($title, &#39;strip&#39;);<br \/>\n&nbsp;<br \/>\n\/* Default player: G2flv.swf *\/<br \/>\n<strong>$swfObjectUrl = $urlGenerator->generateUrl(<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; array(&#39;href&#39; => &#39;modules\/flashvideo\/lib\/swfobject.js&#39;),<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; array(&#39;forceFullUrl&#39; => true));<\/strong><br \/>\n$playerUrl = $urlGenerator->generateUrl(<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; array(&#39;href&#39; => &#39;modules\/flashvideo\/lib\/<strong>player.swf<\/strong>&#39;),<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; array(&#39;forceFullUrl&#39; => true));<br \/>\n$flashVars = &#39;flvUrl=&#39; . urlencode($src) . &#39;&amp;amp;Width=&#39; . $width .<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  &#39;&amp;amp;Height=&#39; . $height . &#39;&amp;amp;title=&#39; .<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;  urlencode($title);<br \/>\n$extraAttr = &#39;&#39;;<\/code><\/p>\n<p>This remaining was basically following the instructions on JW FLV Media Player on how to use their code. I also added another paragraph where I would put the fallback code (e.g. <em>Download Movie<\/em>). If you prefer that to only show up when the item could not load, I would suggest putting the %s in the paragraph above.<\/p>\n<p><code>return sprintf(<br \/>\n&nbsp; &nbsp; &#39;&lt;div id=&#34;flashvideo&#34;&gt;<br \/>\n&nbsp;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &lt;p id=&#34;%s&#34; %s%s&gt;&lt;\/p&gt;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &lt;p id=&#34;fallback&#34;&gt;%s&lt;\/p&gt;<br \/>\n&nbsp;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &lt;script type=&#34;text\/javascript&#34; src=&#34;%s&#34;&gt;&lt;\/script&gt;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &lt;script type=&#34;text\/javascript&#34;&gt;<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; var s1 = new SWFObject(&#34;%s&#34;,&#34;player&#34;,&#34;%s&#34;,&#34;%s&#34;,&#34;9&#34;);<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; s1.addParam(&#34;allowfullscreen&#34;,&#34;true&#34;);<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; s1.addParam(&#34;allowscriptaccess&#34;,&#34;always&#34;);<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; s1.addParam(&#34;flashvars&#34;,&#34;file=%s&#34;);<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; s1.write(&#34;%s&#34;);<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &lt;\/script&gt;<br \/>\n&nbsp;<br \/>\n&nbsp; &nbsp; &lt;\/div&gt;&#39;,<br \/>\n&nbsp;<br \/>\n&nbsp; &nbsp; !empty($params[&#39;id&#39;]) ? $params[&#39;id&#39;] : &#39;movie&#39;,<br \/>\n&nbsp; &nbsp; !empty($params[&#39;class&#39;]) ?<br \/>\n&nbsp; &nbsp; &nbsp; &nbsp; &#39; class=&#34;&#39; . $params[&#39;class&#39;] . &#39;&#34;&#39; : &#39;&#39;, $extraAttr,<br \/>\n&nbsp; &nbsp; $fallback, $swfObjectUrl, $playerUrl, $width,<br \/>\n&nbsp; &nbsp; $height, $src,<br \/>\n&nbsp; &nbsp; !empty($params[&#39;id&#39;]) ? $params[&#39;id&#39;] : &#39;movie&#39;);<\/code><\/p>\n<p>I&#8217;ll probably update my Gallery2 mp3 audio player to use this new player some time in the future.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>So this little exercise started with the fact I was introduced to the JW FLV Media Player a few weeks back. Today, I wanted to share an flash video and thought it would be a good time to hack Gallery2 to use this flv video player. If you&#8217;ve seen flash videos in my Gallery before, &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/www.krunk4ever.com\/blog\/2009\/01\/17\/updated-gallery2-to-use-jw-flv-media-player\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Updated Gallery2 to Use JW FLV Media Player&#8221;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[11],"tags":[1000,999,1002,286,1001],"_links":{"self":[{"href":"https:\/\/www.krunk4ever.com\/blog\/wp-json\/wp\/v2\/posts\/1748"}],"collection":[{"href":"https:\/\/www.krunk4ever.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.krunk4ever.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.krunk4ever.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.krunk4ever.com\/blog\/wp-json\/wp\/v2\/comments?post=1748"}],"version-history":[{"count":0,"href":"https:\/\/www.krunk4ever.com\/blog\/wp-json\/wp\/v2\/posts\/1748\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.krunk4ever.com\/blog\/wp-json\/wp\/v2\/media?parent=1748"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.krunk4ever.com\/blog\/wp-json\/wp\/v2\/categories?post=1748"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.krunk4ever.com\/blog\/wp-json\/wp\/v2\/tags?post=1748"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}