liqvidjs / liqvid

Library for interactive videos in React
https://liqvidjs.org
MIT License
754 stars 39 forks source link

new Script() not working with number duration #26

Closed anishg-cn closed 2 years ago

anishg-cn commented 2 years ago

when calling new Script(markers) with the markers having durations as number instead of string, it is throwing error.

I think in the following code the parseTime function should check if the duration is of type number or string before operating on the duration.

      if (marker.length === 2) {
        const [, duration] = marker;
        marker[1] = time;
        marker[2] = time + parseTime(duration);
      } else {
        const [, begin, end] = marker;
        marker[1] = parseTime(begin);
        marker[2] = parseTime(end);
      }

      time = marker[2];
    }

The error is following:


       Uncaught (in promise) TypeError: str.split is not a function
    at parseTime (liqvid.mjs:887:1)
    at new Script (liqvid.mjs:3251:1)

@ysulyma please check.

ysulyma commented 2 years ago

@anishg-cn this is actually the current intended behavior, the types in the constructor are wrong. But agree that you should be able to pass numeric durations to Script. I'm feeling pretty ill today, I can cut new versions tomorrow. For now pass durations as strings.

anishg-cn commented 2 years ago

@ysulyma ok thanks

ysulyma commented 2 years ago

@anishg-cn try with v2.1.5