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

Image capture not working on Chrome browser on PC #149

Open
baibhavprdn opened this issue Oct 11, 2019 · 3 comments
Open

Image capture not working on Chrome browser on PC #149

baibhavprdn opened this issue Oct 11, 2019 · 3 comments

Comments

@baibhavprdn
Copy link

Image capture isn't working on Chrome browser

Problem: The browser does not load the preview as expected

I tested this on android (works beautifully), Edge browser which also shows the preview div with the capture preview option.

What I get: Uncaught TypeError: Failed to execute 'createObjectURL' on 'URL': No function was found that matched the signature provided. is thrown in the console

Information

I'm trying to include the media capture plugin in a cordova app I've been working on. However I've failed to implement it in the browser for even simple applications.

I searched around in stackoverflow and answers indicate that createObjectURL is supposed to be passed either Blob, File or MediaSources and not raw data but I'm unsure what exactly I need to do to get the plugin working for chrome.

I'm using all latest versions of chrome, cordova.

@breautek
Copy link
Contributor

Are you able to provide the stacktrace for the error? Perhaps breakpointing to inspect the kind of object that is being tried to be fed in. I think this information will be valuable to not only pinpointing the source but also providing some insight why it's receiving some unexpected type. Thanks.

@baibhavprdn
Copy link
Author

baibhavprdn commented Oct 14, 2019

Hey breautek here's the stacktrace for the error:

The error on console is: Uncaught TypeError: Failed to execute 'createObjectURL' on 'URL': No function was found that matched the signature provided. at CaptureProxy.js:120

in CaptureProxy.js line 120
that.preview.src = URL.createObjectURL(previewStream);

the previewSteram is being passed a MediaStream.
I modified the line with the change:
that.preview.srcObject = previewStream;
which lets me access the video preview but throws another error when I try to capture the image.
Uncaught TypeError: this._previewStream.stop is not a function at CameraUI.destroyPreview (CaptureProxy.js:135) at CaptureProxy.js:188 at HTMLVideoElement.preview.onclick (CaptureProxy.js:109)

Thanks again.

EDIT: After looking into it, I found out that the stop() function for MediaStreams is also deprecated. A workaround for my personal use was using the getVideotracks() function for MediaStreams then using stop() to every individual elements in the array.
var track = this._previewStream.getVideoTracks()[0]; // my array only contains a single element track.stop();

For anybody else who's also trying to get the plugin working on browser.

onlinesid added a commit to onlinesid/cordova-plugin-media-capture that referenced this issue Apr 10, 2020
onlinesid added a commit to onlinesid/cordova-plugin-media-capture that referenced this issue Apr 10, 2020
onlinesid added a commit to onlinesid/cordova-plugin-media-capture that referenced this issue Apr 10, 2020
onlinesid added a commit to onlinesid/cordova-plugin-media-capture that referenced this issue Apr 10, 2020
Image capture not working on Chrome browser
onlinesid added a commit to onlinesid/cordova-plugin-media-capture that referenced this issue Apr 10, 2020
@onlinesid
Copy link

Sorry I closed the earlier PR and created a new one as I mistakenly created the first PR from my master branch and I didn't intend to do that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants