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

feature: ability to easily change videoSource to a specific device id #74

Open
2 tasks done
deviantfero opened this issue Apr 4, 2019 · 3 comments
Open
2 tasks done

Comments

@deviantfero
Copy link

deviantfero commented Apr 4, 2019

New issue checklist

General information

  • Library version(s): 2.0.13
  • iOS/Android/Browser version(s): chrome 73
  • Devices/Simulators/Machine affected:
  • Reproducible in the demo project? (Yes/No):
  • Related issues:

Question or Feature Request

Hi everyone, I'm using accelerator-core in order to easily setup one-to-one calls, but one of the requirements is being able to choose from a select list the device from which I want to stream video and audio, audio is not much of an issue, since I can just setAudioSource from the publisher, but setting a different video source is giving me trouble, normally I would kill the old publisher and unpublish it from the session, and publish the new one with the desired video source.

      const session = this.otCore.getSession();
      const otState = this.otCore.state();
      const activePublisher = otState.publishers.camera[Object.keys(otState.publishers.camera)[0]];
      console.log({ session, otState });
      session.unpublish(activePublisher);
      session.publish(publisher);
      console.log({ session, otState });

I'm feeling there must be a better way to do this using opentok-core since if I just use the method described above, the new publisher won't be a part of opentok-core global state, thus loosing track of it and not being able to repeat that action.

is there a way I can replace the camera publisher in opentok-core's state? I wouldn't want to recur to the cycleVideo method of the publisher as some users might have more than two cameras.

Also, thank you for building this wrapper, it has been really useful in more than one project, it's really easy to use.

@deviantfero deviantfero changed the title feature: ability to easily change videoSource in local stream feature: ability to easily change videoSource to a specific device id Apr 4, 2019
@manish1408
Copy link

@deviantfero Did you found any way of doing this?

Also, how do you create a publisher in otcore? I am referring to line
session.publish(publisher); in your code.

@deviantfero
Copy link
Author

deviantfero commented May 1, 2020

@manish1408 hey, I eventually gave up on this and just designed a UI around the limitation in this case, you can always use the bare OT object to create publishers and then you can use ot-core's session to publish them, so I just create them in the usual standard way OT.initPublisher, more on that here.

I recently ran into this issue again in another project, but since I was not using ot-core it was easy to simply replace the publisher I was using in the session, since I'm managing the state in this instance it's easy to do

now, what I think should happen is that you could unpublish the undesired publisher, and add a new one and ot-core state should update accordingly, just as I'm doing in the example, but you can see in the piece of code I pasted there I made a mistake, I just console logged the state I got the first time again instead of fetching it again, so maybe at the time I assumed that ot-core did not handle that correctly, I'm not sure it will now that I see that error, but it should, let me know how it goes for you, just for reference that piece of code could be:

const session = this.otCore.getSession();
const otState = this.otCore.state();
const activePublisher = otState.publishers.camera[Object.keys(otState.publishers.camera)[0]];
console.log({ session, otState });

session.unpublish(activePublisher);
session.publish(publisher, (err) => {
  if (err) return;
  console.log({ session: this.otCore.getSession(), otState: this.otCore.state() });
});

@quuu
Copy link

quuu commented Sep 25, 2020

Bumping this, are there plans to add support for setAudioSource equivalent for video?

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

3 participants