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

Camera switching in a dropdown list #247

Merged
merged 2 commits into from
Aug 21, 2021

Conversation

waridrox
Copy link
Member

@waridrox waridrox commented Aug 13, 2021

Camera switching workflow for video stream:

  • Get all the possible devices in a dropdown
  • For each deviceId associate a video stream
  • On device change through dropdown, stop the current stream and switch to the newly selected stream

Hi @jywarren, the current implementation is such that it takes the initial facingMode as undefined, since the devices have not been fetched yet.

 var constraints = {
        video: {
          deviceId: videoSource ? {exact: videoSource} : undefined //Taking device ids as the video source 
        }
      };

Even after fetching, it is unclear as to what device is facing the environment since some devices don't actually have a facingMode as environment. The MDN docs recommend using it for smartphones.
For instance if a laptop is connected to an external camera, that external camera is recognised as a facingMode = environment instead of the primary one.

Thus, I wanted to know your thoughts regarding this...

Make sure these boxes are checked before your pull request is ready to be reviewed and merged. Thanks!

  • tests pass -- see README.md for how to run them
  • code is in uniquely-named feature branch, and has been rebased on top of latest master (especially if you've been asked to make additional changes)
  • pull request are descriptively named
  • if possible, multiple commits squashed if they're smaller changes
  • reviewed/confirmed/tested by another contributor or maintainer

Please be sure you've reviewed our contribution guidelines at https://publiclab.org/wiki/contributing-to-public-lab-software

Please alert developers on [email protected] when your request is ready or if you need assistance.

Thanks!

@gitpod-io
Copy link

gitpod-io bot commented Aug 13, 2021

@jywarren
Copy link
Member

Hmm. What's the specific problem we're trying to fix in this PR? If we aren't always sure of the initial state, let's just say it's OK whatever the default is (after we give out best guess preference) and then if it's wrong the user will choose the better option from the dropdown. Would that work, or am I not quite getting your question? Thank you!!

@waridrox
Copy link
Member Author

Sorry for the confusion 😅 I meant to say that when I tried out with wifi cam on my system, the primary cam was being identified as the wifi cam instead of the usual laptop cam

So there isn't a proper way to determine if a device even has a facingMode = environment in the first place. Because then the laptop cam should've been the environment facing one

let's just say it's OK whatever the default is (after we give out best guess preference) and then if it's wrong the user will choose the better option from the dropdown. Would that work

Yes that would work 💯

}
}

videoSelect.onchange = start; //repeating the process for source change
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's saying Cannot set property 'onchange' of null probably in relation to this line -- do we have to modify anything for the cypress tests to see the videoSelect element?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think there was no dropdown element for the camera selection in the interface, that's why the tests were failing 😅

@waridrox waridrox requested a review from jywarren August 21, 2021 15:41
@jywarren jywarren merged commit 2013be6 into publiclab:main Aug 21, 2021
@welcome
Copy link

welcome bot commented Aug 21, 2021

Congrats on merging your first pull request! 🙌🎉⚡️
Your code will likely be published to https://spectralworkbench.org in the next few days.
In the meantime, can you tell us your Twitter handle so we can thank you properly?
Now that you've completed this, you can help someone else take their first step!
See: Public Lab's coding community!

@jywarren
Copy link
Member

🎉🎉

@jywarren
Copy link
Member

Should we bump the version and release a 0.0.x update?

@jywarren
Copy link
Member

And, if you can link all the issues/PRs together as we do the publication process (including to this one) that would be great.

@waridrox
Copy link
Member Author

Sure as far this version bump, there are these PRs only

Changelog for v0.2.1

#247 - Allows changing of video device streams in the form of a dropdown.
#245 - Allows to download the live spectrum image in the form of a .png file.

@jywarren
Copy link
Member

Sounds great. Would you like to open a PR for the updated version or shall i do it when I publish? Either way works for me!

@jywarren
Copy link
Member

I went ahead and bumped it and published!!

3e93995

https://www.npmjs.com/package/spectral-workbench

@waridrox
Copy link
Member Author

🎉 🚀 Thanks @jywarren!!! Though I think the dropdown functionality was still on hold...😅

@jywarren
Copy link
Member

Ah, well we can release it in the next publication!

Sorry, I took your 👍 as meaning we can go ahead. I'll be more careful to get an explicit "yes" in the future, thanks!!!

@jywarren
Copy link
Member

I merged a bunch of dependabot PRs at https://github.com/publiclab/spectral-workbench/pulls and we should see this one reach there soon. If you want we can resolve the dropdown one and then merge after, but it's not a big deal to go through the process twice!

