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

Initialization and transmission of video stream #23

Open
ivansteff opened this issue Nov 21, 2019 · 1 comment
Open

Initialization and transmission of video stream #23

ivansteff opened this issue Nov 21, 2019 · 1 comment

Comments

@ivansteff
Copy link

Hello @entertailion @jtromo @ginayeh @meihua @smishra2 googlecast team!
I need you help.
Add chrome cast according to the tutorial

After adding the Chromecast button, I click it, select an available device from the network, and it is connected. The status "Streaming" is visible in the browser, in fact nothing happens, except for the following error in the console:

TypeError: Cannot read property 'loadMedia' of null

Code:

cast.framework.CastContext.getInstance().setOptions({
      receiverApplicationId: '111111',
      autoJoinPolicy: chrome.cast.AutoJoinPolicy.ORIGIN_SCOPED
  });


  var currentMediaURL =
      'https://.....';
  var contentType = 'mp4';

          var mediaInfo = new chrome.cast.media.MediaInfo(currentMediaURL,contentType);
          var request = new chrome.cast.media.LoadRequest(mediaInfo);

          console.log('Below variable -mediaInfo ');
          console.log(mediaInfo);
          console.log('Below variable -request ');
          console.log(request);

          var castSession = cast.framework.CastContext.getInstance().getCurrentSession();
           console.log('Below variable -castSession ');
          console.log(castSession);

  castSession.loadMedia(request).then(
      function () {
          console.log('Load succeed');
      },
      function (errorCode) {
          console.log('Error code: ' + errorCode);
      });

Code testing:

NUfSz

As I understand it, for some reason, the link to the stream is not sent. There is an interesting question, why does the link to the stream go to the variable contentid although there is a variable contentUrl?

@jtromo
Copy link
Contributor

jtromo commented Sep 27, 2021

The issue is your CastSession is null when you try to load the media. Are you waiting until the device has been connected and the session is established before trying to load the media?

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