www.webdeveloper.com
Results 1 to 2 of 2

Thread: Basic Javascript question

Hybrid View

  1. #1
    Join Date
    Jul 2013
    Posts
    1

    Basic Javascript question

    I am trying to get a video player to play from a specific point in time. I happen to be using videojs (https://github.com/videojs/video.js/...er/docs/api.md)

    Here is the code, In this example it's supposed to start from 120 seconds into the video but it still starts from the beginning:

    Code:
    ...
    <body>
    
      <video id="example_video_1" class="video-js vjs-default-skin" controls preload="none" width="640" height="264"
          poster="grandma.png"
          data-setup="{}">
        <source src="grandma.mp4" type='video/mp4' />
        <track kind="captions" src="demo.captions.vtt" srclang="en" label="English"></track><!-- Tracks need an ending tag thanks to IE9 -->
      </video>
      <script>
     videojs("example_video_1").ready(function(){
    
      var myPlayer = videojs.setup("example_video_1");
    
      // EXAMPLE: Start playing the video.
      myPlayer.play();
      myPlayer.currentTime(120);
    
      });
    
      </script>
    when I execute the code in a browser it still starts from the beginning..

    Thanks in advance for your help

  2. #2
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,648
    what if you try to change the current order

    Code:
    ...
    myPlayer.play();
    myPlayer.currentTime(120);
    ...
    to

    Code:
    ...
    myPlayer.currentTime(120);
    myPlayer.play();
    ...
    xxx: Guess Buddhist riddle: "What is the sound of one hand clapping?"
    yyy: facepalm

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles