Player stops with Next.js Router page change #731
Replies: 5 comments
-
Hi @erubescent, thank you for sharing that. Player re-initialize its player via
If you need more dynamism in your component, const plyrVideo = useMemo(
() =>
videoId && provider ? (
<Plyr
ref={ref}
source={{type: "video", sources: [{src: videoId, provider: provider}]}}
options={videoOptions}
/>
) : null,
[videoId && provider]
); Check out this sandbox for full version .
|
Beta Was this translation helpful? Give feedback.
-
Hi @amirHossein-Ebrahimi, thanks for responding! When using the code in my project, I get the desired functionality in having the content play across every page without interrupting playback on page changes. I'm fairly new to how React has changed so this is really helpful, thank you. I've also tested this without using How would I use the code you shared for audio? I've tried changing the parameters and making the Check my sandbox here. |
Beta Was this translation helpful? Give feedback.
-
Happy to hear it solves your issue,
sources: [{
src: audioURL,
type: "audio/wav"
}] Here is a complete codesnadbox Out of the topic:The song was nice 👍🏻 🤗 And Happy new year @erubescent |
Beta Was this translation helpful? Give feedback.
-
Hi! Thank you so much, @amirHossein-Ebrahimi, Happy new year to you as well!! Cheers 🍻 I thought I was missing something simple. I appreciate all of your help. 😇 ~ I read somewhere in one of the issues: is the documentation going to eventually be updated for plyr-react? I've been following the Plyr documentation and its very helpful, but of course React is a lot more functional. I'm used to vanilla JS, and React has so much more functionality and I love it. I have a few more questions if you don't mind so I can get a better understanding on how to use plyr-react with what I am building:
I eventually plan to render details about specific songs from a database, have pages linking to timestamps, and more. This would be extremely helpful to understand how other websites do this (like SoundCloud and MixCloud) and how I can implement it on my own. Again, thank you for everything. Looking forward to hearing from you, and I hope this year is better than last! :)) |
Beta Was this translation helpful? Give feedback.
-
That is good to hear, and we had planned to complete the doc, but we didn't get the time for updating the current doc so much.
IMO the best way to use the plyr-react is conditional, in a case you need something like <Plyr key='something which cause the whole thing to be refresh and new whenever it changes' {...rest} />
I am afraid I didn't understand your question well but rendering from all over the place can be completely done duo to our imperative API (
Finally, we are happy to hear that Plyr-react was useful for you, and that's all open-source communication means. |
Beta Was this translation helpful? Give feedback.
-
Hello,
I'm building a website that features one player at the bottom of the page (kind of like SoundCloud and MixCloud) that will allow the user to select through songs on different pages and will play the track. I've always used Plyr since it's ease of use and customization.
I've set up one main component with Plyr that has one track for testing purposes. Code below:
And then I import the component as follows in my Layout so it renders on every page. The expected behavior would be to keep playing on every page. It was working that way when I used react-player.
However, on every page change, the player stops and restarts. I use Next Router to handle page changes.
I enabled debugging and noticed every time I load a new page, this appears in the console:
Cancelled network requests
Not sure if I am missing something minor or if this is bug with nextJS routing, but I would highly appreciate any advice on how to prevent this and keep it playing. Soon I'll add a way to select tracks and have timestamps + Firebase, etc.
Thank you!
Beta Was this translation helpful? Give feedback.
All reactions