@waridrox
Copy link
Member Author

No it's just that I included the dropdown element on the interface at /v2 so that's why I was thinking about the dropdown one 😅

@jywarren
Copy link
Member

Ah, ok! let's merge that too then!

@jywarren
Copy link
Member

Ah, no, ok - so i guess actually the dropdown one is all good then, as we merged #247 ?

@waridrox
Copy link
Member Author

Yes it is 🙌

@jywarren
Copy link
Member

Ah, sorry, maybe I still misunderstand. Is there something missing we need to fix now, or are we OK to take this a little slower?

Ah, i see your response that it's OK now. Thanks!

Let's try to document clearly the interdependencies between PRs so we can sequence them correctly. Let's use clear comments like Before merging this or Immediately after merging this... etc!

Thanks!!!

@waridrox
Copy link
Member Author

So the new interface also has a dropdown button which would be non-functional if we don't merge #245. The camera functionality was crucial so that is already done.

jywarren added a commit that referenced this pull request Sep 21, 2021
* Update README.md

* Update README.md

* Bump jasmine from 3.6.1 to 3.7.0 (#216)

Bumps [jasmine](https://github.com/jasmine/jasmine-npm) from 3.6.1 to 3.7.0.
- [Release notes](https://github.com/jasmine/jasmine-npm/releases)
- [Commits](jasmine/jasmine-npm@v3.6.1...v3.7.0)

Signed-off-by: dependabot-preview[bot] <[email protected]>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>

* Bump tape from 5.2.0 to 5.2.2 (#211)

Bumps [tape](https://github.com/substack/tape) from 5.2.0 to 5.2.2.
- [Release notes](https://github.com/substack/tape/releases)
- [Commits](tape-testing/tape@v5.2.0...v5.2.2)

Signed-off-by: dependabot-preview[bot] <[email protected]>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>

* [Security] Bump ini from 1.3.5 to 1.3.8 (#198)

Bumps [ini](https://github.com/isaacs/ini) from 1.3.5 to 1.3.8. **This update includes a security fix.**
- [Release notes](https://github.com/isaacs/ini/releases)
- [Commits](npm/ini@v1.3.5...v1.3.8)

Signed-off-by: dependabot-preview[bot] <[email protected]>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>

* bump to v0.2.0 (#238)

* Camera switching in a dropdown list (#247)

* Added camera switching in a dropdown

* Added dropdown element for camera switching on old and new interface

Added dropdown element on old interface

* bump to v0.2.1

* Bump moment from 2.10.6 to 2.19.3 (#230)

Bumps [moment](https://github.com/moment/moment) from 2.10.6 to 2.19.3.
- [Release notes](https://github.com/moment/moment/releases)
- [Changelog](https://github.com/moment/moment/blob/develop/CHANGELOG.md)
- [Commits](moment/moment@2.10.6...2.19.3)

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump jquery from 3.5.1 to 3.6.0 (#232)

Bumps [jquery](https://github.com/jquery/jquery) from 3.5.1 to 3.6.0.
- [Release notes](https://github.com/jquery/jquery/releases)
- [Commits](jquery/jquery@3.5.1...3.6.0)

Signed-off-by: dependabot-preview[bot] <[email protected]>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>

* Bump grunt-cli from 1.3.2 to 1.4.3 (#234)

Bumps [grunt-cli](https://github.com/gruntjs/grunt-cli) from 1.3.2 to 1.4.3.
- [Release notes](https://github.com/gruntjs/grunt-cli/releases)
- [Changelog](https://github.com/gruntjs/grunt-cli/blob/main/CHANGELOG.md)
- [Commits](gruntjs/grunt-cli@v1.3.2...v1.4.3)

Signed-off-by: dependabot-preview[bot] <[email protected]>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>

* Bump cypress from 5.1.0 to 8.1.0 (#244)

Bumps [cypress](https://github.com/cypress-io/cypress) from 5.1.0 to 8.1.0.
- [Release notes](https://github.com/cypress-io/cypress/releases)
- [Changelog](https://github.com/cypress-io/cypress/blob/develop/.releaserc.base.js)
- [Commits](https://github.com/cypress-io/cypress/compare/@cypress/react-v5.1.0...v8.1.0)

Signed-off-by: dependabot-preview[bot] <[email protected]>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>

* Bump path-parse from 1.0.6 to 1.0.7 (#246)

Bumps [path-parse](https://github.com/jbgutierrez/path-parse) from 1.0.6 to 1.0.7.
- [Release notes](https://github.com/jbgutierrez/path-parse/releases)
- [Commits](https://github.com/jbgutierrez/path-parse/commits/v1.0.7)

---
updated-dependencies:
- dependency-name: path-parse
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Upgrade to GitHub-native Dependabot (#226)

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>

* Bump cypress from 8.1.0 to 8.3.0 (#253)

Bumps [cypress](https://github.com/cypress-io/cypress) from 8.1.0 to 8.3.0.
- [Release notes](https://github.com/cypress-io/cypress/releases)
- [Changelog](https://github.com/cypress-io/cypress/blob/develop/.releaserc.base.js)
- [Commits](cypress-io/cypress@v8.1.0...v8.3.0)

---
updated-dependencies:
- dependency-name: cypress
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump grunt from 1.3.0 to 1.4.1 (#252)

Bumps [grunt](https://github.com/gruntjs/grunt) from 1.3.0 to 1.4.1.
- [Release notes](https://github.com/gruntjs/grunt/releases)
- [Changelog](https://github.com/gruntjs/grunt/blob/main/CHANGELOG)
- [Commits](gruntjs/grunt@v1.3.0...v1.4.1)

---
updated-dependencies:
- dependency-name: grunt
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump jquery.steps from 1.1.1 to 1.1.2 (#250)

Bumps [jquery.steps](https://github.com/oguzhanoya/jquery-steps) from 1.1.1 to 1.1.2.
- [Release notes](https://github.com/oguzhanoya/jquery-steps/releases)
- [Commits](oguzhanoya/jquery-steps@v1.1.1...v1.1.2)

---
updated-dependencies:
- dependency-name: jquery.steps
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump tape from 5.2.2 to 5.3.1 (#249)

Bumps [tape](https://github.com/substack/tape) from 5.2.2 to 5.3.1.
- [Release notes](https://github.com/substack/tape/releases)
- [Commits](tape-testing/tape@v5.2.2...v5.3.1)

---
updated-dependencies:
- dependency-name: tape
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump jasmine from 3.7.0 to 3.9.0 (#248)

Bumps [jasmine](https://github.com/jasmine/jasmine-npm) from 3.7.0 to 3.9.0.
- [Release notes](https://github.com/jasmine/jasmine-npm/releases)
- [Commits](jasmine/jasmine-npm@v3.7.0...v3.9.0)

---
updated-dependencies:
- dependency-name: jasmine
  dependency-type: direct:development
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump moment from 2.19.3 to 2.29.1 (#257)

Bumps [moment](https://github.com/moment/moment) from 2.19.3 to 2.29.1.
- [Release notes](https://github.com/moment/moment/releases)
- [Changelog](https://github.com/moment/moment/blob/develop/CHANGELOG.md)
- [Commits](moment/moment@2.19.3...2.29.1)

---
updated-dependencies:
- dependency-name: moment
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump cypress from 8.3.0 to 8.3.1 (#259)

Bumps [cypress](https://github.com/cypress-io/cypress) from 8.3.0 to 8.3.1.
- [Release notes](https://github.com/cypress-io/cypress/releases)
- [Changelog](https://github.com/cypress-io/cypress/blob/develop/.releaserc.base.js)
- [Commits](cypress-io/cypress@v8.3.0...v8.3.1)

---
updated-dependencies:
- dependency-name: cypress
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Bump http-server from 0.12.3 to 13.0.1 (#258)

Bumps [http-server](https://github.com/http-party/http-server) from 0.12.3 to 13.0.1.
- [Release notes](https://github.com/http-party/http-server/releases)
- [Commits](http-party/http-server@v0.12.3...v13.0.1)

---
updated-dependencies:
- dependency-name: http-server
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

* Added functionality for downloading spectrum image (#245)

* Added function for downloading spectrum img

* Adding dropdown for camera switching

* download file and check length

* Update spectral-workbench-demo.spec.js

* Update spectral-workbench-demo.spec.js

* Update spectral-workbench-demo.spec.js

* increase file length test for downloaded image

Co-authored-by: Jeffrey Warren <[email protected]>

* Bump http-server from 13.0.1 to 13.0.2 (#260)

Bumps [http-server](https://github.com/http-party/http-server) from 13.0.1 to 13.0.2.
- [Release notes](https://github.com/http-party/http-server/releases)
- [Commits](http-party/http-server@v13.0.1...v13.0.2)

---
updated-dependencies:
- dependency-name: http-server
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <[email protected]>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>

Co-authored-by: dependabot-preview[bot] <27856297+dependabot-preview[bot]@users.noreply.github.com>
Co-authored-by: Mohammad Warid <[email protected]>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
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.

2 participants