Switching Between Flowplayer And Youtube video player

In my current project, I had to play videos on a page. The decision was to play those videos on Flowplayer. The issue was that few videos were hosted on youtube. And I think YouTube does not permit to play youtube videos directly with another player. So the only solution was to have two players [ youtube and flowplayer in this case] and switch between them.

UPDATE: You can see this live here

Requirement: I had few thumbnails [ video snapshots ]  in a gallery which when clicked should load the respective video.

I did the following to get the result.

<div id="video-wrap">

   <div id="video"> </div>


Created an empty div with id ‘video’ for the player.

  // fgdata --> XML DOM Object

  $('gallery > item', fgData).each(function(){

     var thumbUrl = $('>thumbnail', $(this)).text();

     var videoType = $('>videotype',$(this)).text();

     var videoUrl = $('>videoUrl', $(this)).text()

     // creating thumbnail elements for the gallery

     $('#gallery ul').append('<li>'

       + '<img src="'+ thumbUrl +'" alt=""/>'

       + '<p id="videotype_'+ i +'">'+ videoType +'</p>'

       + '<p id="video_'+ i +'">'+ videoUrl+'</p>'

       + '</li>');


I parse a XML document for the video urls and the thumbnail urls and I get the video type too .

  $('#gallery ul li').children('img:eq(0)').bind('click', function(){

      switchVideos(videoType, videoUrl);

Each thumbnail image is attached a click event.

  var flowplayerobj= null;
  function switchVideos(vType, vUrl){

     // Unload the flowplayer before deleting the element

        if(flowplayerobj != null)

     // removing the element
        $('#video').text(' ');
     // Creating the element [ #video ] again after removng it.

        $('#video-wrap').append('<div id="video"></div>');

     var vType = vType;

     var vUrl = vUrl;



         $('video').append('<object width="506" height="335"><param name="wmode" value="transparent"></param><param name="movie" value="'+ vUrl +'"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="'+ vUrl +'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" wmode="transparent" width="506" height="335"></embed></object>');







Every time I remove the div containing the video player since I would be switching the players according to the video type.

Note:  If the element contains the flowplayer, it can’t be removed directly. One needs to unload the flowplayer first and then remove the element.

If the video type [vType] is youtube, I embed the youtube player. If not I insert the flowplayer.

  function insertFlowPlayer(url){

    var vUrl = url;

    flowplayerobj = $f("video", {src: '/flash/flowplayer-3.1.5.swf', wmode: 'transparent'}, {

                  // change the default controlbar to tube
                  plugins: {
                             controls: {
                                          url: '/flash/flowplayer.controls-tube-3.1.5.swf',
                                          borderRadius: '0px',
                                          bufferGradient: 'none',
                                          sliderColor: '#c9c9c9',
                                          timeBgColor: '#d5d5d5',
                                          volumeSliderGradient: 'none',
                                          tooltipTextColor: '#000',
                                          buttonOverColor: '#BA1010',
                                          volumeSliderColor: '#aaaaaa',
                                          progressGradient: 'medium',
                                          progressColor: '#BA1010',
                                          bufferColor: '#c78f8e',
                                          backgroundColor: '#e1e1e1',
                                          timeColor: '#000',
                                          sliderGradient: 'none',
                                          buttonColor: '#000',
                                          durationColor: '#000',
                                          tooltipColor: '#d5d5d5',
                                          height: 25,
                                          opacity: 1.0
                  playlist: [
                                  url: imgSrc, //screenshot url onload of the player
                                  scaling: 'fit'
                                  url: vUrl,
                                  autoPlay: false
                                  backgroundColor: '#ffffff'


I have customized the flowplayer so that it looks similar to youtube player when switched.


Dojo InlineEditBox

Tried a hand at dojo InlineEditBox tday. Worked fine 🙂

 <form dojoType="dijit.form.Form" >  
		<span>Name :</span>
		<span id="editname" dojoType="dijit.InlineEditBox" editor="dijit.form.ValidationTextBox"
		   autoSave="false" title="change your name" editorParams="{trim:'true',name:'first_name',required:'true',invalidMessage:'Invalid name (max:25 chars)',maxLength:'25',regExp:'&#91;a-zA-Z&#93;{1,25}'}">
		       <?php echo $this->user_profile['name'] ?>
		<span>City :</span>
		<span id="editcity" dojoType="dijit.InlineEditBox" editor="dijit.form.ValidationTextBox"
		   autoSave="false" title="change your city" editorParams="{trim:'true',name:'city',required:'true',invalidMessage:'Invalid city',regExp:'&#91;a-zA-Z\\s&#93;{1,20}',maxLength:'20'}">
		       <?php echo $this->user_profile['city'] ?>
		<span>State :</span>
		<span id="editstate" dojoType="dijit.InlineEditBox" editor="dijit.form.ValidationTextBox"
		    autoSave="false" title="change your state" editorParams="{trim:'true',name:'state',required:'true',invalidMessage:'Invalid state',maxLength:'20',regExp:'&#91;sa-zA-Z\\s&#93;{1,20}'}">
		       <?php echo $this->user_profile['state'] ?>
	   <span style="display:none" dojoType="dojo.data.ItemFileReadStore" jsId="countryStore" url="<?php echo $this->baseUrl(); ?>/js/countries.json"></span>
		<span id="editcountry" dojoType="dijit.InlineEditBox" editor="dijit.form.FilteringSelect"
		   editorParams="{searchAttr: 'name', keyAttr: 'abbr', store: countryStore, autocomplete: true, hasDownArrow: false,name:'country',invalidMessage:'Invalid Country',regExp:'&#91;a-zA-Z&#93;{1,25}'}"
		    width="200px" autoSave="false"> <?php echo $this->user_profile['country'] ?>
		<span>Zip :</span>
		<span id="editzip" dojoType="dijit.InlineEditBox" editor="dijit.form.ValidationTextBox"
		   autoSave="false" title="change your zip code" editorParams="{trim:'true',name:'zip',required:'true',invalidMessage:'Invalid Zip',maxLength:'10',regExp:'&#91;0-9&#93;{1,10}'}">
		       <?php echo $this->user_profile['zip'] ?>
		<span>About Me :</span>
		<span id="editaboutme" dojoType="dijit.InlineEditBox" autoSave="true" editor="dijit.form.Textarea" editorParams="{trim:'true',name:'about_me'}">
		  <?php echo $this->user_profile['about_me'] ?>
	       <span>Confirm changes :</span>
	       <span><button dojoType="dijit.form.Button" type="button" onclick="saveProfile()">Ok</button></span>

I hav hid the save and cancel button that comes on every edit box, through css.

.classname fieldset span div button{display:none }

As i wanted all values submitted through one button than individually submitting it.

Carousel using Dojo

For a project i had to make a carousel and i was using Dojo throughout my project. After about two weeks, i hav made one.

Sorry folks! The site is down for maintenance so i cant post the url here.

The URL that I gave below in one of my comments is now broken. It seems dojo has updated their dojo 1.4.0 to 1.4.3.

Go to this link : http://download.dojotoolkit.org

Choose the the latest release

Then go to  dojox/widget/ and find pager widget.

Final Output :

carousel using dojo

Here is da code :

html code :

<div id="carouselwrap">
<div id="carouselprev" class="traversecontrol"><img src="/img/blank.gif"/></div>
<!--image of the previous arrow-->
<div id="carousel"><!--start of the carousel-->
<div id="carouselscroll" ><!--start of the carouselscroll-->
<div class="carouselscrollbox"><!--start of the carouselscrollbox block-->
<div class="carouselscrollerimg">
           <img src="Your image here" /><!--this div contains the image path --></div>
<div class="soundsettitle bmrm_text">
            Lorem Ipsum</div>
<div class="artisttitle bmrm_text">
            Lorem Ipsum</div>
<div class="soundsetdesc bmrm_text">
           - Lorem ipsum dolor sit amet, consectetuer adipiscing elit.</div>
</em><em><em><!--end of the carouselscrollbox block--></em></em></div>
<div id="carouselnext" class="traversecontrol"><img src="/img/blank.gif"/></div>
<!--image of the next arrow--></div>
<!--repeat the div block wid class 'carouselscrollbox'(in a for loop) as many times to get as many records in da carousel.-->

Javascript code: First step : dojo.require("dojo.fx");

var animationMethod = "chain";
var animG, offsetW, offsetH = null;
var newLeft = 0;
var boxMixin = {duration: 1000};
var carouselscroller ;

//attach events on load
dojo.addOnLoad(function() {
       var prev = dojo.byId('carouselprev');
       var next = dojo.byId('carouselnext');
       carouselscroller = dojo.byId('carouselscroll');

//sliding to the right
function slideRight() {
       var difference = dojo.byId('carousel').offsetWidth-dojo.byId('carouselscroll').offsetWidth;
           newLeft = newLeft - 200;
           var style = carouselscroller.style;
	   var anim1 = dojo.animateProperty({
	   node: carouselscroller,
	   duration: boxMixin.duration/2,
	   properties: {
		left: { end: newLeft, unit:"px" }

	animG = dojo.fx[animationMethod]([anim1]).play();


//sliding to the left
function slideLeft() {
   	    newLeft = newLeft + 200;
	    var style = carouselscroller.style;
	    var anim1 = dojo.animateProperty({
	    node: carouselscroller,
	    duration: boxMixin.duration/2,
	    properties: {
		//width: { /* start: boxMixin.startWidth, */ end: boxMixin.endWidth, unit:"px" },
		left: { end: newLeft, unit:"px" }

   animG = dojo.fx[animationMethod]([anim1]).play();

CSS Code:

/*soundsets traversal [carousel]*/
#carouselwrap{width:700px;margin:35px 0px}
width: 600px;
height: 230px;
overflow: hidden;
width:2000px !important;
#carouselprev{background:url('/*image left arrow*/') no-repeat;}
#carouselnext{background:url('/*image right arrow*/') no-repeat;}
.traversecontrol{float:left;width:40px;height:45px;margin:70px 0px}
	border:1px solid #eee;

.carouselscrollerimg img{width:140px;height:80px;margin:3px 1px }

U can change the css accordingly.This is just my way of doing it.