openEventsPlatformApp/plugins/cordova-plugin-camera/www/blackberry10/assets/camera.js
plugins/cordova-plugin-camera/www/blackberry10/assets/camera.jsRaw
1/*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 *
19 */
20
21document.addEventListener('DOMContentLoaded', function () {
22 document.getElementById('back').onclick = function () {
23 window.qnx.callExtensionMethod('cordova-plugin-camera', 'cancel');
24 };
25 window.navigator.webkitGetUserMedia(
26 { video: true },
27 function (stream) {
28 var video = document.getElementById('v'),
29 canvas = document.getElementById('c'),
30 camera = document.getElementById('camera');
31 video.autoplay = true;
32 video.width = window.innerWidth;
33 video.height = window.innerHeight - 100;
34 video.src = window.webkitURL.createObjectURL(stream);
35 camera.onclick = function () {
36 canvas.width = video.videoWidth;
37 canvas.height = video.videoHeight;
38 canvas.getContext('2d').drawImage(video, 0, 0, video.videoWidth, video.videoHeight);
39 window.qnx.callExtensionMethod('cordova-plugin-camera', canvas.toDataURL('img/png'));
40 };
41 },
42 function () {
43 window.qnx.callExtensionMethod('cordova-plugin-camera', 'error', 'getUserMedia failed');
44 }
45 );
46});