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

Called 'ct_cacheVideo' inside 'ct_mediaLoaded' #13

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

SezerYardim
Copy link

Closes #8

I did what you mentioned in the issue. Called ct_cacheVideoinside ct_mediaLoaded in order to cache and play simultaneously.

Sorry for the commit message. I wasnt sure how to name it so if it is bad you can change it.

@Seneral
Copy link
Owner

Seneral commented Jan 8, 2022

Since this is a change not everyone wants (as it can take quite a lot of disk space) I would make it a separate option (that is OFF by default).
Reason for this is that caching a video requires it to go over the proxy, which is currently hosted on heroku for free (which you notice as a long page load after nobody used the site for 30minutes as the nodes start up).
Bandwidth is also not unlimited there, not a problem this early even for free nodes I think, but still.

The way to do that would be to just copy every occurance for the Cache First option (which in the same change also rename in the UI to "Always Use Cache"). A good name for the new option could be "Always Cache Audio".
Do note also, that with this implementation, you will always download the audio TWICE when first watching. Once from youtube directly for playback, once from the proxy server for caching.
I'm not sure just switching the playback audio to the proxy is going to change that either.
Best option would be to look ahead which video is going to play next if possible and start caching that as the current video plays.

All those options would be a bit more complex to implement though.
You think you can implement that? Else I might do it, though not today for sure.

@SezerYardim
Copy link
Author

@Seneral So what you suggest is

  1. Create a new switch button named "Always Cache Audio"
  2. Copy the implementation of "Cache First" function
  3. Integrate that function to the new switch button with an event listener
  4. If there is a playlist, get the next video url and start caching it

Am i right ? If so, i know how to implement those but the problem is i am not 100% confident with the current codebase. Because it is just a single file with a lot of functions in it. Reading and understanding it from top to bottom is a little bit hard and confusing. So it would take a little longer than it requires

@Seneral
Copy link
Owner

Seneral commented Jan 10, 2022

Yeah just search to navigate.
E.g. the variables used to store the parameters + the html id for the existing "Cache First" function is all you need to find every place that needs changing afaik

Also 4. is pretty complex to implement even for me, so I wouldn't attempt that, just use the existing implementation and wrap it in a parameter. Or I can try the other stuff later, either way we need another toggle

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

Successfully merging this pull request may close these issues.

Automatically cache audio when playing
2 participants