1

Im using youtube api's cueVideoByID and was wondering if there is a way for me to be able to specify multiple "startSeconds" and "endSeconds" for a youtube embedded video and play each one of them right after the previous one.
Something like this:

this.player.cueVideoById(
    { videoId: 'CyySYgkLTak', startSeconds: 10, endSeconds: 12 },
    { videoId: 'CyySYgkLTak', startSeconds: 15, endSeconds: 17 },
    { videoId: 'CyySYgkLTak', startSeconds: 20, endSeconds: 27 },
 )
this.player.playVideo()

What i would like is for the second object to play after the first one and so forth.
What this code does is that it only plays the first one

BillJustin
  • 274
  • 1
  • 10
  • 2
    Create an array of sections. Queue the first one to play. Set up a listener to detect when the video has finished playing, and queue the next one up. See https://stackoverflow.com/a/11726088/378779 – kmoser Aug 18 '20 at 05:55
  • I tried doing this but it skips(goes through but ends immediately) some of the array. it seems like i need to do a setTimeout or setInterval but im trying to stay away from these two because they give problems on interval. What i need is something like a multiple cueVideoById as stated above – BillJustin Aug 18 '20 at 07:31
  • 1
    Please show us the code you tried. – kmoser Aug 18 '20 at 14:50
  • it is the code above. but i already solved it using a different way. ill post the answer soon – BillJustin Aug 19 '20 at 05:45

0 Answers0