Archive

Archive for January, 2012

How to bring Administration Menu on the top of the page in Drupal

1. Enable Toolbar in admin/modules and click Save Configuration

Advertisements
Categories: Drupal

Include Windows Media Player in HTML – Firefox

1. Download wmpfirefoxplugin.exe from online.
you can download it from http://www.mediafire.com/?idnw2nkt2em also.

2. Save and run the file.

3. Detect the browser accordingly and we can add the <object> tag.

<SCRIPT type=”text/javascript”>if(-1 != navigator.userAgent.indexOf(“MSIE”))   // internet explorer version

{

document.write(‘<OBJECT id=”Player”‘);

document.write(‘ classid=”clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6″‘);

document.write(‘ width=400 height=300> <param name=”playCount” value=”1″> <PARAM name=”URL” value=”helicopter.mpg”></OBJECT>’);

}

else if(-1 != navigator.userAgent.indexOf(“Firefox”))  // firefox version

{

document.write(‘<OBJECT id=”Player”‘);

document.write(‘ type=”application/x-ms-wmp”‘);

document.write(‘ width=400 height=300> <param name=”playCount” value=”1″> <PARAM name=”URL” value=”helicopter.mpg”></OBJECT>’);

}

</SCRIPT>

4. Instead of adding thru Javascript we can add in Html also as,

<object id=”Player” type=”application/x-ms-wmp” height=”590px” width=”1045px” style=”padding-top:13px;”><param value=”videos/AL_JANBUS.mp4″ name=”url”>

<param name=”playCount” value=”1″>

<param name=”uiMode” value=”none”>

<!–If we need controls enable this–>

<!–<param name=”uiMode” value=”full”>–>

</object>

5. The entire code is given below,

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
  <TITLE>video tracking of windows embedded mediaplayer play pause events</TITLE>

<script type="text/javascript">

function submit_action(action) 
{
         YWATracker = YWA.getTracker(project_PID);
         YWATracker.setAction('' + action);
         YWATracker.submit_action();
}

</script>
</head>

<body>

<SCRIPT type="text/javascript">
      if(-1 != navigator.userAgent.indexOf("MSIE"))
      {
        document.write('<OBJECT id="Player"');
        document.write(' classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6"');
        document.write(' width=400 height=300> <param name="playCount" value="1"> <PARAM name="URL" value="helicopter.mpg"></OBJECT>');
      }
      else if(-1 != navigator.userAgent.indexOf("Firefox"))
      {

        document.write('<OBJECT id="Player"');
        document.write(' type="application/x-ms-wmp"');
        document.write(' width=400 height=300> <param name="playCount" value="1"> <PARAM name="URL" value="helicopter.mpg"></OBJECT>');
      }    
</SCRIPT>
<BR>

<!--example holders for player status information -->
<P id="p1">...</P>
<P id="p2">...</P>
<P id="p3">...</P>

<script type="text/javascript" src="http://d.yimg.com/mi/ywa.js"></script>
<script type="text/javascript">

video_duration = Player.currentMedia.duration;
p3.innerHTML = video_duration;

/*globals YWA, YWATracker */
//set project PID of target project - avaialble from installation section of UI
project_PID="1000123456789";

YWATracker = YWA.getTracker(project_PID);
YWATracker.setDocumentName('Video_page');
YWATracker.setDocumentGroup('Video_group');
YWATracker.submit();

</script>
<noscript>
<div><img src="http://stats.indextools.com/p.pl?a=1000xyz1332777957&js=no" width="1" height="1" alt="" /></div>
</noscript>
<!-- End of IndexTools  Code  -->

<script type="text/javascript">
function OnDSPlayStateChangeEvt(NewState){

// this section deals with video play stop pause etc events 

    p1.innerHTML = "Play state: " + NewState;
         video_duration = Player.currentMedia.duration;
         p3.innerHTML = video_duration;

         switch (NewState){
                 case 1: // Stopped
                          submit_action(6);
                 break;

                 case 2: // Paused
                          video_paused_position=0;
                          video_paused_position=Player.controls.currentPosition;
                          video_paused_position = parseInt(video_paused_position);  // just have whole seconds = so convert to int
                          //otionall add code to send paused position as a Custom Field
                          submit_action(7);
                 break;

                 case 3: // Playing
                          submit_action(8);
                          break;
                 case 4: // FastScanForward
                          submit_action(9);
                          break;
                 case 5: // FastScanRewind
                          submit_action(10);
                          break;
                 case 6: // Buffering
                          submit_action(11);
                          break;
                 case 7: // Waiting
                          submit_action(12);
                          break;
                 case 8: // Media Ended
                          submit_action(35);
                          break;
                 case 9: // Transitioning
                          submit_action(13)
                          break;
                 case 10: // Ready
                          submit_action(14);
                          break;
         }
}
</script>

<script type="text/javascript">
function OnDSPositionChangeEvt(video_old_position, video_new_position){
// this section deals with video position slider bar change events
         video_duration = Player.currentMedia.duration;
         p3.innerHTML = video_duration;
         text_pos = 'Position_Change_Event_';
         video_old_position = parseInt(video_old_position);  // deleted fractions of a second - convert to int
         video_new_position = parseInt(video_new_position);  // deleted fractions of a second - convert to int
         text_pos = text_pos + video_new_position +'_' + video_old_position;
         submit_action(15);
         p2.innerHTML = "PLAYING_POSITION_CHANGED "+ text_pos;

         if(video_new_position>video_old_position){
// do some code to say skipped forward, e.g. store from and to position in action based Custom Fields
         }

         if(video_new_position<video_old_position){
// do some code to say skipped backwards, e.g. send positive user action signal, e.g. store from and to position in action based Custom Fields
         }
}
</script>

</body>
</html>

5. To continously run without manual interaction,

function OnDSPlayStateChangeEvt(NewState){

         switch (NewState){
                 case 1: // Stopped
                          submit_action(6);

.

..

..

}

Change to

function OnDSPlayStateChangeEvt(NewState){

.

.

.

case 1: // Stopped

            Player.controls.play();

.

.

}

6.  Now save the file and run.

Additional notes: If we want to remove the controls add

<param name=”uiMode” value=”none”>

which will remove all controls and look like flash players.

Categories: HTML Snippets