Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot redefine chapters when creating a second player #55

Closed
editpetercolquhoun opened this issue Mar 25, 2022 · 1 comment
Closed

Comments

@editpetercolquhoun
Copy link

editpetercolquhoun commented Mar 25, 2022

When I create the first player everything works fine but trying to create a second player causes an error TypeError: Cannot redefine property: chapters this stops a second player from being created.
Full stack trace
Uncaught TypeError: Cannot redefine property: chapters at Function.defineProperties (<anonymous>) at Chapter.patchPlayer (bundle.js:102149:12) at Chapter.init (bundle.js:102092:10) at bundle.js:102103:14 at bundle.js:103025:39 at Array.forEach (<anonymous>) at Events.trigger (bundle.js:103025:25) at Player.update (bundle.js:103421:19) at Player.initAudio (bundle.js:103244:12) at new Player (bundle.js:103082:10)

An example of how I am creating the player, this is triggered by button press when a user needs to create a player.

const chapters = [
      { title: 'First Chapter', startTime: 0, endTime: 2 },
      { title: 'Second Chapter', startTime: 2, endTime: 4 },
]


Shikwasa.use(Chapter)
      const player = new Shikwasa({
        container: () => document.querySelector('#e' + widgetID),
        audio: {
          title: titleTmp,
          artist: artist,
          cover: require('./testPic.jpeg'),
          src: require('./testFile.mov'),
          Chapter: chapters
        },
        theme: theme,
        themeColor: themeColour,
      })

I've checked all the variables exist and so do the test files. Thanks

@jessuni
Copy link
Owner

jessuni commented May 4, 2022

Did you register the plugin twice? The plugin is registered once, applied to every instance.
There's also an error in your snippet, it should be chapters instead of Chapter: chapters

I include a working fiddle here with two players powered by the chapter plugin for you to check and debug.

@jessuni jessuni closed this as completed Jun 23, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants