Giter VIP home page Giter VIP logo

Comments (10)

rafa8626 avatar rafa8626 commented on May 14, 2024

Thanks for all these useful info. There's not a lot of sources on how to achieve this and I'll look more into Cast documentation but I have no idea how to remove the sessions since that's what I was trying to do originally. I'll keep looking and keep you posted. Thanks again

from mediaelement-plugins.

rafa8626 avatar rafa8626 commented on May 14, 2024

Can you do me a favor: in Chromecast.js create a method called cleanchromecast and put the code you use the code you set up to remove the current session and see if it does any good

from mediaelement-plugins.

rafa8626 avatar rafa8626 commented on May 14, 2024

Also take a look at this Fiddle and see if anything could work for you: https://jsfiddle.net/gurupras/sgLfcocq/

from mediaelement-plugins.

rafa8626 avatar rafa8626 commented on May 14, 2024

I fond this snippet and maybe that's the answer. Can you try using this?

function stopCasting() {
  var castSession = cast.framework.CastContext.getInstance().getCurrentSession();
  // End the session and pass 'true' to indicate
  // that receiver application should be stopped.
  castSession.endSession(true);
}

from mediaelement-plugins.

sergioavazquez avatar sergioavazquez commented on May 14, 2024

I had already tried the last snippet but I added it to cleanchromecast(), added it on unmounting and all combinations I could come up with. Regardless of how you end the session, if you open chrome's console immediately afterwards, get the context instance (window.cast.framework.CastContext.getInstance()) and request a session (session.requestSession()), previous cast resumes. Apparently we need to kill the context, because as soon as you request a session on the same context everything you did on that context is still there.
I'm going to explore the fiddle you sent, but I believe the best and cleanest solution is to reset the context rather than having to handle sessions and a lot of code that I don't really need.
I tried removing the entire cast framework on unmounting with that purpose but that generates a lot of errors and I can't get it to cast again.
I'm going to keep digging...

from mediaelement-plugins.

sergioavazquez avatar sergioavazquez commented on May 14, 2024

I tried creating a new context, since it's a singleton it should replace the previous one but apparently you cannot get a session from it so chomecast.js throws and error. Also tried to set up a castOption: resumeSavedSession to false but no luck...

from mediaelement-plugins.

rafa8626 avatar rafa8626 commented on May 14, 2024

Thanks I'll keep looking in the documentation about how to do this properly or I'll ask the question directly if I'm at lost

from mediaelement-plugins.

rafa8626 avatar rafa8626 commented on May 14, 2024

@sergioavazquez I have updated the plugin with a missing workflow to avoid loading a request more than once, and destroying Cast session properly. Please download the master branch and let me know if it worked for you. I tested on my local ReactJS env and seemed to work just fine.

from mediaelement-plugins.

sergioavazquez avatar sergioavazquez commented on May 14, 2024

@rafa8626 you nailed it! It's working like a charm...

from mediaelement-plugins.

rafa8626 avatar rafa8626 commented on May 14, 2024

Excellent news!! Thanks for testing this good team work

from mediaelement-plugins.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.