accelerator-core-js icon indicating copy to clipboard operation
accelerator-core-js copied to clipboard

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

Open deviantfero opened this issue 6 years ago • 3 comments

New issue checklist

  • [x] I have read all of the README
  • [x] I have searched existing issues and this is not a duplicate.

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 avatar Apr 04 '19 04:04 deviantfero

@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.

manish1408 avatar May 01 '20 03:05 manish1408

@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() });
});

deviantfero avatar May 01 '20 05:05 deviantfero

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

quuu avatar Sep 25 '20 15:09 quuu