Go
Not registered? Sign up!

Video interaction with javascript

Google Translate
6 posts | return to the JavaScript Interaction forum | get the rss feed for this thread

Nov. 05, 2009Shatil

hello,
i have to develop an application where user will click on a video file when the video is playing and i have to take the time when the user click the on the video file and pass it to the server.

for example a video is 3 min long and the user click on the video when it is in 2 min so i have to take the time as 2 min and send it server and process it.

Nov. 05, 2009hobbs

JavaScript API code:
    <script type="text/javascript">
      var player       =  null;
      var playlist     =  null;
      var currentTime  =  null;


      function playerReady(obj)
      {
        player = gid(obj.id);
        addListeners();
      };


      function addListeners()
      {
        playlist = player.getPlaylist();

        if((playlist !== null) && (playlist.length > 0))
        {
          player.addModelListener('TIME', 'timeMonitor');
        }
        else
        {
          setTimeout("addListeners()", 100);
        }
      };


      function timeMonitor(obj)
      {
        currentTime = obj.position;
      };


      function saveTime()
      {
      //...needed to restart the player
        player.sendEvent('PLAY', 'true');

        // send current time to your server
      };


      function gid(name)
      {
        return document.getElementById(name);
      };
    </script>


Player code:
      'displayclick':             'link',
      'linktarget':               '_self',
      'link':                     'javascript:saveTime()',

Nov. 06, 2009Shatil

thanx hobbs,

i am little novice in javascript.can you explain little more like how i add the video on html and how i add the corresponding javascirpt with that embedded video.

may i sound disturbing..sorry for that.

Shatil

Nov. 06, 2009hobbs

How are you going to send the time to the server?


How are you going to process the time on the server?

Nov. 07, 2009Shatil

I have to develop hazard perception test page and in that page user will see a video and click on the video when he see a hazard and then that time will be verified against predefined time which is saved in database.

Thanx in advance

Shatil

Nov. 07, 2009hobbs

 
You need to develop your serverside code for the database and for the video player page to communicate with using AJAX.

Then when the user clicks, the time would be sent to the server, verified, and a confirmation message "correct/incorrect" — whatever, returned to the video player page.

Add a reaction

You can also return to the category or try this search for related threads.


 

Search the Forums

Go

Support

Support Here are some helpful links to learn more about the JW Player™:

Monetize Your Video

Monetize Your Video Earn money with ads from LongTail's AdSolution. Watch our demos and sign up now!

Why Buy a License?

Why Buy a License? If you don’t buy a commercial license, you cannot use a JW Player™ on (i) a site that has ads; (ii) a corporate site; or a (iii) CMS. Our licenses are very inexpensive, so what are you waiting for? Buy a license today.