CB-6521: Remove development branch
diff --git a/LICENSE b/LICENSE
deleted file mode 100644
index 7a4a3ea..0000000
--- a/LICENSE
+++ /dev/null
@@ -1,202 +0,0 @@
-
- Apache License
- Version 2.0, January 2004
- http://www.apache.org/licenses/
-
- TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
-
- 1. Definitions.
-
- "License" shall mean the terms and conditions for use, reproduction,
- and distribution as defined by Sections 1 through 9 of this document.
-
- "Licensor" shall mean the copyright owner or entity authorized by
- the copyright owner that is granting the License.
-
- "Legal Entity" shall mean the union of the acting entity and all
- other entities that control, are controlled by, or are under common
- control with that entity. For the purposes of this definition,
- "control" means (i) the power, direct or indirect, to cause the
- direction or management of such entity, whether by contract or
- otherwise, or (ii) ownership of fifty percent (50%) or more of the
- outstanding shares, or (iii) beneficial ownership of such entity.
-
- "You" (or "Your") shall mean an individual or Legal Entity
- exercising permissions granted by this License.
-
- "Source" form shall mean the preferred form for making modifications,
- including but not limited to software source code, documentation
- source, and configuration files.
-
- "Object" form shall mean any form resulting from mechanical
- transformation or translation of a Source form, including but
- not limited to compiled object code, generated documentation,
- and conversions to other media types.
-
- "Work" shall mean the work of authorship, whether in Source or
- Object form, made available under the License, as indicated by a
- copyright notice that is included in or attached to the work
- (an example is provided in the Appendix below).
-
- "Derivative Works" shall mean any work, whether in Source or Object
- form, that is based on (or derived from) the Work and for which the
- editorial revisions, annotations, elaborations, or other modifications
- represent, as a whole, an original work of authorship. For the purposes
- of this License, Derivative Works shall not include works that remain
- separable from, or merely link (or bind by name) to the interfaces of,
- the Work and Derivative Works thereof.
-
- "Contribution" shall mean any work of authorship, including
- the original version of the Work and any modifications or additions
- to that Work or Derivative Works thereof, that is intentionally
- submitted to Licensor for inclusion in the Work by the copyright owner
- or by an individual or Legal Entity authorized to submit on behalf of
- the copyright owner. For the purposes of this definition, "submitted"
- means any form of electronic, verbal, or written communication sent
- to the Licensor or its representatives, including but not limited to
- communication on electronic mailing lists, source code control systems,
- and issue tracking systems that are managed by, or on behalf of, the
- Licensor for the purpose of discussing and improving the Work, but
- excluding communication that is conspicuously marked or otherwise
- designated in writing by the copyright owner as "Not a Contribution."
-
- "Contributor" shall mean Licensor and any individual or Legal Entity
- on behalf of whom a Contribution has been received by Licensor and
- subsequently incorporated within the Work.
-
- 2. Grant of Copyright License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- copyright license to reproduce, prepare Derivative Works of,
- publicly display, publicly perform, sublicense, and distribute the
- Work and such Derivative Works in Source or Object form.
-
- 3. Grant of Patent License. Subject to the terms and conditions of
- this License, each Contributor hereby grants to You a perpetual,
- worldwide, non-exclusive, no-charge, royalty-free, irrevocable
- (except as stated in this section) patent license to make, have made,
- use, offer to sell, sell, import, and otherwise transfer the Work,
- where such license applies only to those patent claims licensable
- by such Contributor that are necessarily infringed by their
- Contribution(s) alone or by combination of their Contribution(s)
- with the Work to which such Contribution(s) was submitted. If You
- institute patent litigation against any entity (including a
- cross-claim or counterclaim in a lawsuit) alleging that the Work
- or a Contribution incorporated within the Work constitutes direct
- or contributory patent infringement, then any patent licenses
- granted to You under this License for that Work shall terminate
- as of the date such litigation is filed.
-
- 4. Redistribution. You may reproduce and distribute copies of the
- Work or Derivative Works thereof in any medium, with or without
- modifications, and in Source or Object form, provided that You
- meet the following conditions:
-
- (a) You must give any other recipients of the Work or
- Derivative Works a copy of this License; and
-
- (b) You must cause any modified files to carry prominent notices
- stating that You changed the files; and
-
- (c) You must retain, in the Source form of any Derivative Works
- that You distribute, all copyright, patent, trademark, and
- attribution notices from the Source form of the Work,
- excluding those notices that do not pertain to any part of
- the Derivative Works; and
-
- (d) If the Work includes a "NOTICE" text file as part of its
- distribution, then any Derivative Works that You distribute must
- include a readable copy of the attribution notices contained
- within such NOTICE file, excluding those notices that do not
- pertain to any part of the Derivative Works, in at least one
- of the following places: within a NOTICE text file distributed
- as part of the Derivative Works; within the Source form or
- documentation, if provided along with the Derivative Works; or,
- within a display generated by the Derivative Works, if and
- wherever such third-party notices normally appear. The contents
- of the NOTICE file are for informational purposes only and
- do not modify the License. You may add Your own attribution
- notices within Derivative Works that You distribute, alongside
- or as an addendum to the NOTICE text from the Work, provided
- that such additional attribution notices cannot be construed
- as modifying the License.
-
- You may add Your own copyright statement to Your modifications and
- may provide additional or different license terms and conditions
- for use, reproduction, or distribution of Your modifications, or
- for any such Derivative Works as a whole, provided Your use,
- reproduction, and distribution of the Work otherwise complies with
- the conditions stated in this License.
-
- 5. Submission of Contributions. Unless You explicitly state otherwise,
- any Contribution intentionally submitted for inclusion in the Work
- by You to the Licensor shall be under the terms and conditions of
- this License, without any additional terms or conditions.
- Notwithstanding the above, nothing herein shall supersede or modify
- the terms of any separate license agreement you may have executed
- with Licensor regarding such Contributions.
-
- 6. Trademarks. This License does not grant permission to use the trade
- names, trademarks, service marks, or product names of the Licensor,
- except as required for reasonable and customary use in describing the
- origin of the Work and reproducing the content of the NOTICE file.
-
- 7. Disclaimer of Warranty. Unless required by applicable law or
- agreed to in writing, Licensor provides the Work (and each
- Contributor provides its Contributions) on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
- implied, including, without limitation, any warranties or conditions
- of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
- PARTICULAR PURPOSE. You are solely responsible for determining the
- appropriateness of using or redistributing the Work and assume any
- risks associated with Your exercise of permissions under this License.
-
- 8. Limitation of Liability. In no event and under no legal theory,
- whether in tort (including negligence), contract, or otherwise,
- unless required by applicable law (such as deliberate and grossly
- negligent acts) or agreed to in writing, shall any Contributor be
- liable to You for damages, including any direct, indirect, special,
- incidental, or consequential damages of any character arising as a
- result of this License or out of the use or inability to use the
- Work (including but not limited to damages for loss of goodwill,
- work stoppage, computer failure or malfunction, or any and all
- other commercial damages or losses), even if such Contributor
- has been advised of the possibility of such damages.
-
- 9. Accepting Warranty or Additional Liability. While redistributing
- the Work or Derivative Works thereof, You may choose to offer,
- and charge a fee for, acceptance of support, warranty, indemnity,
- or other liability obligations and/or rights consistent with this
- License. However, in accepting such obligations, You may act only
- on Your own behalf and on Your sole responsibility, not on behalf
- of any other Contributor, and only if You agree to indemnify,
- defend, and hold each Contributor harmless for any liability
- incurred by, or claims asserted against, such Contributor by reason
- of your accepting any such warranty or additional liability.
-
- END OF TERMS AND CONDITIONS
-
- APPENDIX: How to apply the Apache License to your work.
-
- To apply the Apache License to your work, attach the following
- boilerplate notice, with the fields enclosed by brackets "[]"
- replaced with your own identifying information. (Don't include
- the brackets!) The text should be enclosed in the appropriate
- comment syntax for the file format. We also recommend that a
- file or class name and description of purpose be included on the
- same "printed page" as the copyright notice for easier
- identification within third-party archives.
-
- Copyright [yyyy] [name of copyright owner]
-
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
\ No newline at end of file
diff --git a/NOTICE b/NOTICE
deleted file mode 100644
index 8ec56a5..0000000
--- a/NOTICE
+++ /dev/null
@@ -1,5 +0,0 @@
-Apache Cordova
-Copyright 2012 The Apache Software Foundation
-
-This product includes software developed at
-The Apache Software Foundation (http://www.apache.org/).
diff --git a/README.md b/README.md
index 793db47..8a0e3be 100644
--- a/README.md
+++ b/README.md
@@ -20,3 +20,5 @@
# org.apache.cordova.media-capture
Plugin documentation: [doc/index.md](doc/index.md)
+
+This is `dev` - the deprecated development branch of this plugin; development of this plugin has moved to the `master` branch
diff --git a/RELEASENOTES.md b/RELEASENOTES.md
deleted file mode 100644
index b82a16c..0000000
--- a/RELEASENOTES.md
+++ /dev/null
@@ -1,74 +0,0 @@
-<!--
-#
-# Licensed to the Apache Software Foundation (ASF) under one
-# or more contributor license agreements. See the NOTICE file
-# distributed with this work for additional information
-# regarding copyright ownership. The ASF licenses this file
-# to you under the Apache License, Version 2.0 (the
-# "License"); you may not use this file except in compliance
-# with the License. You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing,
-# software distributed under the License is distributed on an
-# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
-# KIND, either express or implied. See the License for the
-# specific language governing permissions and limitations
-# under the License.
-#
--->
-# Release Notes
-
-### 0.2.2 (Sept 25, 2013)
-* CB-4889 bumping&resetting version
-* [windows8] commandProxy was moved
-* [windows8] commandProxy was moved
-* CB-4889
-* CB-4889 renaming org.apache.cordova.core.media-capture to org.apache.cordova.media-capture and updating dependency
-* Rename CHANGELOG.md -> RELEASENOTES.md
-* [CB-4847] iOS 7 microphone access requires user permission - if denied, CDVCapture, CDVSound does not handle it properly
-* [CB-4826] Fix warning using UITextAlignmentCenter
-* [CB-4826] Fix XCode 5 capture plugin warnings
-* [CB-4488] - added manual capture test
-* [CB-4764] Remove reference to DirectoryManager from Capture.java
-* [CB-4763] Use own version of FileHelper.
-* [CB-4752] Incremented plugin version on dev branch.
-
-### 0.2.3 (Oct 9, 2013)
-* CB-4720: fixed incorrect feature tag in plugin.xml for wp
-* [CB-4915] Incremented plugin version on dev branch.
-
- ### 0.2.4 (Oct 28, 2013)
-* CB-5199 - ios - Media Capture - UI issues under iOS 7
-* CB-5128: added repo + issue tag to plugin.xml for media capture plugin
-* [CB-5010] Incremented plugin version on dev branch.
-
-### 0.2.5 (Dec 4, 2013)
-* add ubuntu platform
-* Added amazon-fireos platform. Change to use amazon-fireos as a platform if user agent string contains 'cordova-amazon-fireos'
-* CB-5291 - ios - Media Capture Audio - status bar issues under iOS 7
-* CB-5275: CaptureImage and CaptureVideo have runnables and CaptureVideo works on 4.2. Still doesn't work for 4.3
-
-### 0.2.6 (Jan 02, 2014)
-* CB-5658 Add doc/index.md for Media Capture plugin
-* CB-5569 Windows8. MediaFile constructor does not exist
-* CB-5517 Fix the audio capture IO exception by putting it in a runnable
-
-### 0.2.7 (Feb 05, 2014)
-* [ubuntu] request audio/camera/microphone permission
-* fixed cordova cli add capture plugin not work wp
-* CB-5685 [BlackBerry10] Add access_shared permission
-
-### 0.2.8 (Feb 26, 2014)
-* CB-5202 Fix video capture crash on Android 4.3+
-
-### 0.3.0 (Apr 17, 2014)
-* CB-6152: [ios, android] Make mediafile compatible with file plugin
-* CB-6385: Specify file plugin dependency version
-* CB-6212: [iOS] fix warnings compiled under arm64 64-bit
-* CB-6016 [BlackBerry10] Add audio capture capability
-* [Blackberry10] Add rim xml namespaces declaration
-* CB-6422 [windows8] use cordova/exec/proxy
-* CB-6460: Update license headers
-* Add NOTICE file
diff --git a/doc/index.md b/doc/index.md
deleted file mode 100644
index ed682f3..0000000
--- a/doc/index.md
+++ /dev/null
@@ -1,593 +0,0 @@
-<!---
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-
-# org.apache.cordova.media-capture
-
-This plugin provides access to the device's audio, image, and video capture capabilities.
-
-__WARNING__: Collection and use of images, video, or
-audio from the device's camera or microphone raises important privacy
-issues. Your app's privacy policy should discuss how the app uses
-such sensors and whether the data recorded is shared with any other
-parties. In addition, if the app's use of the camera or microphone is
-not apparent in the user interface, you should provide a just-in-time
-notice before the app accesses the camera or microphone (if the
-device operating system doesn't do so already). That notice should
-provide the same information noted above, as well as obtaining the
-user's permission (e.g., by presenting choices for __OK__ and __No
-Thanks__). Note that some app marketplaces may require your app to
-provide just-in-time notice and obtain permission from the user prior
-to accessing the camera or microphone. For more information, please
-see the Privacy Guide.
-
-## Installation
-
- cordova plugin add org.apache.cordova.media-capture
-
-## Supported Platforms
-
-- Amazon Fire OS
-- Android
-- BlackBerry 10
-- iOS
-- Windows Phone 7 and 8
-- Windows 8
-
-## Objects
-
-- Capture
-- CaptureAudioOptions
-- CaptureImageOptions
-- CaptureVideoOptions
-- CaptureCallback
-- CaptureErrorCB
-- ConfigurationData
-- MediaFile
-- MediaFileData
-
-## Methods
-
-- capture.captureAudio
-- capture.captureImage
-- capture.captureVideo
-- MediaFile.getFormatData
-
-## Properties
-
-- __supportedAudioModes__: The audio recording formats supported by the device. (ConfigurationData[])
-
-- __supportedImageModes__: The recording image sizes and formats supported by the device. (ConfigurationData[])
-
-- __supportedVideoModes__: The recording video resolutions and formats supported by the device. (ConfigurationData[])
-
-## capture.captureAudio
-
-> Start the audio recorder application and return information about captured audio clip files.
-
- navigator.device.capture.captureAudio(
- CaptureCB captureSuccess, CaptureErrorCB captureError, [CaptureAudioOptions options]
- );
-
-### Description
-
-Starts an asynchronous operation to capture audio recordings using the
-device's default audio recording application. The operation allows
-the device user to capture multiple recordings in a single session.
-
-The capture operation ends when either the user exits the audio
-recording application, or the maximum number of recordings specified
-by `CaptureAudioOptions.limit` is reached. If no `limit` parameter
-value is specified, it defaults to one (1), and the capture operation
-terminates after the user records a single audio clip.
-
-When the capture operation finishes, the `CaptureCallback` executes
-with an array of `MediaFile` objects describing each captured audio
-clip file. If the user terminates the operation before an audio clip
-is captured, the `CaptureErrorCallback` executes with a `CaptureError`
-object, featuring the `CaptureError.CAPTURE_NO_MEDIA_FILES` error
-code.
-
-### Supported Platforms
-
-- Amazon Fire OS
-- Android
-- BlackBerry 10
-- iOS
-- Windows Phone 7 and 8
-- Windows 8
-
-### Example
-
- // capture callback
- var captureSuccess = function(mediaFiles) {
- var i, path, len;
- for (i = 0, len = mediaFiles.length; i < len; i += 1) {
- path = mediaFiles[i].fullPath;
- // do something interesting with the file
- }
- };
-
- // capture error callback
- var captureError = function(error) {
- navigator.notification.alert('Error code: ' + error.code, null, 'Capture Error');
- };
-
- // start audio capture
- navigator.device.capture.captureAudio(captureSuccess, captureError, {limit:2});
-
-### iOS Quirks
-
-- iOS does not have a default audio recording application, so a simple user interface is provided.
-
-### Windows Phone 7 and 8 Quirks
-
-- Windows Phone 7 does not have a default audio recording application, so a simple user interface is provided.
-
-## CaptureAudioOptions
-
-> Encapsulates audio capture configuration options.
-
-### Properties
-
-- __limit__: The maximum number of audio clips the device user can record in a single capture operation. The value must be greater than or equal to 1 (defaults to 1).
-
-- __duration__: The maximum duration of an audio sound clip, in seconds.
-
-### Example
-
- // limit capture operation to 3 media files, no longer than 10 seconds each
- var options = { limit: 3, duration: 10 };
-
- navigator.device.capture.captureAudio(captureSuccess, captureError, options);
-
-### Amazon Fire OS Quirks
-
-- The `duration` parameter is not supported. Recording lengths cannot be limited programmatically.
-
-### Android Quirks
-
-- The `duration` parameter is not supported. Recording lengths can't be limited programmatically.
-
-### BlackBerry 10 Quirks
-
-- The `duration` parameter is not supported. Recording lengths can't be limited programmatically.
-- The `limit` parameter is not supported, so only one recording can be created for each invocation.
-
-### iOS Quirks
-
-- The `limit` parameter is not supported, so only one recording can be created for each invocation.
-
-## capture.captureImage
-
-> Start the camera application and return information about captured image files.
-
- navigator.device.capture.captureImage(
- CaptureCB captureSuccess, CaptureErrorCB captureError, [CaptureImageOptions options]
- );
-
-### Description
-
-Starts an asynchronous operation to capture images using the device's
-camera application. The operation allows users to capture more than
-one image in a single session.
-
-The capture operation ends either when the user closes the camera
-application, or the maximum number of recordings specified by
-`CaptureAudioOptions.limit` is reached. If no `limit` value is
-specified, it defaults to one (1), and the capture operation
-terminates after the user captures a single image.
-
-When the capture operation finishes, it invokes the `CaptureCB`
-callback with an array of `MediaFile` objects describing each captured
-image file. If the user terminates the operation before capturing an
-image, the `CaptureErrorCB` callback executes with a `CaptureError`
-object featuring a `CaptureError.CAPTURE_NO_MEDIA_FILES` error code.
-
-### Supported Platforms
-
-- Amazon Fire OS
-- Android
-- BlackBerry 10
-- iOS
-- Windows Phone 7 and 8
-- Windows 8
-
-### Windows Phone 7 Quirks
-
-Invoking the native camera application while your device is connected
-via Zune does not work, and the error callback executes.
-
-### Example
-
- // capture callback
- var captureSuccess = function(mediaFiles) {
- var i, path, len;
- for (i = 0, len = mediaFiles.length; i < len; i += 1) {
- path = mediaFiles[i].fullPath;
- // do something interesting with the file
- }
- };
-
- // capture error callback
- var captureError = function(error) {
- navigator.notification.alert('Error code: ' + error.code, null, 'Capture Error');
- };
-
- // start image capture
- navigator.device.capture.captureImage(captureSuccess, captureError, {limit:2});
-
-
-
-## CaptureImageOptions
-
-> Encapsulates image capture configuration options.
-
-### Properties
-
-- __limit__: The maximum number of images the user can capture in a single capture operation. The value must be greater than or equal to 1 (defaults to 1).
-
-### Example
-
- // limit capture operation to 3 images
- var options = { limit: 3 };
-
- navigator.device.capture.captureImage(captureSuccess, captureError, options);
-
-### iOS Quirks
-
-- The __limit__ parameter is not supported, and only one image is taken per invocation.
-
-## capture.captureVideo
-
-> Start the video recorder application and return information about captured video clip files.
-
- navigator.device.capture.captureVideo(
- CaptureCB captureSuccess, CaptureErrorCB captureError, [CaptureVideoOptions options]
- );
-
-### Description
-
-Starts an asynchronous operation to capture video recordings using the
-device's video recording application. The operation allows the user
-to capture more than one recordings in a single session.
-
-The capture operation ends when either the user exits the video
-recording application, or the maximum number of recordings specified
-by `CaptureVideoOptions.limit` is reached. If no `limit` parameter
-value is specified, it defaults to one (1), and the capture operation
-terminates after the user records a single video clip.
-
-When the capture operation finishes, it the `CaptureCB` callback
-executes with an array of `MediaFile` objects describing each captured
-video clip file. If the user terminates the operation before
-capturing a video clip, the `CaptureErrorCB` callback executes with a
-`CaptureError` object featuring a
-`CaptureError.CAPTURE_NO_MEDIA_FILES` error code.
-
-### Supported Platforms
-
-- Amazon Fire OS
-- Android
-- BlackBerry 10
-- iOS
-- Windows Phone 7 and 8
-- Windows 8
-
-### Example
-
- // capture callback
- var captureSuccess = function(mediaFiles) {
- var i, path, len;
- for (i = 0, len = mediaFiles.length; i < len; i += 1) {
- path = mediaFiles[i].fullPath;
- // do something interesting with the file
- }
- };
-
- // capture error callback
- var captureError = function(error) {
- navigator.notification.alert('Error code: ' + error.code, null, 'Capture Error');
- };
-
- // start video capture
- navigator.device.capture.captureVideo(captureSuccess, captureError, {limit:2});
-
-
-### BlackBerry 10 Quirks
-
-- Cordova for BlackBerry 10 attempts to launch the __Video Recorder__ application, provided by RIM, to capture video recordings. The app receives a `CaptureError.CAPTURE_NOT_SUPPORTED` error code if the application is not installed on the device.
-
-
-## CaptureVideoOptions
-
-> Encapsulates video capture configuration options.
-
-### Properties
-
-- __limit__: The maximum number of video clips the device's user can capture in a single capture operation. The value must be greater than or equal to 1 (defaults to 1).
-
-- __duration__: The maximum duration of a video clip, in seconds.
-
-### Example
-
- // limit capture operation to 3 video clips
- var options = { limit: 3 };
-
- navigator.device.capture.captureVideo(captureSuccess, captureError, options);
-
-### BlackBerry 10 Quirks
-
-- The __duration__ parameter is not supported, so the length of recordings can't be limited programmatically.
-
-### iOS Quirks
-
-- The __limit__ parameter is not supported. Only one video is recorded per invocation.
-
-
-## CaptureCB
-
-> Invoked upon a successful media capture operation.
-
- function captureSuccess( MediaFile[] mediaFiles ) { ... };
-
-### Description
-
-This function executes after a successful capture operation completes.
-At this point a media file has been captured, and either the user has
-exited the media capture application, or the capture limit has been
-reached.
-
-Each `MediaFile` object describes a captured media file.
-
-### Example
-
- // capture callback
- function captureSuccess(mediaFiles) {
- var i, path, len;
- for (i = 0, len = mediaFiles.length; i < len; i += 1) {
- path = mediaFiles[i].fullPath;
- // do something interesting with the file
- }
- };
-
-## CaptureError
-
-> Encapsulates the error code resulting from a failed media capture operation.
-
-### Properties
-
-- __code__: One of the pre-defined error codes listed below.
-
-### Constants
-
-- `CaptureError.CAPTURE_INTERNAL_ERR`: The camera or microphone failed to capture image or sound.
-
-- `CaptureError.CAPTURE_APPLICATION_BUSY`: The camera or audio capture application is currently serving another capture request.
-
-- `CaptureError.CAPTURE_INVALID_ARGUMENT`: Invalid use of the API (e.g., the value of `limit` is less than one).
-
-- `CaptureError.CAPTURE_NO_MEDIA_FILES`: The user exits the camera or audio capture application before capturing anything.
-
-- `CaptureError.CAPTURE_NOT_SUPPORTED`: The requested capture operation is not supported.
-
-## CaptureErrorCB
-
-> Invoked if an error occurs during a media capture operation.
-
- function captureError( CaptureError error ) { ... };
-
-### Description
-
-This function executes if an error occurs when trying to launch a
-media capture operation. Failure scenarios include when the capture
-application is busy, a capture operation is already taking place, or
-the user cancels the operation before any media files are captured.
-
-This function executes with a `CaptureError` object containing an
-appropriate error `code`.
-
-### Example
-
- // capture error callback
- var captureError = function(error) {
- navigator.notification.alert('Error code: ' + error.code, null, 'Capture Error');
- };
-
-## ConfigurationData
-
-> Encapsulates a set of media capture parameters that a device supports.
-
-### Description
-
-Describes media capture modes supported by the device. The
-configuration data includes the MIME type, and capture dimensions for
-video or image capture.
-
-The MIME types should adhere to [RFC2046](http://www.ietf.org/rfc/rfc2046.txt). Examples:
-
-- `video/3gpp`
-- `video/quicktime`
-- `image/jpeg`
-- `audio/amr`
-- `audio/wav`
-
-### Properties
-
-- __type__: The ASCII-encoded lowercase string representing the media type. (DOMString)
-
-- __height__: The height of the image or video in pixels. The value is zero for sound clips. (Number)
-
-- __width__: The width of the image or video in pixels. The value is zero for sound clips. (Number)
-
-### Example
-
- // retrieve supported image modes
- var imageModes = navigator.device.capture.supportedImageModes;
-
- // Select mode that has the highest horizontal resolution
- var width = 0;
- var selectedmode;
- for each (var mode in imageModes) {
- if (mode.width > width) {
- width = mode.width;
- selectedmode = mode;
- }
- }
-
-Not supported by any platform. All configuration data arrays are empty.
-
-## MediaFile.getFormatData
-
-> Retrieves format information about the media capture file.
-
- mediaFile.getFormatData(
- MediaFileDataSuccessCB successCallback,
- [MediaFileDataErrorCB errorCallback]
- );
-
-### Description
-
-This function asynchronously attempts to retrieve the format
-information for the media file. If successful, it invokes the
-`MediaFileDataSuccessCB` callback with a `MediaFileData` object. If
-the attempt fails, this function invokes the `MediaFileDataErrorCB`
-callback.
-
-### Supported Platforms
-
-- Amazon Fire OS
-- Android
-- BlackBerry 10
-- iOS
-- Windows Phone 7 and 8
-- Windows 8
-
-### Amazon Fire OS Quirks
-
-The API to access media file format information is limited, so not all
-`MediaFileData` properties are supported.
-
-### BlackBerry 10 Quirks
-
-Does not provide an API for information about media files, so all
-`MediaFileData` objects return with default values.
-
-### Android Quirks
-
-The API to access media file format information is limited, so not all
-`MediaFileData` properties are supported.
-
-### iOS Quirks
-
-The API to access media file format information is limited, so not all
-`MediaFileData` properties are supported.
-
-## MediaFile
-
-> Encapsulates properties of a media capture file.
-
-### Properties
-
-- __name__: The name of the file, without path information. (DOMString)
-
-- __fullPath__: The full path of the file, including the name. (DOMString)
-
-- __type__: The file's mime type (DOMString)
-
-- __lastModifiedDate__: The date and time when the file was last modified. (Date)
-
-- __size__: The size of the file, in bytes. (Number)
-
-### Methods
-
-- __MediaFile.getFormatData__: Retrieves the format information of the media file.
-
-## MediaFileData
-
-> Encapsulates format information about a media file.
-
-### Properties
-
-- __codecs__: The actual format of the audio and video content. (DOMString)
-
-- __bitrate__: The average bitrate of the content. The value is zero for images. (Number)
-
-- __height__: The height of the image or video in pixels. The value is zero for audio clips. (Number)
-
-- __width__: The width of the image or video in pixels. The value is zero for audio clips. (Number)
-
-- __duration__: The length of the video or sound clip in seconds. The value is zero for images. (Number)
-
-### BlackBerry 10 Quirks
-
-No API provides format information for media files, so the
-`MediaFileData` object returned by `MediaFile.getFormatData` features
-the following default values:
-
-- __codecs__: Not supported, and returns `null`.
-
-- __bitrate__: Not supported, and returns zero.
-
-- __height__: Not supported, and returns zero.
-
-- __width__: Not supported, and returns zero.
-
-- __duration__: Not supported, and returns zero.
-
-### Amazon Fire OS Quirks
-
-Supports the following `MediaFileData` properties:
-
-- __codecs__: Not supported, and returns `null`.
-
-- __bitrate__: Not supported, and returns zero.
-
-- __height__: Supported: image and video files only.
-
-- __width__: Supported: image and video files only.
-
-- __duration__: Supported: audio and video files only
-
-### Android Quirks
-
-Supports the following `MediaFileData` properties:
-
-- __codecs__: Not supported, and returns `null`.
-
-- __bitrate__: Not supported, and returns zero.
-
-- __height__: Supported: image and video files only.
-
-- __width__: Supported: image and video files only.
-
-- __duration__: Supported: audio and video files only.
-
-### iOS Quirks
-
-Supports the following `MediaFileData` properties:
-
-- __codecs__: Not supported, and returns `null`.
-
-- __bitrate__: Supported on iOS4 devices for audio only. Returns zero for images and videos.
-
-- __height__: Supported: image and video files only.
-
-- __width__: Supported: image and video files only.
-
-- __duration__: Supported: audio and video files only.
diff --git a/plugin.xml b/plugin.xml
deleted file mode 100644
index 4260036..0000000
--- a/plugin.xml
+++ /dev/null
@@ -1,211 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-
-<plugin xmlns="http://apache.org/cordova/ns/plugins/1.0"
-xmlns:android="http://schemas.android.com/apk/res/android"
-xmlns:rim="http://www.blackberry.com/ns/widgets"
- id="org.apache.cordova.media-capture"
- version="0.3.1-dev">
- <name>Capture</name>
-
- <description>Cordova Media Capture Plugin</description>
- <license>Apache 2.0</license>
- <keywords>cordova,media,capture</keywords>
- <repo>https://git-wip-us.apache.org/repos/asf/cordova-plugin-media-capture.git</repo>
- <issue>https://issues.apache.org/jira/browse/CB/component/12320646</issue>
-
- <dependency id="org.apache.cordova.file" version="1.0.1" />
-
- <js-module src="www/CaptureAudioOptions.js" name="CaptureAudioOptions">
- <clobbers target="CaptureAudioOptions" />
- </js-module>
-
- <js-module src="www/CaptureImageOptions.js" name="CaptureImageOptions">
- <clobbers target="CaptureImageOptions" />
- </js-module>
-
- <js-module src="www/CaptureVideoOptions.js" name="CaptureVideoOptions">
- <clobbers target="CaptureVideoOptions" />
- </js-module>
-
- <js-module src="www/CaptureError.js" name="CaptureError">
- <clobbers target="CaptureError" />
- </js-module>
-
- <js-module src="www/MediaFileData.js" name="MediaFileData">
- <clobbers target="MediaFileData" />
- </js-module>
-
- <js-module src="www/MediaFile.js" name="MediaFile">
- <clobbers target="MediaFile" />
- </js-module>
-
- <js-module src="www/capture.js" name="capture">
- <clobbers target="navigator.device.capture" />
- </js-module>
-
- <!-- android -->
- <platform name="android">
- <config-file target="res/xml/config.xml" parent="/*">
- <feature name="Capture" >
- <param name="android-package" value="org.apache.cordova.mediacapture.Capture"/>
- </feature>
- </config-file>
-
- <config-file target="AndroidManifest.xml" parent="/*">
- <uses-permission android:name="android.permission.RECORD_AUDIO" />
- <uses-permission android:name="android.permission.RECORD_VIDEO"/>
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
- </config-file>
-
- <source-file src="src/android/Capture.java" target-dir="src/org/apache/cordova/mediacapture" />
- <source-file src="src/android/FileHelper.java" target-dir="src/org/apache/cordova/mediacapture" />
- </platform>
-
- <!-- amazon-fireos -->
- <platform name="amazon-fireos">
- <config-file target="res/xml/config.xml" parent="/*">
- <feature name="Capture" >
- <param name="android-package" value="org.apache.cordova.mediacapture.Capture"/>
- </feature>
- </config-file>
-
- <config-file target="AndroidManifest.xml" parent="/*">
- <uses-permission android:name="android.permission.RECORD_AUDIO" />
- <uses-permission android:name="android.permission.RECORD_VIDEO"/>
- <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
- </config-file>
-
- <source-file src="src/android/Capture.java" target-dir="src/org/apache/cordova/mediacapture" />
- <source-file src="src/android/FileHelper.java" target-dir="src/org/apache/cordova/mediacapture" />
- </platform>
-
-
- <!-- ubuntu -->
- <platform name="ubuntu">
- <header-file src="src/ubuntu/capture.h" />
- <source-file src="src/ubuntu/capture.cpp" />
-
- <resource-file src="src/ubuntu/back.png" />
- <resource-file src="src/ubuntu/MediaCaptureWidget.qml" />
- <resource-file src="src/ubuntu/shoot.png" />
- <resource-file src="src/ubuntu/microphone.png" />
- <resource-file src="src/ubuntu/record_on.png" />
- <resource-file src="src/ubuntu/record_off.png" />
- <resource-file src="src/ubuntu/toolbar-left.png" />
- <resource-file src="src/ubuntu/toolbar-middle.png" />
- <resource-file src="src/ubuntu/toolbar-right.png" />
- <config-file target="config.xml" parent="/*">
- <feature name="Capture">
- <param policy_group="audio" policy_version="1" />
- <param policy_group="camera" policy_version="1" />
- <param policy_group="microphone" policy_version="1" />
- </feature>
- </config-file>
- </platform>
-
- <!-- ios -->
- <platform name="ios">
- <config-file target="config.xml" parent="/*">
- <feature name="Capture">
- <param name="ios-package" value="CDVCapture" />
- </feature>
- </config-file>
- <header-file src="src/ios/CDVCapture.h" />
- <source-file src="src/ios/CDVCapture.m" />
- <resource-file src="src/ios/CDVCapture.bundle" />
-
- <framework src="CoreGraphics.framework" />
- <framework src="MobileCoreServices.framework" />
- </platform>
-
- <!-- blackberry10 -->
- <platform name="blackberry10">
- <source-file src="src/blackberry10/index.js" target-dir="Capture" />
- <config-file target="www/config.xml" parent="/widget">
- <feature name="media-capture" value="Capture"/>
- </config-file>
- <config-file target="www/config.xml" parent="/widget/rim:permissions">
- <rim:permit>access_shared</rim:permit>
- </config-file>
- </platform>
-
- <!-- wp7 -->
- <platform name="wp7">
- <config-file target="config.xml" parent="/*">
- <feature name="Capture">
- <param name="wp-package" value="Capture"/>
- </feature>
- </config-file>
-
- <config-file target="Properties/WMAppManifest.xml" parent="/Deployment/App/Capabilities">
- <Capability Name="ID_CAP_MEDIALIB"/>
- <Capability Name="ID_CAP_MICROPHONE"/>
- <Capability Name="ID_CAP_ISV_CAMERA" />
- </config-file>
-
- <source-file src="src/wp/Capture.cs" />
- <source-file src="src/wp/UI/AudioCaptureTask.cs" />
- <source-file src="src/wp/UI/AudioRecorder.xaml" />
- <source-file src="src/wp/UI/AudioRecorder.xaml.cs" />
- <source-file src="src/wp/UI/VideoCaptureTask.cs" />
- <source-file src="src/wp/UI/VideoRecorder.xaml" />
- <source-file src="src/wp/UI/VideoRecorder.xaml.cs" />
- </platform>
-
- <!-- wp8 -->
- <platform name="wp8">
- <config-file target="config.xml" parent="/*">
- <feature name="Capture">
- <param name="wp-package" value="Capture"/>
- </feature>
- </config-file>
-
- <config-file target="Properties/WMAppManifest.xml" parent="/Deployment/App/Capabilities">
- <Capability Name="ID_CAP_MEDIALIB_AUDIO"/>
- <Capability Name="ID_CAP_MEDIALIB_PHOTO"/>
- <Capability Name="ID_CAP_MEDIALIB_PLAYBACK"/>
- <Capability Name="ID_CAP_MICROPHONE"/>
- <Capability Name="ID_CAP_ISV_CAMERA" />
- </config-file>
-
- <source-file src="src/wp/Capture.cs" />
- <source-file src="src/wp/UI/AudioCaptureTask.cs" />
- <source-file src="src/wp/UI/AudioRecorder.xaml" />
- <source-file src="src/wp/UI/AudioRecorder.xaml.cs" />
- <source-file src="src/wp/UI/VideoCaptureTask.cs" />
- <source-file src="src/wp/UI/VideoRecorder.xaml" />
- <source-file src="src/wp/UI/VideoRecorder.xaml.cs" />
- </platform>
-
- <!-- windows8 -->
- <platform name="windows8">
-
- <js-module src="src/windows8/MediaFile.js" name="MediaFile2">
- <merges target="MediaFile" />
- </js-module>
-
- <js-module src="src/windows8/CaptureProxy.js" name="CaptureProxy">
- <merges target="" />
- </js-module>
-
- </platform>
-
-</plugin>
diff --git a/src/android/Capture.java b/src/android/Capture.java
deleted file mode 100644
index 65df61f..0000000
--- a/src/android/Capture.java
+++ /dev/null
@@ -1,511 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
-*/
-package org.apache.cordova.mediacapture;
-
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.OutputStream;
-
-import android.os.Build;
-
-import org.apache.cordova.file.FileUtils;
-import org.apache.cordova.file.LocalFilesystemURL;
-
-import org.apache.cordova.CallbackContext;
-import org.apache.cordova.CordovaPlugin;
-import org.apache.cordova.LOG;
-import org.apache.cordova.PluginResult;
-import org.json.JSONArray;
-import org.json.JSONException;
-import org.json.JSONObject;
-
-import android.app.Activity;
-import android.content.ContentValues;
-import android.content.Intent;
-import android.database.Cursor;
-import android.graphics.BitmapFactory;
-import android.media.MediaPlayer;
-import android.net.Uri;
-import android.os.Environment;
-import android.provider.MediaStore;
-import android.util.Log;
-
-public class Capture extends CordovaPlugin {
-
- private static final String VIDEO_3GPP = "video/3gpp";
- private static final String VIDEO_MP4 = "video/mp4";
- private static final String AUDIO_3GPP = "audio/3gpp";
- private static final String IMAGE_JPEG = "image/jpeg";
-
- private static final int CAPTURE_AUDIO = 0; // Constant for capture audio
- private static final int CAPTURE_IMAGE = 1; // Constant for capture image
- private static final int CAPTURE_VIDEO = 2; // Constant for capture video
- private static final String LOG_TAG = "Capture";
-
- private static final int CAPTURE_INTERNAL_ERR = 0;
-// private static final int CAPTURE_APPLICATION_BUSY = 1;
-// private static final int CAPTURE_INVALID_ARGUMENT = 2;
- private static final int CAPTURE_NO_MEDIA_FILES = 3;
-
- private CallbackContext callbackContext; // The callback context from which we were invoked.
- private long limit; // the number of pics/vids/clips to take
- private int duration; // optional max duration of video recording in seconds
- private JSONArray results; // The array of results to be returned to the user
- private int numPics; // Number of pictures before capture activity
-
- //private CordovaInterface cordova;
-
-// public void setContext(Context mCtx)
-// {
-// if (CordovaInterface.class.isInstance(mCtx))
-// cordova = (CordovaInterface) mCtx;
-// else
-// LOG.d(LOG_TAG, "ERROR: You must use the CordovaInterface for this to work correctly. Please implement it in your activity");
-// }
-
- @Override
- public boolean execute(String action, JSONArray args, CallbackContext callbackContext) throws JSONException {
- this.callbackContext = callbackContext;
- this.limit = 1;
- this.duration = 0;
- this.results = new JSONArray();
-
- JSONObject options = args.optJSONObject(0);
- if (options != null) {
- limit = options.optLong("limit", 1);
- duration = options.optInt("duration", 0);
- }
-
- if (action.equals("getFormatData")) {
- JSONObject obj = getFormatData(args.getString(0), args.getString(1));
- callbackContext.success(obj);
- return true;
- }
- else if (action.equals("captureAudio")) {
- this.captureAudio();
- }
- else if (action.equals("captureImage")) {
- this.captureImage();
- }
- else if (action.equals("captureVideo")) {
- this.captureVideo(duration);
- }
- else {
- return false;
- }
-
- return true;
- }
-
- /**
- * Provides the media data file data depending on it's mime type
- *
- * @param filePath path to the file
- * @param mimeType of the file
- * @return a MediaFileData object
- */
- private JSONObject getFormatData(String filePath, String mimeType) throws JSONException {
- Uri fileUrl = filePath.startsWith("file:") ? Uri.parse(filePath) : Uri.fromFile(new File(filePath));
- JSONObject obj = new JSONObject();
- // setup defaults
- obj.put("height", 0);
- obj.put("width", 0);
- obj.put("bitrate", 0);
- obj.put("duration", 0);
- obj.put("codecs", "");
-
- // If the mimeType isn't set the rest will fail
- // so let's see if we can determine it.
- if (mimeType == null || mimeType.equals("") || "null".equals(mimeType)) {
- mimeType = FileHelper.getMimeType(fileUrl, cordova);
- }
- Log.d(LOG_TAG, "Mime type = " + mimeType);
-
- if (mimeType.equals(IMAGE_JPEG) || filePath.endsWith(".jpg")) {
- obj = getImageData(fileUrl, obj);
- }
- else if (mimeType.endsWith(AUDIO_3GPP)) {
- obj = getAudioVideoData(filePath, obj, false);
- }
- else if (mimeType.equals(VIDEO_3GPP) || mimeType.equals(VIDEO_MP4)) {
- obj = getAudioVideoData(filePath, obj, true);
- }
- return obj;
- }
-
- /**
- * Get the Image specific attributes
- *
- * @param filePath path to the file
- * @param obj represents the Media File Data
- * @return a JSONObject that represents the Media File Data
- * @throws JSONException
- */
- private JSONObject getImageData(Uri fileUrl, JSONObject obj) throws JSONException {
- BitmapFactory.Options options = new BitmapFactory.Options();
- options.inJustDecodeBounds = true;
- BitmapFactory.decodeFile(fileUrl.getPath(), options);
- obj.put("height", options.outHeight);
- obj.put("width", options.outWidth);
- return obj;
- }
-
- /**
- * Get the Image specific attributes
- *
- * @param filePath path to the file
- * @param obj represents the Media File Data
- * @param video if true get video attributes as well
- * @return a JSONObject that represents the Media File Data
- * @throws JSONException
- */
- private JSONObject getAudioVideoData(String filePath, JSONObject obj, boolean video) throws JSONException {
- MediaPlayer player = new MediaPlayer();
- try {
- player.setDataSource(filePath);
- player.prepare();
- obj.put("duration", player.getDuration() / 1000);
- if (video) {
- obj.put("height", player.getVideoHeight());
- obj.put("width", player.getVideoWidth());
- }
- } catch (IOException e) {
- Log.d(LOG_TAG, "Error: loading video file");
- }
- return obj;
- }
-
- /**
- * Sets up an intent to capture audio. Result handled by onActivityResult()
- */
- private void captureAudio() {
- Intent intent = new Intent(android.provider.MediaStore.Audio.Media.RECORD_SOUND_ACTION);
-
- this.cordova.startActivityForResult((CordovaPlugin) this, intent, CAPTURE_AUDIO);
- }
-
- private String getTempDirectoryPath() {
- File cache = null;
-
- // Use internal storage
- cache = cordova.getActivity().getCacheDir();
-
- // Create the cache directory if it doesn't exist
- cache.mkdirs();
- return cache.getAbsolutePath();
- }
-
- /**
- * Sets up an intent to capture images. Result handled by onActivityResult()
- */
- private void captureImage() {
- // Save the number of images currently on disk for later
- this.numPics = queryImgDB(whichContentStore()).getCount();
-
- Intent intent = new Intent(android.provider.MediaStore.ACTION_IMAGE_CAPTURE);
-
- // Specify file so that large image is captured and returned
- File photo = new File(getTempDirectoryPath(), "Capture.jpg");
- intent.putExtra(android.provider.MediaStore.EXTRA_OUTPUT, Uri.fromFile(photo));
-
- this.cordova.startActivityForResult((CordovaPlugin) this, intent, CAPTURE_IMAGE);
- }
-
- /**
- * Sets up an intent to capture video. Result handled by onActivityResult()
- */
- private void captureVideo(int duration) {
- Intent intent = new Intent(android.provider.MediaStore.ACTION_VIDEO_CAPTURE);
-
- if(Build.VERSION.SDK_INT > 7){
- intent.putExtra("android.intent.extra.durationLimit", duration);
- }
- this.cordova.startActivityForResult((CordovaPlugin) this, intent, CAPTURE_VIDEO);
- }
-
- /**
- * Called when the video view exits.
- *
- * @param requestCode The request code originally supplied to startActivityForResult(),
- * allowing you to identify who this result came from.
- * @param resultCode The integer result code returned by the child activity through its setResult().
- * @param intent An Intent, which can return result data to the caller (various data can be attached to Intent "extras").
- * @throws JSONException
- */
- public void onActivityResult(int requestCode, int resultCode, final Intent intent) {
-
- // Result received okay
- if (resultCode == Activity.RESULT_OK) {
- // An audio clip was requested
- if (requestCode == CAPTURE_AUDIO) {
-
- final Capture that = this;
- Runnable captureAudio = new Runnable() {
-
- @Override
- public void run() {
- // Get the uri of the audio clip
- Uri data = intent.getData();
- // create a file object from the uri
- results.put(createMediaFile(data));
-
- if (results.length() >= limit) {
- // Send Uri back to JavaScript for listening to audio
- that.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, results));
- } else {
- // still need to capture more audio clips
- captureAudio();
- }
- }
- };
- this.cordova.getThreadPool().execute(captureAudio);
- } else if (requestCode == CAPTURE_IMAGE) {
- // For some reason if I try to do:
- // Uri data = intent.getData();
- // It crashes in the emulator and on my phone with a null pointer exception
- // To work around it I had to grab the code from CameraLauncher.java
-
- final Capture that = this;
- Runnable captureImage = new Runnable() {
- @Override
- public void run() {
- try {
- // TODO Auto-generated method stub
- // Create entry in media store for image
- // (Don't use insertImage() because it uses default compression setting of 50 - no way to change it)
- ContentValues values = new ContentValues();
- values.put(android.provider.MediaStore.Images.Media.MIME_TYPE, IMAGE_JPEG);
- Uri uri = null;
- try {
- uri = that.cordova.getActivity().getContentResolver().insert(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, values);
- } catch (UnsupportedOperationException e) {
- LOG.d(LOG_TAG, "Can't write to external media storage.");
- try {
- uri = that.cordova.getActivity().getContentResolver().insert(android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI, values);
- } catch (UnsupportedOperationException ex) {
- LOG.d(LOG_TAG, "Can't write to internal media storage.");
- that.fail(createErrorObject(CAPTURE_INTERNAL_ERR, "Error capturing image - no media storage found."));
- return;
- }
- }
- FileInputStream fis = new FileInputStream(getTempDirectoryPath() + "/Capture.jpg");
- OutputStream os = that.cordova.getActivity().getContentResolver().openOutputStream(uri);
- byte[] buffer = new byte[4096];
- int len;
- while ((len = fis.read(buffer)) != -1) {
- os.write(buffer, 0, len);
- }
- os.flush();
- os.close();
- fis.close();
-
- // Add image to results
- results.put(createMediaFile(uri));
-
- checkForDuplicateImage();
-
- if (results.length() >= limit) {
- // Send Uri back to JavaScript for viewing image
- that.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, results));
- } else {
- // still need to capture more images
- captureImage();
- }
- } catch (IOException e) {
- e.printStackTrace();
- that.fail(createErrorObject(CAPTURE_INTERNAL_ERR, "Error capturing image."));
- }
- }
- };
- this.cordova.getThreadPool().execute(captureImage);
- } else if (requestCode == CAPTURE_VIDEO) {
-
- final Capture that = this;
- Runnable captureVideo = new Runnable() {
-
- @Override
- public void run() {
-
- Uri data = null;
-
- if (intent != null){
- // Get the uri of the video clip
- data = intent.getData();
- }
-
- if( data == null){
- File movie = new File(getTempDirectoryPath(), "Capture.avi");
- data = Uri.fromFile(movie);
- }
-
- // create a file object from the uri
- if(data == null)
- {
- that.fail(createErrorObject(CAPTURE_NO_MEDIA_FILES, "Error: data is null"));
- }
- else
- {
- results.put(createMediaFile(data));
-
- if (results.length() >= limit) {
- // Send Uri back to JavaScript for viewing video
- that.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, results));
- } else {
- // still need to capture more video clips
- captureVideo(duration);
- }
- }
- }
- };
- this.cordova.getThreadPool().execute(captureVideo);
- }
- }
- // If canceled
- else if (resultCode == Activity.RESULT_CANCELED) {
- // If we have partial results send them back to the user
- if (results.length() > 0) {
- this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, results));
- }
- // user canceled the action
- else {
- this.fail(createErrorObject(CAPTURE_NO_MEDIA_FILES, "Canceled."));
- }
- }
- // If something else
- else {
- // If we have partial results send them back to the user
- if (results.length() > 0) {
- this.callbackContext.sendPluginResult(new PluginResult(PluginResult.Status.OK, results));
- }
- // something bad happened
- else {
- this.fail(createErrorObject(CAPTURE_NO_MEDIA_FILES, "Did not complete!"));
- }
- }
- }
-
- /**
- * Creates a JSONObject that represents a File from the Uri
- *
- * @param data the Uri of the audio/image/video
- * @return a JSONObject that represents a File
- * @throws IOException
- */
- private JSONObject createMediaFile(Uri data) {
- File fp = webView.getResourceApi().mapUriToFile(data);
- JSONObject obj = new JSONObject();
-
- FileUtils filePlugin = (FileUtils)webView.pluginManager.getPlugin("File");
- LocalFilesystemURL url = filePlugin.filesystemURLforLocalPath(fp.getAbsolutePath());
-
- try {
- // File properties
- obj.put("name", fp.getName());
- obj.put("fullPath", fp.toURI().toString());
- if (url != null) {
- obj.put("localURL", url.toString());
- }
- // Because of an issue with MimeTypeMap.getMimeTypeFromExtension() all .3gpp files
- // are reported as video/3gpp. I'm doing this hacky check of the URI to see if it
- // is stored in the audio or video content store.
- if (fp.getAbsoluteFile().toString().endsWith(".3gp") || fp.getAbsoluteFile().toString().endsWith(".3gpp")) {
- if (data.toString().contains("/audio/")) {
- obj.put("type", AUDIO_3GPP);
- } else {
- obj.put("type", VIDEO_3GPP);
- }
- } else {
- obj.put("type", FileHelper.getMimeType(Uri.fromFile(fp), cordova));
- }
-
- obj.put("lastModifiedDate", fp.lastModified());
- obj.put("size", fp.length());
- } catch (JSONException e) {
- // this will never happen
- e.printStackTrace();
- }
- return obj;
- }
-
- private JSONObject createErrorObject(int code, String message) {
- JSONObject obj = new JSONObject();
- try {
- obj.put("code", code);
- obj.put("message", message);
- } catch (JSONException e) {
- // This will never happen
- }
- return obj;
- }
-
- /**
- * Send error message to JavaScript.
- *
- * @param err
- */
- public void fail(JSONObject err) {
- this.callbackContext.error(err);
- }
-
-
- /**
- * Creates a cursor that can be used to determine how many images we have.
- *
- * @return a cursor
- */
- private Cursor queryImgDB(Uri contentStore) {
- return this.cordova.getActivity().getContentResolver().query(
- contentStore,
- new String[] { MediaStore.Images.Media._ID },
- null,
- null,
- null);
- }
-
- /**
- * Used to find out if we are in a situation where the Camera Intent adds to images
- * to the content store.
- */
- private void checkForDuplicateImage() {
- Uri contentStore = whichContentStore();
- Cursor cursor = queryImgDB(contentStore);
- int currentNumOfImages = cursor.getCount();
-
- // delete the duplicate file if the difference is 2
- if ((currentNumOfImages - numPics) == 2) {
- cursor.moveToLast();
- int id = Integer.valueOf(cursor.getString(cursor.getColumnIndex(MediaStore.Images.Media._ID))) - 1;
- Uri uri = Uri.parse(contentStore + "/" + id);
- this.cordova.getActivity().getContentResolver().delete(uri, null, null);
- }
- }
-
- /**
- * Determine if we are storing the images in internal or external storage
- * @return Uri
- */
- private Uri whichContentStore() {
- if (Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED)) {
- return android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI;
- } else {
- return android.provider.MediaStore.Images.Media.INTERNAL_CONTENT_URI;
- }
- }
-}
diff --git a/src/android/FileHelper.java b/src/android/FileHelper.java
deleted file mode 100644
index 267ad53..0000000
--- a/src/android/FileHelper.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
- */
-package org.apache.cordova.mediacapture;
-
-import android.net.Uri;
-import android.webkit.MimeTypeMap;
-
-import org.apache.cordova.CordovaInterface;
-
-import java.util.Locale;
-
-// TODO: Replace with CordovaResourceApi.getMimeType() post 3.1.
-public class FileHelper {
- public static String getMimeTypeForExtension(String path) {
- String extension = path;
- int lastDot = extension.lastIndexOf('.');
- if (lastDot != -1) {
- extension = extension.substring(lastDot + 1);
- }
- // Convert the URI string to lower case to ensure compatibility with MimeTypeMap (see CB-2185).
- extension = extension.toLowerCase(Locale.getDefault());
- if (extension.equals("3ga")) {
- return "audio/3gpp";
- }
- return MimeTypeMap.getSingleton().getMimeTypeFromExtension(extension);
- }
-
- /**
- * Returns the mime type of the data specified by the given URI string.
- *
- * @param uriString the URI string of the data
- * @return the mime type of the specified data
- */
- public static String getMimeType(Uri uri, CordovaInterface cordova) {
- String mimeType = null;
- if ("content".equals(uri.getScheme())) {
- mimeType = cordova.getActivity().getContentResolver().getType(uri);
- } else {
- mimeType = getMimeTypeForExtension(uri.getPath());
- }
-
- return mimeType;
- }
-}
diff --git a/src/blackberry10/index.js b/src/blackberry10/index.js
deleted file mode 100644
index ea78137..0000000
--- a/src/blackberry10/index.js
+++ /dev/null
@@ -1,116 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-//cordova-js/lib/common/plugin/CaptureError.js
-var INTERNAL_ERROR_CODE = 0,
- APPLICATION_BUSY_ERROR_CODE = 1,
- INVALID_ARGUMENT_ERROR_CODE = 2,
- NO_MEDIA_FILES_ERROR_CODE = 3,
- NOT_SUPPORTED_ERROR_CODE = 20;
-
-function capture(action, options, result, webview) {
- var noop = function () {},
- limit = options.limit || 1,
- fail = function (error) {
- result.callbackError({code: INTERNAL_ERROR_CODE});
- },
- onCaptured = function (path) {
- var sb = webview.setFileSystemSandbox;
- webview.setFileSystemSandbox = false;
- window.webkitRequestFileSystem(window.PERSISTENT, 1024, function (fs) {
- fs.root.getFile(path, {}, function (fe) {
- fe.file(function (file) {
- file.fullPath = fe.fullPath;
- webview.setFileSystemSandbox = sb;
- result.callbackOk([file]);
- }, fail);
- }, fail);
- }, fail);
- },
- onAudioCaptured = function (response) {
- window.qnx.webplatform.getApplication().invocation.removeEventListener("childCardClosed", onAudioCaptured);
- if (response.data && response.data !== "") {
- onCaptured(response.data);
- } else {
- result.callbackError({code: NO_MEDIA_FILES_ERROR_CODE });
- }
- }
- onCancelled = function () {
- result.callbackError({code: NO_MEDIA_FILES_ERROR_CODE });
- },
- onInvoked = function (error) {
- if (error) {
- result.callbackError({code: APPLICATION_BUSY_ERROR_CODE});
- }
- };
-
- if (limit < 0) {
- result.error({code: INVALID_ARGUMENT_ERROR_CODE});
- } else if (action === "audio") {
- window.qnx.webplatform.getApplication().invocation.invoke(
- {
- target: "sys.apps.audiorecorder",
- action: "bb.action.CAPTURE"
- },
- function (error) {
- if (error) {
- console.log(error);
- } else {
- window.qnx.webplatform.getApplication().invocation.addEventListener("childCardClosed", onAudioCaptured);
- }
- });
- result.noResult(true);
- } else {
- window.qnx.webplatform.getApplication().cards.camera.open(action, onCaptured, onCancelled, onInvoked);
- result.noResult(true);
- }
-}
-
-module.exports = {
- getSupportedAudioModes: function (success, fail, args, env) {
- var result = new PluginResult(args, env);
- result.ok([]);
- },
- getSupportedImageModes: function (win, fail, args, env) {
- var result = new PluginResult(args, env);
- result.ok([]);
- },
- getSupportedVideoModes: function (win, fail, args, env) {
- var result = new PluginResult(args, env);
- result.ok([]);
- },
- captureImage: function (win, fail, args, env) {
- var result = new PluginResult(args, env),
- options = args[0] === "undefined" ? {} : JSON.parse(decodeURIComponent(args[0]));
-
- capture("photo", options, result, env.webview);
- },
- captureVideo: function (win, fail, args, env) {
- var result = new PluginResult(args, env),
- options = args[0] === "undefined" ? {} : JSON.parse(decodeURIComponent(args[0]));
-
- capture("video", options, result, env.webview);
- },
- captureAudio: function (win, fail, args, env) {
- var result = new PluginResult(args, env);
- capture("audio", {}, result, env.webview);
- }
-};
diff --git a/src/ios/CDVCapture.bundle/controls_bg.png b/src/ios/CDVCapture.bundle/controls_bg.png
deleted file mode 100644
index 784e9c7..0000000
--- a/src/ios/CDVCapture.bundle/controls_bg.png
+++ /dev/null
Binary files differ
diff --git a/src/ios/CDVCapture.bundle/controls_bg@2x.png b/src/ios/CDVCapture.bundle/controls_bg@2x.png
deleted file mode 100644
index 1e28c6d..0000000
--- a/src/ios/CDVCapture.bundle/controls_bg@2x.png
+++ /dev/null
Binary files differ
diff --git a/src/ios/CDVCapture.bundle/controls_bg@2x~ipad.png b/src/ios/CDVCapture.bundle/controls_bg@2x~ipad.png
deleted file mode 100644
index d4e3483..0000000
--- a/src/ios/CDVCapture.bundle/controls_bg@2x~ipad.png
+++ /dev/null
Binary files differ
diff --git a/src/ios/CDVCapture.bundle/controls_bg~ipad.png b/src/ios/CDVCapture.bundle/controls_bg~ipad.png
deleted file mode 100644
index efbef8a..0000000
--- a/src/ios/CDVCapture.bundle/controls_bg~ipad.png
+++ /dev/null
Binary files differ
diff --git a/src/ios/CDVCapture.bundle/microphone-568h@2x~iphone.png b/src/ios/CDVCapture.bundle/microphone-568h@2x~iphone.png
deleted file mode 100644
index 8e80f73..0000000
--- a/src/ios/CDVCapture.bundle/microphone-568h@2x~iphone.png
+++ /dev/null
Binary files differ
diff --git a/src/ios/CDVCapture.bundle/microphone.png b/src/ios/CDVCapture.bundle/microphone.png
deleted file mode 100644
index 155b88c..0000000
--- a/src/ios/CDVCapture.bundle/microphone.png
+++ /dev/null
Binary files differ
diff --git a/src/ios/CDVCapture.bundle/microphone@2x.png b/src/ios/CDVCapture.bundle/microphone@2x.png
deleted file mode 100644
index 79ef16b..0000000
--- a/src/ios/CDVCapture.bundle/microphone@2x.png
+++ /dev/null
Binary files differ
diff --git a/src/ios/CDVCapture.bundle/microphone@2x~ipad.png b/src/ios/CDVCapture.bundle/microphone@2x~ipad.png
deleted file mode 100644
index af1bbb2..0000000
--- a/src/ios/CDVCapture.bundle/microphone@2x~ipad.png
+++ /dev/null
Binary files differ
diff --git a/src/ios/CDVCapture.bundle/microphone~ipad.png b/src/ios/CDVCapture.bundle/microphone~ipad.png
deleted file mode 100644
index ef1c472..0000000
--- a/src/ios/CDVCapture.bundle/microphone~ipad.png
+++ /dev/null
Binary files differ
diff --git a/src/ios/CDVCapture.bundle/record_button.png b/src/ios/CDVCapture.bundle/record_button.png
deleted file mode 100644
index ceb9589..0000000
--- a/src/ios/CDVCapture.bundle/record_button.png
+++ /dev/null
Binary files differ
diff --git a/src/ios/CDVCapture.bundle/record_button@2x.png b/src/ios/CDVCapture.bundle/record_button@2x.png
deleted file mode 100644
index d6ce302..0000000
--- a/src/ios/CDVCapture.bundle/record_button@2x.png
+++ /dev/null
Binary files differ
diff --git a/src/ios/CDVCapture.bundle/record_button@2x~ipad.png b/src/ios/CDVCapture.bundle/record_button@2x~ipad.png
deleted file mode 100644
index 0ac2e67..0000000
--- a/src/ios/CDVCapture.bundle/record_button@2x~ipad.png
+++ /dev/null
Binary files differ
diff --git a/src/ios/CDVCapture.bundle/record_button~ipad.png b/src/ios/CDVCapture.bundle/record_button~ipad.png
deleted file mode 100644
index d8e24a4..0000000
--- a/src/ios/CDVCapture.bundle/record_button~ipad.png
+++ /dev/null
Binary files differ
diff --git a/src/ios/CDVCapture.bundle/recording_bg.png b/src/ios/CDVCapture.bundle/recording_bg.png
deleted file mode 100644
index bafc087..0000000
--- a/src/ios/CDVCapture.bundle/recording_bg.png
+++ /dev/null
Binary files differ
diff --git a/src/ios/CDVCapture.bundle/recording_bg@2x.png b/src/ios/CDVCapture.bundle/recording_bg@2x.png
deleted file mode 100644
index 798490b..0000000
--- a/src/ios/CDVCapture.bundle/recording_bg@2x.png
+++ /dev/null
Binary files differ
diff --git a/src/ios/CDVCapture.bundle/recording_bg@2x~ipad.png b/src/ios/CDVCapture.bundle/recording_bg@2x~ipad.png
deleted file mode 100644
index a1b7208..0000000
--- a/src/ios/CDVCapture.bundle/recording_bg@2x~ipad.png
+++ /dev/null
Binary files differ
diff --git a/src/ios/CDVCapture.bundle/recording_bg~ipad.png b/src/ios/CDVCapture.bundle/recording_bg~ipad.png
deleted file mode 100644
index 3b467f6..0000000
--- a/src/ios/CDVCapture.bundle/recording_bg~ipad.png
+++ /dev/null
Binary files differ
diff --git a/src/ios/CDVCapture.bundle/stop_button.png b/src/ios/CDVCapture.bundle/stop_button.png
deleted file mode 100644
index 9c31838..0000000
--- a/src/ios/CDVCapture.bundle/stop_button.png
+++ /dev/null
Binary files differ
diff --git a/src/ios/CDVCapture.bundle/stop_button@2x.png b/src/ios/CDVCapture.bundle/stop_button@2x.png
deleted file mode 100644
index 8cf657e..0000000
--- a/src/ios/CDVCapture.bundle/stop_button@2x.png
+++ /dev/null
Binary files differ
diff --git a/src/ios/CDVCapture.bundle/stop_button@2x~ipad.png b/src/ios/CDVCapture.bundle/stop_button@2x~ipad.png
deleted file mode 100644
index 88b606c..0000000
--- a/src/ios/CDVCapture.bundle/stop_button@2x~ipad.png
+++ /dev/null
Binary files differ
diff --git a/src/ios/CDVCapture.bundle/stop_button~ipad.png b/src/ios/CDVCapture.bundle/stop_button~ipad.png
deleted file mode 100644
index 59bb7a5..0000000
--- a/src/ios/CDVCapture.bundle/stop_button~ipad.png
+++ /dev/null
Binary files differ
diff --git a/src/ios/CDVCapture.h b/src/ios/CDVCapture.h
deleted file mode 100644
index 2cd8db8..0000000
--- a/src/ios/CDVCapture.h
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
- */
-
-#import <Foundation/Foundation.h>
-#import <MobileCoreServices/MobileCoreServices.h>
-#import <AVFoundation/AVFoundation.h>
-#import <Cordova/CDVPlugin.h>
-#import "CDVFile.h"
-
-enum CDVCaptureError {
- CAPTURE_INTERNAL_ERR = 0,
- CAPTURE_APPLICATION_BUSY = 1,
- CAPTURE_INVALID_ARGUMENT = 2,
- CAPTURE_NO_MEDIA_FILES = 3,
- CAPTURE_NOT_SUPPORTED = 20
-};
-typedef NSUInteger CDVCaptureError;
-
-@interface CDVImagePicker : UIImagePickerController
-{
- NSString* callbackid;
- NSInteger quality;
- NSString* mimeType;
-}
-@property (assign) NSInteger quality;
-@property (copy) NSString* callbackId;
-@property (copy) NSString* mimeType;
-
-@end
-
-@interface CDVCapture : CDVPlugin <UIImagePickerControllerDelegate, UINavigationControllerDelegate>
-{
- CDVImagePicker* pickerController;
- BOOL inUse;
-}
-@property BOOL inUse;
-- (void)captureAudio:(CDVInvokedUrlCommand*)command;
-- (void)captureImage:(CDVInvokedUrlCommand*)command;
-- (CDVPluginResult*)processImage:(UIImage*)image type:(NSString*)mimeType forCallbackId:(NSString*)callbackId;
-- (void)captureVideo:(CDVInvokedUrlCommand*)command;
-- (CDVPluginResult*)processVideo:(NSString*)moviePath forCallbackId:(NSString*)callbackId;
-- (void)getMediaModes:(CDVInvokedUrlCommand*)command;
-- (void)getFormatData:(CDVInvokedUrlCommand*)command;
-- (NSDictionary*)getMediaDictionaryFromPath:(NSString*)fullPath ofType:(NSString*)type;
-- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info;
-- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingImage:(UIImage*)image editingInfo:(NSDictionary*)editingInfo;
-- (void)imagePickerControllerDidCancel:(UIImagePickerController*)picker;
-
-@end
-
-@interface CDVAudioNavigationController : UINavigationController
-
-@end
-
-/* AudioRecorderViewController is used to create a simple view for audio recording.
- * It is created from [Capture captureAudio]. It creates a very simple interface for
- * recording by presenting just a record/stop button and a Done button to close the view.
- * The recording time is displayed and recording for a specified duration is supported. When duration
- * is specified there is no UI to the user - recording just stops when the specified
- * duration is reached. The UI has been minimized to avoid localization.
- */
-@interface CDVAudioRecorderViewController : UIViewController <AVAudioRecorderDelegate>
-{
- CDVCaptureError errorCode;
- NSString* callbackId;
- NSNumber* duration;
- CDVCapture* captureCommand;
- UIBarButtonItem* doneButton;
- UIView* recordingView;
- UIButton* recordButton;
- UIImage* recordImage;
- UIImage* stopRecordImage;
- UILabel* timerLabel;
- AVAudioRecorder* avRecorder;
- AVAudioSession* avSession;
- CDVPluginResult* pluginResult;
- NSTimer* timer;
- BOOL isTimed;
-}
-@property (nonatomic) CDVCaptureError errorCode;
-@property (nonatomic, copy) NSString* callbackId;
-@property (nonatomic, copy) NSNumber* duration;
-@property (nonatomic, strong) CDVCapture* captureCommand;
-@property (nonatomic, strong) UIBarButtonItem* doneButton;
-@property (nonatomic, strong) UIView* recordingView;
-@property (nonatomic, strong) UIButton* recordButton;
-@property (nonatomic, strong) UIImage* recordImage;
-@property (nonatomic, strong) UIImage* stopRecordImage;
-@property (nonatomic, strong) UILabel* timerLabel;
-@property (nonatomic, strong) AVAudioRecorder* avRecorder;
-@property (nonatomic, strong) AVAudioSession* avSession;
-@property (nonatomic, strong) CDVPluginResult* pluginResult;
-@property (nonatomic, strong) NSTimer* timer;
-@property (nonatomic) BOOL isTimed;
-
-- (id)initWithCommand:(CDVPlugin*)theCommand duration:(NSNumber*)theDuration callbackId:(NSString*)theCallbackId;
-- (void)processButton:(id)sender;
-- (void)stopRecordingCleanup;
-- (void)dismissAudioView:(id)sender;
-- (NSString*)formatTime:(int)interval;
-- (void)updateTime;
-@end
diff --git a/src/ios/CDVCapture.m b/src/ios/CDVCapture.m
deleted file mode 100644
index 6bcf0ad..0000000
--- a/src/ios/CDVCapture.m
+++ /dev/null
@@ -1,936 +0,0 @@
-/*
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
- */
-
-#import "CDVCapture.h"
-#import "CDVFile.h"
-#import <Cordova/CDVJSON.h>
-#import <Cordova/CDVAvailability.h>
-
-#define kW3CMediaFormatHeight @"height"
-#define kW3CMediaFormatWidth @"width"
-#define kW3CMediaFormatCodecs @"codecs"
-#define kW3CMediaFormatBitrate @"bitrate"
-#define kW3CMediaFormatDuration @"duration"
-#define kW3CMediaModeType @"type"
-
-@implementation CDVImagePicker
-
-@synthesize quality;
-@synthesize callbackId;
-@synthesize mimeType;
-
-- (uint64_t)accessibilityTraits
-{
- NSString* systemVersion = [[UIDevice currentDevice] systemVersion];
-
- if (([systemVersion compare:@"4.0" options:NSNumericSearch] != NSOrderedAscending)) { // this means system version is not less than 4.0
- return UIAccessibilityTraitStartsMediaSession;
- }
-
- return UIAccessibilityTraitNone;
-}
-
-- (BOOL)prefersStatusBarHidden {
- return YES;
-}
-
-- (UIViewController*)childViewControllerForStatusBarHidden {
- return nil;
-}
-
-- (void)viewWillAppear:(BOOL)animated {
- SEL sel = NSSelectorFromString(@"setNeedsStatusBarAppearanceUpdate");
- if ([self respondsToSelector:sel]) {
- [self performSelector:sel withObject:nil afterDelay:0];
- }
-
- [super viewWillAppear:animated];
-}
-
-@end
-
-@implementation CDVCapture
-@synthesize inUse;
-
-- (id)initWithWebView:(UIWebView*)theWebView
-{
- self = (CDVCapture*)[super initWithWebView:theWebView];
- if (self) {
- self.inUse = NO;
- }
- return self;
-}
-
-- (void)captureAudio:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- NSDictionary* options = [command.arguments objectAtIndex:0];
-
- if ([options isKindOfClass:[NSNull class]]) {
- options = [NSDictionary dictionary];
- }
-
- NSNumber* duration = [options objectForKey:@"duration"];
- // the default value of duration is 0 so use nil (no duration) if default value
- if (duration) {
- duration = [duration doubleValue] == 0 ? nil : duration;
- }
- CDVPluginResult* result = nil;
-
- if (NSClassFromString(@"AVAudioRecorder") == nil) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageToErrorObject:CAPTURE_NOT_SUPPORTED];
- } else if (self.inUse == YES) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageToErrorObject:CAPTURE_APPLICATION_BUSY];
- } else {
- // all the work occurs here
- CDVAudioRecorderViewController* audioViewController = [[CDVAudioRecorderViewController alloc] initWithCommand:self duration:duration callbackId:callbackId];
-
- // Now create a nav controller and display the view...
- CDVAudioNavigationController* navController = [[CDVAudioNavigationController alloc] initWithRootViewController:audioViewController];
-
- self.inUse = YES;
-
- SEL selector = NSSelectorFromString(@"presentViewController:animated:completion:");
- if ([self.viewController respondsToSelector:selector]) {
- [self.viewController presentViewController:navController animated:YES completion:nil];
- } else {
- // deprecated as of iOS >= 6.0
- [self.viewController presentModalViewController:navController animated:YES];
- }
- }
-
- if (result) {
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- }
-}
-
-- (void)captureImage:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- NSDictionary* options = [command.arguments objectAtIndex:0];
-
- if ([options isKindOfClass:[NSNull class]]) {
- options = [NSDictionary dictionary];
- }
-
- // options could contain limit and mode neither of which are supported at this time
- // taking more than one picture (limit) is only supported if provide own controls via cameraOverlayView property
- // can support mode in OS
-
- if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
- NSLog(@"Capture.imageCapture: camera not available.");
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageToErrorObject:CAPTURE_NOT_SUPPORTED];
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- } else {
- if (pickerController == nil) {
- pickerController = [[CDVImagePicker alloc] init];
- }
-
- pickerController.delegate = self;
- pickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
- pickerController.allowsEditing = NO;
- if ([pickerController respondsToSelector:@selector(mediaTypes)]) {
- // iOS 3.0
- pickerController.mediaTypes = [NSArray arrayWithObjects:(NSString*)kUTTypeImage, nil];
- }
-
- /*if ([pickerController respondsToSelector:@selector(cameraCaptureMode)]){
- // iOS 4.0
- pickerController.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
- pickerController.cameraDevice = UIImagePickerControllerCameraDeviceRear;
- pickerController.cameraFlashMode = UIImagePickerControllerCameraFlashModeAuto;
- }*/
- // CDVImagePicker specific property
- pickerController.callbackId = callbackId;
-
- SEL selector = NSSelectorFromString(@"presentViewController:animated:completion:");
- if ([self.viewController respondsToSelector:selector]) {
- [self.viewController presentViewController:pickerController animated:YES completion:nil];
- } else {
- // deprecated as of iOS >= 6.0
- [self.viewController presentModalViewController:pickerController animated:YES];
- }
- }
-}
-
-/* Process a still image from the camera.
- * IN:
- * UIImage* image - the UIImage data returned from the camera
- * NSString* callbackId
- */
-- (CDVPluginResult*)processImage:(UIImage*)image type:(NSString*)mimeType forCallbackId:(NSString*)callbackId
-{
- CDVPluginResult* result = nil;
-
- // save the image to photo album
- UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);
-
- NSData* data = nil;
- if (mimeType && [mimeType isEqualToString:@"image/png"]) {
- data = UIImagePNGRepresentation(image);
- } else {
- data = UIImageJPEGRepresentation(image, 0.5);
- }
-
- // write to temp directory and return URI
- NSString* docsPath = [NSTemporaryDirectory()stringByStandardizingPath]; // use file system temporary directory
- NSError* err = nil;
- NSFileManager* fileMgr = [[NSFileManager alloc] init];
-
- // generate unique file name
- NSString* filePath;
- int i = 1;
- do {
- filePath = [NSString stringWithFormat:@"%@/photo_%03d.jpg", docsPath, i++];
- } while ([fileMgr fileExistsAtPath:filePath]);
-
- if (![data writeToFile:filePath options:NSAtomicWrite error:&err]) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageToErrorObject:CAPTURE_INTERNAL_ERR];
- if (err) {
- NSLog(@"Error saving image: %@", [err localizedDescription]);
- }
- } else {
- // create MediaFile object
-
- NSDictionary* fileDict = [self getMediaDictionaryFromPath:filePath ofType:mimeType];
- NSArray* fileArray = [NSArray arrayWithObject:fileDict];
-
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:fileArray];
- }
-
- return result;
-}
-
-- (void)captureVideo:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- NSDictionary* options = [command.arguments objectAtIndex:0];
-
- if ([options isKindOfClass:[NSNull class]]) {
- options = [NSDictionary dictionary];
- }
-
- // options could contain limit, duration and mode
- // taking more than one video (limit) is only supported if provide own controls via cameraOverlayView property
- NSNumber* duration = [options objectForKey:@"duration"];
- NSString* mediaType = nil;
-
- if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
- // there is a camera, it is available, make sure it can do movies
- pickerController = [[CDVImagePicker alloc] init];
-
- NSArray* types = nil;
- if ([UIImagePickerController respondsToSelector:@selector(availableMediaTypesForSourceType:)]) {
- types = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
- // NSLog(@"MediaTypes: %@", [types description]);
-
- if ([types containsObject:(NSString*)kUTTypeMovie]) {
- mediaType = (NSString*)kUTTypeMovie;
- } else if ([types containsObject:(NSString*)kUTTypeVideo]) {
- mediaType = (NSString*)kUTTypeVideo;
- }
- }
- }
- if (!mediaType) {
- // don't have video camera return error
- NSLog(@"Capture.captureVideo: video mode not available.");
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageToErrorObject:CAPTURE_NOT_SUPPORTED];
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- pickerController = nil;
- } else {
- pickerController.delegate = self;
- pickerController.sourceType = UIImagePickerControllerSourceTypeCamera;
- pickerController.allowsEditing = NO;
- // iOS 3.0
- pickerController.mediaTypes = [NSArray arrayWithObjects:mediaType, nil];
-
- if ([mediaType isEqualToString:(NSString*)kUTTypeMovie]){
- if (duration) {
- pickerController.videoMaximumDuration = [duration doubleValue];
- }
- //NSLog(@"pickerController.videoMaximumDuration = %f", pickerController.videoMaximumDuration);
- }
-
- // iOS 4.0
- if ([pickerController respondsToSelector:@selector(cameraCaptureMode)]) {
- pickerController.cameraCaptureMode = UIImagePickerControllerCameraCaptureModeVideo;
- // pickerController.videoQuality = UIImagePickerControllerQualityTypeHigh;
- // pickerController.cameraDevice = UIImagePickerControllerCameraDeviceRear;
- // pickerController.cameraFlashMode = UIImagePickerControllerCameraFlashModeAuto;
- }
- // CDVImagePicker specific property
- pickerController.callbackId = callbackId;
-
- SEL selector = NSSelectorFromString(@"presentViewController:animated:completion:");
- if ([self.viewController respondsToSelector:selector]) {
- [self.viewController presentViewController:pickerController animated:YES completion:nil];
- } else {
- // deprecated as of iOS >= 6.0
- [self.viewController presentModalViewController:pickerController animated:YES];
- }
- }
-}
-
-- (CDVPluginResult*)processVideo:(NSString*)moviePath forCallbackId:(NSString*)callbackId
-{
- // save the movie to photo album (only avail as of iOS 3.1)
-
- /* don't need, it should automatically get saved
- NSLog(@"can save %@: %d ?", moviePath, UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(moviePath));
- if (&UIVideoAtPathIsCompatibleWithSavedPhotosAlbum != NULL && UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(moviePath) == YES) {
- NSLog(@"try to save movie");
- UISaveVideoAtPathToSavedPhotosAlbum(moviePath, nil, nil, nil);
- NSLog(@"finished saving movie");
- }*/
- // create MediaFile object
- NSDictionary* fileDict = [self getMediaDictionaryFromPath:moviePath ofType:nil];
- NSArray* fileArray = [NSArray arrayWithObject:fileDict];
-
- return [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:fileArray];
-}
-
-- (void)getMediaModes:(CDVInvokedUrlCommand*)command
-{
- // NSString* callbackId = [arguments objectAtIndex:0];
- // NSMutableDictionary* imageModes = nil;
- NSArray* imageArray = nil;
- NSArray* movieArray = nil;
- NSArray* audioArray = nil;
-
- if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
- // there is a camera, find the modes
- // can get image/jpeg or image/png from camera
-
- /* can't find a way to get the default height and width and other info
- * for images/movies taken with UIImagePickerController
- */
- NSDictionary* jpg = [NSDictionary dictionaryWithObjectsAndKeys:
- [NSNumber numberWithInt:0], kW3CMediaFormatHeight,
- [NSNumber numberWithInt:0], kW3CMediaFormatWidth,
- @"image/jpeg", kW3CMediaModeType,
- nil];
- NSDictionary* png = [NSDictionary dictionaryWithObjectsAndKeys:
- [NSNumber numberWithInt:0], kW3CMediaFormatHeight,
- [NSNumber numberWithInt:0], kW3CMediaFormatWidth,
- @"image/png", kW3CMediaModeType,
- nil];
- imageArray = [NSArray arrayWithObjects:jpg, png, nil];
-
- if ([UIImagePickerController respondsToSelector:@selector(availableMediaTypesForSourceType:)]) {
- NSArray* types = [UIImagePickerController availableMediaTypesForSourceType:UIImagePickerControllerSourceTypeCamera];
-
- if ([types containsObject:(NSString*)kUTTypeMovie]) {
- NSDictionary* mov = [NSDictionary dictionaryWithObjectsAndKeys:
- [NSNumber numberWithInt:0], kW3CMediaFormatHeight,
- [NSNumber numberWithInt:0], kW3CMediaFormatWidth,
- @"video/quicktime", kW3CMediaModeType,
- nil];
- movieArray = [NSArray arrayWithObject:mov];
- }
- }
- }
- NSDictionary* modes = [NSDictionary dictionaryWithObjectsAndKeys:
- imageArray ? (NSObject*) imageArray:[NSNull null], @"image",
- movieArray ? (NSObject*) movieArray:[NSNull null], @"video",
- audioArray ? (NSObject*) audioArray:[NSNull null], @"audio",
- nil];
- NSString* jsString = [NSString stringWithFormat:@"navigator.device.capture.setSupportedModes(%@);", [modes JSONString]];
- [self.commandDelegate evalJs:jsString];
-}
-
-- (void)getFormatData:(CDVInvokedUrlCommand*)command
-{
- NSString* callbackId = command.callbackId;
- // existence of fullPath checked on JS side
- NSString* fullPath = [command.arguments objectAtIndex:0];
- // mimeType could be null
- NSString* mimeType = nil;
-
- if ([command.arguments count] > 1) {
- mimeType = [command.arguments objectAtIndex:1];
- }
- BOOL bError = NO;
- CDVCaptureError errorCode = CAPTURE_INTERNAL_ERR;
- CDVPluginResult* result = nil;
-
- if (!mimeType || [mimeType isKindOfClass:[NSNull class]]) {
- // try to determine mime type if not provided
- id command = [self.commandDelegate getCommandInstance:@"File"];
- bError = !([command isKindOfClass:[CDVFile class]]);
- if (!bError) {
- CDVFile* cdvFile = (CDVFile*)command;
- mimeType = [cdvFile getMimeTypeFromPath:fullPath];
- if (!mimeType) {
- // can't do much without mimeType, return error
- bError = YES;
- errorCode = CAPTURE_INVALID_ARGUMENT;
- }
- }
- }
- if (!bError) {
- // create and initialize return dictionary
- NSMutableDictionary* formatData = [NSMutableDictionary dictionaryWithCapacity:5];
- [formatData setObject:[NSNull null] forKey:kW3CMediaFormatCodecs];
- [formatData setObject:[NSNumber numberWithInt:0] forKey:kW3CMediaFormatBitrate];
- [formatData setObject:[NSNumber numberWithInt:0] forKey:kW3CMediaFormatHeight];
- [formatData setObject:[NSNumber numberWithInt:0] forKey:kW3CMediaFormatWidth];
- [formatData setObject:[NSNumber numberWithInt:0] forKey:kW3CMediaFormatDuration];
-
- if ([mimeType rangeOfString:@"image/"].location != NSNotFound) {
- UIImage* image = [UIImage imageWithContentsOfFile:fullPath];
- if (image) {
- CGSize imgSize = [image size];
- [formatData setObject:[NSNumber numberWithInteger:imgSize.width] forKey:kW3CMediaFormatWidth];
- [formatData setObject:[NSNumber numberWithInteger:imgSize.height] forKey:kW3CMediaFormatHeight];
- }
- } else if (([mimeType rangeOfString:@"video/"].location != NSNotFound) && (NSClassFromString(@"AVURLAsset") != nil)) {
- NSURL* movieURL = [NSURL fileURLWithPath:fullPath];
- AVURLAsset* movieAsset = [[AVURLAsset alloc] initWithURL:movieURL options:nil];
- CMTime duration = [movieAsset duration];
- [formatData setObject:[NSNumber numberWithFloat:CMTimeGetSeconds(duration)] forKey:kW3CMediaFormatDuration];
-
- NSArray* allVideoTracks = [movieAsset tracksWithMediaType:AVMediaTypeVideo];
- if ([allVideoTracks count] > 0) {
- AVAssetTrack* track = [[movieAsset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0];
- CGSize size = [track naturalSize];
-
- [formatData setObject:[NSNumber numberWithFloat:size.height] forKey:kW3CMediaFormatHeight];
- [formatData setObject:[NSNumber numberWithFloat:size.width] forKey:kW3CMediaFormatWidth];
- // not sure how to get codecs or bitrate???
- // AVMetadataItem
- // AudioFile
- } else {
- NSLog(@"No video tracks found for %@", fullPath);
- }
- } else if ([mimeType rangeOfString:@"audio/"].location != NSNotFound) {
- if (NSClassFromString(@"AVAudioPlayer") != nil) {
- NSURL* fileURL = [NSURL fileURLWithPath:fullPath];
- NSError* err = nil;
-
- AVAudioPlayer* avPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:fileURL error:&err];
- if (!err) {
- // get the data
- [formatData setObject:[NSNumber numberWithDouble:[avPlayer duration]] forKey:kW3CMediaFormatDuration];
- if ([avPlayer respondsToSelector:@selector(settings)]) {
- NSDictionary* info = [avPlayer settings];
- NSNumber* bitRate = [info objectForKey:AVEncoderBitRateKey];
- if (bitRate) {
- [formatData setObject:bitRate forKey:kW3CMediaFormatBitrate];
- }
- }
- } // else leave data init'ed to 0
- }
- }
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:formatData];
- // NSLog(@"getFormatData: %@", [formatData description]);
- }
- if (bError) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageToErrorObject:(int)errorCode];
- }
- if (result) {
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- }
-}
-
-- (NSDictionary*)getMediaDictionaryFromPath:(NSString*)fullPath ofType:(NSString*)type
-{
- NSFileManager* fileMgr = [[NSFileManager alloc] init];
- NSMutableDictionary* fileDict = [NSMutableDictionary dictionaryWithCapacity:5];
-
- CDVFile *fs = [self.commandDelegate getCommandInstance:@"File"];
-
- // Get canonical version of localPath
- NSURL *fileURL = [NSURL URLWithString:[NSString stringWithFormat:@"file://%@", fullPath]];
- NSURL *resolvedFileURL = [fileURL URLByResolvingSymlinksInPath];
- NSString *path = [resolvedFileURL path];
-
- CDVFilesystemURL *url = [fs fileSystemURLforLocalPath:path];
-
- [fileDict setObject:[fullPath lastPathComponent] forKey:@"name"];
- [fileDict setObject:fullPath forKey:@"fullPath"];
- if (url) {
- [fileDict setObject:[url absoluteURL] forKey:@"localURL"];
- }
- // determine type
- if (!type) {
- id command = [self.commandDelegate getCommandInstance:@"File"];
- if ([command isKindOfClass:[CDVFile class]]) {
- CDVFile* cdvFile = (CDVFile*)command;
- NSString* mimeType = [cdvFile getMimeTypeFromPath:fullPath];
- [fileDict setObject:(mimeType != nil ? (NSObject*)mimeType : [NSNull null]) forKey:@"type"];
- }
- }
- NSDictionary* fileAttrs = [fileMgr attributesOfItemAtPath:fullPath error:nil];
- [fileDict setObject:[NSNumber numberWithUnsignedLongLong:[fileAttrs fileSize]] forKey:@"size"];
- NSDate* modDate = [fileAttrs fileModificationDate];
- NSNumber* msDate = [NSNumber numberWithDouble:[modDate timeIntervalSince1970] * 1000];
- [fileDict setObject:msDate forKey:@"lastModifiedDate"];
-
- return fileDict;
-}
-
-- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingImage:(UIImage*)image editingInfo:(NSDictionary*)editingInfo
-{
- // older api calls new one
- [self imagePickerController:picker didFinishPickingMediaWithInfo:editingInfo];
-}
-
-/* Called when image/movie is finished recording.
- * Calls success or error code as appropriate
- * if successful, result contains an array (with just one entry since can only get one image unless build own camera UI) of MediaFile object representing the image
- * name
- * fullPath
- * type
- * lastModifiedDate
- * size
- */
-- (void)imagePickerController:(UIImagePickerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info
-{
- CDVImagePicker* cameraPicker = (CDVImagePicker*)picker;
- NSString* callbackId = cameraPicker.callbackId;
-
- if ([picker respondsToSelector:@selector(presentingViewController)]) {
- [[picker presentingViewController] dismissModalViewControllerAnimated:YES];
- } else {
- [[picker parentViewController] dismissModalViewControllerAnimated:YES];
- }
-
- CDVPluginResult* result = nil;
-
- UIImage* image = nil;
- NSString* mediaType = [info objectForKey:UIImagePickerControllerMediaType];
- if (!mediaType || [mediaType isEqualToString:(NSString*)kUTTypeImage]) {
- // mediaType is nil then only option is UIImagePickerControllerOriginalImage
- if ([UIImagePickerController respondsToSelector:@selector(allowsEditing)] &&
- (cameraPicker.allowsEditing && [info objectForKey:UIImagePickerControllerEditedImage])) {
- image = [info objectForKey:UIImagePickerControllerEditedImage];
- } else {
- image = [info objectForKey:UIImagePickerControllerOriginalImage];
- }
- }
- if (image != nil) {
- // mediaType was image
- result = [self processImage:image type:cameraPicker.mimeType forCallbackId:callbackId];
- } else if ([mediaType isEqualToString:(NSString*)kUTTypeMovie]) {
- // process video
- NSString* moviePath = [[info objectForKey:UIImagePickerControllerMediaURL] path];
- if (moviePath) {
- result = [self processVideo:moviePath forCallbackId:callbackId];
- }
- }
- if (!result) {
- result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageToErrorObject:CAPTURE_INTERNAL_ERR];
- }
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- pickerController = nil;
-}
-
-- (void)imagePickerControllerDidCancel:(UIImagePickerController*)picker
-{
- CDVImagePicker* cameraPicker = (CDVImagePicker*)picker;
- NSString* callbackId = cameraPicker.callbackId;
-
- if ([picker respondsToSelector:@selector(presentingViewController)]) {
- [[picker presentingViewController] dismissModalViewControllerAnimated:YES];
- } else {
- [[picker parentViewController] dismissModalViewControllerAnimated:YES];
- }
-
- CDVPluginResult* result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageToErrorObject:CAPTURE_NO_MEDIA_FILES];
- [self.commandDelegate sendPluginResult:result callbackId:callbackId];
- pickerController = nil;
-}
-
-@end
-
-@implementation CDVAudioNavigationController
-
-#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 60000
- - (NSUInteger)supportedInterfaceOrientations
- {
- // delegate to CVDAudioRecorderViewController
- return [self.topViewController supportedInterfaceOrientations];
- }
-#endif
-
-@end
-
-@interface CDVAudioRecorderViewController () {
- UIStatusBarStyle _previousStatusBarStyle;
-}
-@end
-
-@implementation CDVAudioRecorderViewController
-@synthesize errorCode, callbackId, duration, captureCommand, doneButton, recordingView, recordButton, recordImage, stopRecordImage, timerLabel, avRecorder, avSession, pluginResult, timer, isTimed;
-
-- (NSString*)resolveImageResource:(NSString*)resource
-{
- NSString* systemVersion = [[UIDevice currentDevice] systemVersion];
- BOOL isLessThaniOS4 = ([systemVersion compare:@"4.0" options:NSNumericSearch] == NSOrderedAscending);
-
- // the iPad image (nor retina) differentiation code was not in 3.x, and we have to explicitly set the path
- // if user wants iPhone only app to run on iPad they must remove *~ipad.* images from CDVCapture.bundle
- if (isLessThaniOS4) {
- NSString* iPadResource = [NSString stringWithFormat:@"%@~ipad.png", resource];
- if (CDV_IsIPad() && [UIImage imageNamed:iPadResource]) {
- return iPadResource;
- } else {
- return [NSString stringWithFormat:@"%@.png", resource];
- }
- }
-
- return resource;
-}
-
-- (id)initWithCommand:(CDVCapture*)theCommand duration:(NSNumber*)theDuration callbackId:(NSString*)theCallbackId
-{
- if ((self = [super init])) {
- self.captureCommand = theCommand;
- self.duration = theDuration;
- self.callbackId = theCallbackId;
- self.errorCode = CAPTURE_NO_MEDIA_FILES;
- self.isTimed = self.duration != nil;
- _previousStatusBarStyle = [UIApplication sharedApplication].statusBarStyle;
-
- return self;
- }
-
- return nil;
-}
-
-- (void)loadView
-{
- if ([self respondsToSelector:@selector(edgesForExtendedLayout)]) {
- self.edgesForExtendedLayout = UIRectEdgeNone;
- }
-
- // create view and display
- CGRect viewRect = [[UIScreen mainScreen] applicationFrame];
- UIView* tmp = [[UIView alloc] initWithFrame:viewRect];
-
- // make backgrounds
- NSString* microphoneResource = @"CDVCapture.bundle/microphone";
-
- if (CDV_IsIPhone5()) {
- microphoneResource = @"CDVCapture.bundle/microphone-568h";
- }
-
- UIImage* microphone = [UIImage imageNamed:[self resolveImageResource:microphoneResource]];
- UIView* microphoneView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, viewRect.size.width, microphone.size.height)];
- [microphoneView setBackgroundColor:[UIColor colorWithPatternImage:microphone]];
- [microphoneView setUserInteractionEnabled:NO];
- [microphoneView setIsAccessibilityElement:NO];
- [tmp addSubview:microphoneView];
-
- // add bottom bar view
- UIImage* grayBkg = [UIImage imageNamed:[self resolveImageResource:@"CDVCapture.bundle/controls_bg"]];
- UIView* controls = [[UIView alloc] initWithFrame:CGRectMake(0, microphone.size.height, viewRect.size.width, grayBkg.size.height)];
- [controls setBackgroundColor:[UIColor colorWithPatternImage:grayBkg]];
- [controls setUserInteractionEnabled:NO];
- [controls setIsAccessibilityElement:NO];
- [tmp addSubview:controls];
-
- // make red recording background view
- UIImage* recordingBkg = [UIImage imageNamed:[self resolveImageResource:@"CDVCapture.bundle/recording_bg"]];
- UIColor* background = [UIColor colorWithPatternImage:recordingBkg];
- self.recordingView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, viewRect.size.width, recordingBkg.size.height)];
- [self.recordingView setBackgroundColor:background];
- [self.recordingView setHidden:YES];
- [self.recordingView setUserInteractionEnabled:NO];
- [self.recordingView setIsAccessibilityElement:NO];
- [tmp addSubview:self.recordingView];
-
- // add label
- self.timerLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, viewRect.size.width, recordingBkg.size.height)];
- // timerLabel.autoresizingMask = reSizeMask;
- [self.timerLabel setBackgroundColor:[UIColor clearColor]];
- [self.timerLabel setTextColor:[UIColor whiteColor]];
-#ifdef __IPHONE_6_0
- [self.timerLabel setTextAlignment:NSTextAlignmentCenter];
-#else
- // for iOS SDK < 6.0
- [self.timerLabel setTextAlignment:UITextAlignmentCenter];
-#endif
- [self.timerLabel setText:@"0:00"];
- [self.timerLabel setAccessibilityHint:NSLocalizedString(@"recorded time in minutes and seconds", nil)];
- self.timerLabel.accessibilityTraits |= UIAccessibilityTraitUpdatesFrequently;
- self.timerLabel.accessibilityTraits &= ~UIAccessibilityTraitStaticText;
- [tmp addSubview:self.timerLabel];
-
- // Add record button
-
- self.recordImage = [UIImage imageNamed:[self resolveImageResource:@"CDVCapture.bundle/record_button"]];
- self.stopRecordImage = [UIImage imageNamed:[self resolveImageResource:@"CDVCapture.bundle/stop_button"]];
- self.recordButton.accessibilityTraits |= [self accessibilityTraits];
- self.recordButton = [[UIButton alloc] initWithFrame:CGRectMake((viewRect.size.width - recordImage.size.width) / 2, (microphone.size.height + (grayBkg.size.height - recordImage.size.height) / 2), recordImage.size.width, recordImage.size.height)];
- [self.recordButton setAccessibilityLabel:NSLocalizedString(@"toggle audio recording", nil)];
- [self.recordButton setImage:recordImage forState:UIControlStateNormal];
- [self.recordButton addTarget:self action:@selector(processButton:) forControlEvents:UIControlEventTouchUpInside];
- [tmp addSubview:recordButton];
-
- // make and add done button to navigation bar
- self.doneButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismissAudioView:)];
- [self.doneButton setStyle:UIBarButtonItemStyleDone];
- self.navigationItem.rightBarButtonItem = self.doneButton;
-
- [self setView:tmp];
-}
-
-- (void)viewDidLoad
-{
- [super viewDidLoad];
- UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, nil);
- NSError* error = nil;
-
- if (self.avSession == nil) {
- // create audio session
- self.avSession = [AVAudioSession sharedInstance];
- if (error) {
- // return error if can't create recording audio session
- NSLog(@"error creating audio session: %@", [[error userInfo] description]);
- self.errorCode = CAPTURE_INTERNAL_ERR;
- [self dismissAudioView:nil];
- }
- }
-
- // create file to record to in temporary dir
-
- NSString* docsPath = [NSTemporaryDirectory()stringByStandardizingPath]; // use file system temporary directory
- NSError* err = nil;
- NSFileManager* fileMgr = [[NSFileManager alloc] init];
-
- // generate unique file name
- NSString* filePath;
- int i = 1;
- do {
- filePath = [NSString stringWithFormat:@"%@/audio_%03d.wav", docsPath, i++];
- } while ([fileMgr fileExistsAtPath:filePath]);
-
- NSURL* fileURL = [NSURL fileURLWithPath:filePath isDirectory:NO];
-
- // create AVAudioPlayer
- self.avRecorder = [[AVAudioRecorder alloc] initWithURL:fileURL settings:nil error:&err];
- if (err) {
- NSLog(@"Failed to initialize AVAudioRecorder: %@\n", [err localizedDescription]);
- self.avRecorder = nil;
- // return error
- self.errorCode = CAPTURE_INTERNAL_ERR;
- [self dismissAudioView:nil];
- } else {
- self.avRecorder.delegate = self;
- [self.avRecorder prepareToRecord];
- self.recordButton.enabled = YES;
- self.doneButton.enabled = YES;
- }
-}
-
-#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 60000
- - (NSUInteger)supportedInterfaceOrientations
- {
- NSUInteger orientation = UIInterfaceOrientationMaskPortrait; // must support portrait
- NSUInteger supported = [captureCommand.viewController supportedInterfaceOrientations];
-
- orientation = orientation | (supported & UIInterfaceOrientationMaskPortraitUpsideDown);
- return orientation;
- }
-#endif
-
-- (void)viewDidUnload
-{
- [self setView:nil];
- [self.captureCommand setInUse:NO];
-}
-
-- (void)processButton:(id)sender
-{
- if (self.avRecorder.recording) {
- // stop recording
- [self.avRecorder stop];
- self.isTimed = NO; // recording was stopped via button so reset isTimed
- // view cleanup will occur in audioRecordingDidFinishRecording
- } else {
- // begin recording
- [self.recordButton setImage:stopRecordImage forState:UIControlStateNormal];
- self.recordButton.accessibilityTraits &= ~[self accessibilityTraits];
- [self.recordingView setHidden:NO];
- __block NSError* error = nil;
-
- void (^startRecording)(void) = ^{
- [self.avSession setCategory:AVAudioSessionCategoryRecord error:&error];
- [self.avSession setActive:YES error:&error];
- if (error) {
- // can't continue without active audio session
- self.errorCode = CAPTURE_INTERNAL_ERR;
- [self dismissAudioView:nil];
- } else {
- if (self.duration) {
- self.isTimed = true;
- [self.avRecorder recordForDuration:[duration doubleValue]];
- } else {
- [self.avRecorder record];
- }
- [self.timerLabel setText:@"0.00"];
- self.timer = [NSTimer scheduledTimerWithTimeInterval:0.5f target:self selector:@selector(updateTime) userInfo:nil repeats:YES];
- self.doneButton.enabled = NO;
- }
- UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, nil);
- };
-
- SEL rrpSel = NSSelectorFromString(@"requestRecordPermission:");
- if ([self.avSession respondsToSelector:rrpSel])
- {
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Warc-performSelector-leaks"
- [self.avSession performSelector:rrpSel withObject:^(BOOL granted){
- if (granted) {
- startRecording();
- } else {
- NSLog(@"Error creating audio session, microphone permission denied.");
- self.errorCode = CAPTURE_INTERNAL_ERR;
- [self dismissAudioView:nil];
- }
- }];
-#pragma clang diagnostic pop
- } else {
- startRecording();
- }
- }
-}
-
-/*
- * helper method to clean up when stop recording
- */
-- (void)stopRecordingCleanup
-{
- if (self.avRecorder.recording) {
- [self.avRecorder stop];
- }
- [self.recordButton setImage:recordImage forState:UIControlStateNormal];
- self.recordButton.accessibilityTraits |= [self accessibilityTraits];
- [self.recordingView setHidden:YES];
- self.doneButton.enabled = YES;
- if (self.avSession) {
- // deactivate session so sounds can come through
- [self.avSession setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];
- [self.avSession setActive:NO error:nil];
- }
- if (self.duration && self.isTimed) {
- // VoiceOver announcement so user knows timed recording has finished
- BOOL isUIAccessibilityAnnouncementNotification = (&UIAccessibilityAnnouncementNotification != NULL);
- if (isUIAccessibilityAnnouncementNotification) {
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, 500ull * NSEC_PER_MSEC), dispatch_get_main_queue(), ^{
- UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, NSLocalizedString(@"timed recording complete", nil));
- });
- }
- } else {
- // issue a layout notification change so that VO will reannounce the button label when recording completes
- UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, nil);
- }
-}
-
-- (void)dismissAudioView:(id)sender
-{
- // called when done button pressed or when error condition to do cleanup and remove view
- if ([self.captureCommand.viewController.modalViewController respondsToSelector:@selector(presentingViewController)]) {
- [[self.captureCommand.viewController.modalViewController presentingViewController] dismissModalViewControllerAnimated:YES];
- } else {
- [[self.captureCommand.viewController.modalViewController parentViewController] dismissModalViewControllerAnimated:YES];
- }
-
- if (!self.pluginResult) {
- // return error
- self.pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageToErrorObject:(int)self.errorCode];
- }
-
- self.avRecorder = nil;
- [self.avSession setCategory:AVAudioSessionCategoryPlayAndRecord error:nil];
- [self.avSession setActive:NO error:nil];
- [self.captureCommand setInUse:NO];
- UIAccessibilityPostNotification(UIAccessibilityScreenChangedNotification, nil);
- // return result
- [self.captureCommand.commandDelegate sendPluginResult:pluginResult callbackId:callbackId];
-
- if (IsAtLeastiOSVersion(@"7.0")) {
- [[UIApplication sharedApplication] setStatusBarStyle:_previousStatusBarStyle];
- }
-}
-
-- (void)updateTime
-{
- // update the label with the elapsed time
- [self.timerLabel setText:[self formatTime:self.avRecorder.currentTime]];
-}
-
-- (NSString*)formatTime:(int)interval
-{
- // is this format universal?
- int secs = interval % 60;
- int min = interval / 60;
-
- if (interval < 60) {
- return [NSString stringWithFormat:@"0:%02d", interval];
- } else {
- return [NSString stringWithFormat:@"%d:%02d", min, secs];
- }
-}
-
-- (void)audioRecorderDidFinishRecording:(AVAudioRecorder*)recorder successfully:(BOOL)flag
-{
- // may be called when timed audio finishes - need to stop time and reset buttons
- [self.timer invalidate];
- [self stopRecordingCleanup];
-
- // generate success result
- if (flag) {
- NSString* filePath = [avRecorder.url path];
- // NSLog(@"filePath: %@", filePath);
- NSDictionary* fileDict = [captureCommand getMediaDictionaryFromPath:filePath ofType:@"audio/wav"];
- NSArray* fileArray = [NSArray arrayWithObject:fileDict];
-
- self.pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsArray:fileArray];
- } else {
- self.pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageToErrorObject:CAPTURE_INTERNAL_ERR];
- }
-}
-
-- (void)audioRecorderEncodeErrorDidOccur:(AVAudioRecorder*)recorder error:(NSError*)error
-{
- [self.timer invalidate];
- [self stopRecordingCleanup];
-
- NSLog(@"error recording audio");
- self.pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_IO_EXCEPTION messageToErrorObject:CAPTURE_INTERNAL_ERR];
- [self dismissAudioView:nil];
-}
-
-- (UIStatusBarStyle)preferredStatusBarStyle
-{
- return UIStatusBarStyleDefault;
-}
-
-- (void)viewWillAppear:(BOOL)animated
-{
- if (IsAtLeastiOSVersion(@"7.0")) {
- [[UIApplication sharedApplication] setStatusBarStyle:[self preferredStatusBarStyle]];
- }
-
- [super viewWillAppear:animated];
-}
-
-@end
diff --git a/src/ubuntu/MediaCaptureWidget.qml b/src/ubuntu/MediaCaptureWidget.qml
deleted file mode 100644
index cf0b04c..0000000
--- a/src/ubuntu/MediaCaptureWidget.qml
+++ /dev/null
@@ -1,207 +0,0 @@
-/*
- *
- * Copyright 2013 Canonical Ltd.
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-import QtQuick 2.0
-import QtMultimedia 5.0
-
-Rectangle {
- property string recordOffImagePath: "record_off.png"
- property string recordOnImagePath: "record_on.png"
- property string shootImagePath: "shoot.png"
- function isSuffix(str, suffix) {
- return String(str).substr(String(str).length - suffix.length) == suffix
- }
-
- id: ui
- color: "#252423"
- anchors.fill: parent
- state: "off"
-
- Camera {
- objectName: "camera"
- id: camera
- cameraState: Camera.UnloadedState
- onError: {
- console.log(errorString);
- shootButton.source = recordOffImagePath
- }
- imageCapture {
- onImageSaved: {
- root.exec("Capture", "onImageSaved", [path]);
- ui.destroy();
- }
- }
- videoRecorder {
- audioBitRate: 128000
- mediaContainer: "mp4"
- outputLocation: ui.parent.plugin('Capture').generateLocation("mp4")
- onRecorderStateChanged: {
- if (videoRecorder.recorderState === CameraRecorder.StoppedState) {
- ui.parent.exec("Capture", "onVideoRecordEnd", [camera.videoRecorder.actualLocation]);
- shootButton.source = recordOffImagePath
- }
- }
- }
- }
- Image {
- id: microphoneImage
- source: "microphone.png"
- smooth: true
- visible: false
- width: parent.width
- height: parent.height
- }
- VideoOutput {
- id: output
- focus : visible
- source: camera
- width: parent.width
- height: parent.height
- }
-
- Item {
- anchors.bottom: parent.bottom
- width: parent.width
- height: shootButton.height
- BorderImage {
- id: leftBackground
- anchors.left: parent.left
- anchors.top: parent.top
- anchors.bottom: parent.bottom
- anchors.right: middle.left
- anchors.topMargin: units.dp(2)
- anchors.bottomMargin: units.dp(2)
- source: "toolbar-left.png"
- Image {
- anchors.verticalCenter: parent.verticalCenter
- anchors.left: parent.left
- anchors.leftMargin: parent.iconSpacing
- source: "back.png"
- width: units.gu(6)
- height: units.gu(5)
- MouseArea {
- anchors.fill: parent
- onClicked: {
- root.exec("Capture", "cancel");
- }
- }
- }
- }
- BorderImage {
- id: middle
- anchors.top: parent.top
- anchors.bottom: parent.bottom
- anchors.horizontalCenter: parent.horizontalCenter
- height: shootButton.height + units.gu(1)
- width: shootButton.width
- source: "toolbar-middle.png"
- Image {
- id: shootButton
- width: units.gu(8)
- height: width
- anchors.horizontalCenter: parent.horizontalCenter
- source: shootImagePath
- MouseArea {
- anchors.fill: parent
- onClicked: {
- if (ui.state === "camera") {
- camera.imageCapture.captureToLocation(ui.parent.plugin('Capture').generateLocation("jpg"));
- } else if (ui.state === "audio") {
- ui.parent.exec("Capture", "recordAudio");
- if (isSuffix(shootButton.source, recordOffImagePath)) {
- shootButton.source = recordOnImagePath
- } else {
- shootButton.source = recordOffImagePath
- }
- } else if (ui.state === "videoRecording") {
- if (!camera.videoRecorder.recorderState) {
- shootButton.source = recordOnImagePath
- camera.videoRecorder.record();
- } else {
- camera.videoRecorder.stop();
- }
- }
- }
- }
- }
- }
- BorderImage {
- id: rightBackground
- anchors.right: parent.right
- anchors.top: parent.top
- anchors.bottom: parent.bottom
- anchors.left: middle.right
- anchors.topMargin: units.dp(2)
- anchors.bottomMargin: units.dp(2)
- source: "toolbar-right.png"
- }
- }
- states: [
- State {
- name: "off"
- StateChangeScript {
- script:{
- ui.visible = false;
- camera.stop();
- camera.unlock();
- }
- }
- },
- State {
- name: "camera"
- StateChangeScript {
- script: {
- camera.start();
- microphoneImage.visible = false
- output.visible = true
- shootButton.source = shootImagePath
- ui.visible = true
- }
- }
- },
- State {
- name: "videoRecording"
- StateChangeScript {
- script: {
- shootButton.source = recordOffImagePath
- camera.start();
- microphoneImage.visible = false
- output.visible = true
- ui.visible = true
- }
- }
- },
- State {
- name: "audio"
- StateChangeScript {
- script:{
- shootButton.source = recordOffImagePath
- camera.stop();
- microphoneImage.visible = true
- camera.unlock();
- output.visible = false
- ui.visible = true
- }
- }
- }
- ]
-}
diff --git a/src/ubuntu/back.png b/src/ubuntu/back.png
deleted file mode 100644
index af78faa..0000000
--- a/src/ubuntu/back.png
+++ /dev/null
Binary files differ
diff --git a/src/ubuntu/capture.cpp b/src/ubuntu/capture.cpp
deleted file mode 100644
index cab4074..0000000
--- a/src/ubuntu/capture.cpp
+++ /dev/null
@@ -1,167 +0,0 @@
-/*
- *
- * Copyright 2013 Canonical Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-#include "capture.h"
-
-const char code[] = "\
-var component, object; \
-function createObject() { \
- component = Qt.createComponent(%1); \
- if (component.status == Component.Ready) \
- finishCreation(); \
- else \
- component.statusChanged.connect(finishCreation); \
-} \
-function finishCreation() { \
- CordovaWrapper.captureObject = component.createObject(root, \
- {root: root, cordova: cordova, state: \"%2\"}); \
-} \
-createObject()";
-
-static QString formatFile(const QMimeDatabase &db, const QString &path) {
- QFileInfo info(path);
- QMimeType mime = db.mimeTypeForFile(info.fileName());
-
- QVariantMap file;
- file.insert("name", info.fileName());
- file.insert("fullPath", info.absoluteFilePath());
- file.insert("lastModifiedDate", info.lastModified().toMSecsSinceEpoch());
- file.insert("size", info.size());
- file.insert("type", mime.name());
-
- return CordovaInternal::format(file);
-}
-
-MediaCapture::MediaCapture(Cordova *cordova): CPlugin(cordova), _scId(0), _ecId(0) {
-}
-
-void MediaCapture::captureAudio(int scId, int ecId, QVariantMap options) {
- if (_scId || _ecId) {
- this->callback(_ecId, QString("{code: %1}").arg(CAPTURE_APPLICATION_BUSY));
- return;
- }
-
- QString path = m_cordova->get_app_dir() + "/../qml/MediaCaptureWidget.qml";
-
- // TODO: relative url
- QString qml = QString(code).arg(CordovaInternal::format(path)).arg("audio");
- m_cordova->execQML(qml);
-
- _scId = scId;
- _ecId = ecId;
-}
-
-void MediaCapture::onAudioRecordError(QMediaRecorder::Error) {
- if (!_ecId)
- return;
- this->callback(_ecId, QString("{code: %1}").arg(CAPTURE_INTERNAL_ERR));
- _ecId = _scId = 0;
-
- _recorder.clear();
- _files.clear();
-
- m_cordova->execQML("CordovaWrapper.captureObject.destroy()");
-}
-
-void MediaCapture::recordAudio() {
- if (_recorder.data()) {
- QUrl url = _recorder->outputLocation();
-
- QString path = url.toString();
- _recorder->stop();
-
- _recorder.clear();
-
- this->callback(_scId, QString("[%1]").arg(formatFile(_db, path)));
- _ecId = _scId = 0;
-
- m_cordova->execQML("CordovaWrapper.captureObject.destroy()");
- } else {
- _recorder = QSharedPointer<QAudioRecorder>(new QAudioRecorder);
- QObject::connect(_recorder.data(), SIGNAL(error(QMediaRecorder::Error)), this, SLOT(onAudioRecordError(QMediaRecorder::Error)));
-
- if (_options.find("mode")->toString() == "audio/amr") {
- _recorder->setContainerFormat("amr");
- _recorder->setOutputLocation(generateLocation("amr"));
- } else {
- _recorder->setContainerFormat("wav");
- _recorder->setOutputLocation(generateLocation("wav"));
- }
- _recorder->record();
- }
-}
-
-void MediaCapture::cancel() {
- if (!_ecId)
- return;
-
- m_cordova->execQML("CordovaWrapper.captureObject.destroy()");
-
- _recorder.clear();
- this->callback(_ecId, QString("{code: %1}").arg(CAPTURE_NO_MEDIA_FILES));
- _ecId = _scId = 0;
-
- _recorder.clear();
-}
-
-void MediaCapture::captureVideo(int scId, int ecId, QVariantMap options) {
- if (_scId || _ecId) {
- this->callback(_ecId, QString("{code: %1}").arg(CAPTURE_APPLICATION_BUSY));
- return;
- }
-
- QString path = m_cordova->get_app_dir() + "/../qml/MediaCaptureWidget.qml";
-
- // TODO: relative url
- QString qml = QString(code).arg(CordovaInternal::format(path)).arg("videoRecording");
- m_cordova->execQML(qml);
-
- _scId = scId;
- _ecId = ecId;
-}
-
-void MediaCapture::onVideoRecordEnd(QString path) {
- assert(path.startsWith("file:"));
- path = path.mid(5);
-
- this->callback(_scId, QString("[%1]").arg(formatFile(_db, path)));
- _ecId = _scId = 0;
-
- m_cordova->execQML("CordovaWrapper.captureObject.destroy()");
-}
-
-void MediaCapture::captureImage(int scId, int ecId, QVariantMap options) {
- if (_scId || _ecId) {
- this->callback(_ecId, QString("{code: %1}").arg(CAPTURE_APPLICATION_BUSY));
- return;
- }
-
- QString path = m_cordova->get_app_dir() + "/../qml/MediaCaptureWidget.qml";
-
- // TODO: relative url
- QString qml = QString(code).arg(CordovaInternal::format(path)).arg("camera");
- m_cordova->execQML(qml);
-
- _scId = scId;
- _ecId = ecId;
-}
-
-void MediaCapture::onImageSaved(const QString &path) {
- this->callback(_scId, QString("[%1]").arg(formatFile(_db, path)));
- _ecId = _scId = 0;
-}
diff --git a/src/ubuntu/capture.h b/src/ubuntu/capture.h
deleted file mode 100644
index 2c6caa4..0000000
--- a/src/ubuntu/capture.h
+++ /dev/null
@@ -1,84 +0,0 @@
-/*
- *
- * Copyright 2013 Canonical Ltd.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-#ifndef CAPTURE_H_ASCXZFG975
-#define CAPTURE_H_ASCXZFG975
-
-#include <cordova.h>
-#include <cplugin.h>
-#include <QtMultimedia>
-#include <QtCore>
-#include <QtQuick>
-
-class MediaCapture: public CPlugin {
- Q_OBJECT
-public:
- explicit MediaCapture(Cordova *cordova);
-
- virtual const QString fullName() override {
- return MediaCapture::fullID();
- }
-
- virtual const QString shortName() override {
- return "Capture";
- }
-
- static const QString fullID() {
- return "Capture";
- }
-
-public slots:
- void captureAudio(int scId, int ecId, QVariantMap options);
- void captureImage(int scId, int ecId, QVariantMap options);
- void captureVideo(int scId, int ecId, QVariantMap options);
-
- void recordAudio();
- void cancel();
- void onVideoRecordEnd(QString path);
- void onImageSaved(const QString &path);
-
- QString generateLocation(const QString &extension) {
- int i = 1;
- for (;;++i) {
- QString path = QString("%1/.local/share/%2/persistent/%3.%4").arg(QDir::homePath())
- .arg(QCoreApplication::applicationName()).arg(i).arg(extension);
-
- if (!QFileInfo(path).exists())
- return path;
- }
- }
-private slots:
- void onAudioRecordError(QMediaRecorder::Error);
-private:
- QSharedPointer<QAudioRecorder> _recorder;
-
- int _scId, _ecId;
- QList<QString> _files;
- QVariantMap _options;
- QMimeDatabase _db;
-
- enum CaptureError {
- CAPTURE_INTERNAL_ERR = 0,
- CAPTURE_APPLICATION_BUSY = 1,
- CAPTURE_INVALID_ARGUMENT = 2,
- CAPTURE_NO_MEDIA_FILES = 3,
- CAPTURE_NOT_SUPPORTED = 20
- };
-};
-
-#endif
diff --git a/src/ubuntu/microphone.png b/src/ubuntu/microphone.png
deleted file mode 100644
index 4f2a5cf..0000000
--- a/src/ubuntu/microphone.png
+++ /dev/null
Binary files differ
diff --git a/src/ubuntu/record_off.png b/src/ubuntu/record_off.png
deleted file mode 100644
index adc822c..0000000
--- a/src/ubuntu/record_off.png
+++ /dev/null
Binary files differ
diff --git a/src/ubuntu/record_on.png b/src/ubuntu/record_on.png
deleted file mode 100644
index 985658a..0000000
--- a/src/ubuntu/record_on.png
+++ /dev/null
Binary files differ
diff --git a/src/ubuntu/shoot.png b/src/ubuntu/shoot.png
deleted file mode 100644
index c093b63..0000000
--- a/src/ubuntu/shoot.png
+++ /dev/null
Binary files differ
diff --git a/src/ubuntu/toolbar-left.png b/src/ubuntu/toolbar-left.png
deleted file mode 100644
index 720d7f6..0000000
--- a/src/ubuntu/toolbar-left.png
+++ /dev/null
Binary files differ
diff --git a/src/ubuntu/toolbar-middle.png b/src/ubuntu/toolbar-middle.png
deleted file mode 100644
index 77595bb..0000000
--- a/src/ubuntu/toolbar-middle.png
+++ /dev/null
Binary files differ
diff --git a/src/ubuntu/toolbar-right.png b/src/ubuntu/toolbar-right.png
deleted file mode 100644
index e4e6aa6..0000000
--- a/src/ubuntu/toolbar-right.png
+++ /dev/null
Binary files differ
diff --git a/src/windows8/CaptureProxy.js b/src/windows8/CaptureProxy.js
deleted file mode 100644
index d78dc41..0000000
--- a/src/windows8/CaptureProxy.js
+++ /dev/null
@@ -1,161 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-/*global Windows:true */
-
-var MediaFile = require('org.apache.cordova.media-capture.MediaFile');
-var CaptureError = require('org.apache.cordova.media-capture.CaptureError');
-var CaptureAudioOptions = require('org.apache.cordova.media-capture.CaptureAudioOptions');
-var CaptureImageOptions = require('org.apache.cordova.media-capture.CaptureImageOptions');
-var CaptureVideoOptions = require('org.apache.cordova.media-capture.CaptureVideoOptions');
-var MediaFileData = require('org.apache.cordova.media-capture.MediaFileData');
-
-module.exports = {
-
- captureAudio:function(successCallback, errorCallback, args) {
- var options = args[0];
-
- var audioOptions = new CaptureAudioOptions();
- if (typeof(options.duration) == 'undefined') {
- audioOptions.duration = 3600; // Arbitrary amount, need to change later
- } else if (options.duration > 0) {
- audioOptions.duration = options.duration;
- } else {
- errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
- return;
- }
-
- var cameraCaptureAudioDuration = audioOptions.duration;
- var mediaCaptureSettings;
- var initCaptureSettings = function () {
- mediaCaptureSettings = null;
- mediaCaptureSettings = new Windows.Media.Capture.MediaCaptureInitializationSettings();
- mediaCaptureSettings.streamingCaptureMode = Windows.Media.Capture.StreamingCaptureMode.audio;
- };
-
- initCaptureSettings();
- var mediaCapture = new Windows.Media.Capture.MediaCapture();
- mediaCapture.initializeAsync(mediaCaptureSettings).done(function () {
- Windows.Storage.KnownFolders.musicLibrary.createFileAsync("captureAudio.mp3", Windows.Storage.NameCollisionOption.generateUniqueName).then(function (storageFile) {
- var mediaEncodingProfile = new Windows.Media.MediaProperties.MediaEncodingProfile.createMp3(Windows.Media.MediaProperties.AudioEncodingQuality.auto);
- var stopRecord = function () {
- mediaCapture.stopRecordAsync().then(function (result) {
- storageFile.getBasicPropertiesAsync().then(function (basicProperties) {
- var results = [];
- results.push(new MediaFile(storageFile.name, storageFile.path, storageFile.contentType, basicProperties.dateModified, basicProperties.size));
- successCallback(results);
- }, function () {
- errorCallback(new CaptureError(CaptureError.CAPTURE_NO_MEDIA_FILES));
- });
- }, function () { errorCallback(new CaptureError(CaptureError.CAPTURE_NO_MEDIA_FILES)); });
- };
- mediaCapture.startRecordToStorageFileAsync(mediaEncodingProfile, storageFile).then(function () {
- setTimeout(stopRecord, cameraCaptureAudioDuration * 1000);
- }, function () { errorCallback(new CaptureError(CaptureError.CAPTURE_NO_MEDIA_FILES)); });
- }, function () { errorCallback(new CaptureError(CaptureError.CAPTURE_NO_MEDIA_FILES)); });
- });
- },
-
- captureImage:function (successCallback, errorCallback, args) {
- var options = args[0];
- var imageOptions = new CaptureImageOptions();
- var cameraCaptureUI = new Windows.Media.Capture.CameraCaptureUI();
- cameraCaptureUI.photoSettings.allowCropping = true;
- cameraCaptureUI.photoSettings.maxResolution = Windows.Media.Capture.CameraCaptureUIMaxPhotoResolution.highestAvailable;
- cameraCaptureUI.photoSettings.format = Windows.Media.Capture.CameraCaptureUIPhotoFormat.jpeg;
- cameraCaptureUI.captureFileAsync(Windows.Media.Capture.CameraCaptureUIMode.photo).then(function (file) {
- file.moveAsync(Windows.Storage.KnownFolders.picturesLibrary, "cameraCaptureImage.jpg", Windows.Storage.NameCollisionOption.generateUniqueName).then(function () {
- file.getBasicPropertiesAsync().then(function (basicProperties) {
- var results = [];
- results.push(new MediaFile(file.name, file.path, file.contentType, basicProperties.dateModified, basicProperties.size));
- successCallback(results);
- }, function () {
- errorCallback(new CaptureError(CaptureError.CAPTURE_NO_MEDIA_FILES));
- });
- }, function () {
- errorCallback(new CaptureError(CaptureError.CAPTURE_NO_MEDIA_FILES));
- });
- }, function () { errorCallback(new CaptureError(CaptureError.CAPTURE_NO_MEDIA_FILES)); });
- },
-
- captureVideo:function (successCallback, errorCallback, args) {
- var options = args[0];
- var videoOptions = new CaptureVideoOptions();
- if (options.duration && options.duration > 0) {
- videoOptions.duration = options.duration;
- }
- if (options.limit > 1) {
- videoOptions.limit = options.limit;
- }
- var cameraCaptureUI = new Windows.Media.Capture.CameraCaptureUI();
- cameraCaptureUI.videoSettings.allowTrimming = true;
- cameraCaptureUI.videoSettings.format = Windows.Media.Capture.CameraCaptureUIVideoFormat.mp4;
- cameraCaptureUI.videoSettings.maxDurationInSeconds = videoOptions.duration;
- cameraCaptureUI.captureFileAsync(Windows.Media.Capture.CameraCaptureUIMode.video).then(function (file) {
- file.moveAsync(Windows.Storage.KnownFolders.videosLibrary, "cameraCaptureVedio.mp4", Windows.Storage.NameCollisionOption.generateUniqueName).then(function () {
- file.getBasicPropertiesAsync().then(function (basicProperties) {
- var results = [];
- results.push(new MediaFile(file.name, file.path, file.contentType, basicProperties.dateModified, basicProperties.size));
- successCallback(results);
- }, function () {
- errorCallback(new CaptureError(CaptureError.CAPTURE_NO_MEDIA_FILES));
- });
- }, function () {
- errorCallback(new CaptureError(CaptureError.CAPTURE_NO_MEDIA_FILES));
- });
- }, function () { errorCallback(new CaptureError(CaptureError.CAPTURE_NO_MEDIA_FILES)); });
-
- },
-
- getFormatData: function (successCallback, errorCallback, args) {
- Windows.Storage.StorageFile.getFileFromPathAsync(args[0]).then(
- function (storageFile) {
- var mediaTypeFlag = String(storageFile.contentType).split("/")[0].toLowerCase();
- if (mediaTypeFlag === "audio") {
- storageFile.properties.getMusicPropertiesAsync().then(function (audioProperties) {
- successCallback(new MediaFileData(null, audioProperties.bitrate, 0, 0, audioProperties.duration / 1000));
- }, function () {
- errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
- });
- }
- else if (mediaTypeFlag === "video") {
- storageFile.properties.getVideoPropertiesAsync().then(function (videoProperties) {
- successCallback(new MediaFileData(null, videoProperties.bitrate, videoProperties.height, videoProperties.width, videoProperties.duration / 1000));
- }, function () {
- errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
- });
- }
- else if (mediaTypeFlag === "image") {
- storageFile.properties.getImagePropertiesAsync().then(function (imageProperties) {
- successCallback(new MediaFileData(null, 0, imageProperties.height, imageProperties.width, 0));
- }, function () {
- errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
- });
- }
- else { errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT)); }
- }, function () {
- errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
- }
- );
- }
-};
-
-require("cordova/exec/proxy").add("Capture",module.exports);
diff --git a/src/windows8/MediaFile.js b/src/windows8/MediaFile.js
deleted file mode 100644
index 51465a5..0000000
--- a/src/windows8/MediaFile.js
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-/*global Windows:true */
-
-var MediaFileData = require('org.apache.cordova.media-capture.MediaFileData');
-var CaptureError = require('org.apache.cordova.media-capture.CaptureError');
-
-module.exports = {
-
- getFormatData: function (successCallback, errorCallback, args) {
- Windows.Storage.StorageFile.getFileFromPathAsync(this.fullPath).then(
- function (storageFile) {
- var mediaTypeFlag = String(storageFile.contentType).split("/")[0].toLowerCase();
- if (mediaTypeFlag === "audio") {
- storageFile.properties.getMusicPropertiesAsync().then(
- function (audioProperties) {
- successCallback(new MediaFileData(null, audioProperties.bitrate, 0, 0, audioProperties.duration / 1000));
- }, function () {
- errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
- }
- );
- } else if (mediaTypeFlag === "video") {
- storageFile.properties.getVideoPropertiesAsync().then(
- function (videoProperties) {
- successCallback(new MediaFileData(null, videoProperties.bitrate, videoProperties.height, videoProperties.width, videoProperties.duration / 1000));
- }, function () {
- errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
- }
- );
- } else if (mediaTypeFlag === "image") {
- storageFile.properties.getImagePropertiesAsync().then(
- function (imageProperties) {
- successCallback(new MediaFileData(null, 0, imageProperties.height, imageProperties.width, 0));
- }, function () {
- errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
- }
- );
- } else {
- errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
- }
- }, function () {
- errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
- }
- );
- }
-};
diff --git a/src/wp/Capture.cs b/src/wp/Capture.cs
deleted file mode 100644
index 1f5a327..0000000
--- a/src/wp/Capture.cs
+++ /dev/null
@@ -1,736 +0,0 @@
-/*
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.IO.IsolatedStorage;
-using System.Runtime.Serialization;
-using System.Windows.Media.Imaging;
-using Microsoft.Phone;
-using Microsoft.Phone.Tasks;
-using Microsoft.Xna.Framework.Media;
-using WPCordovaClassLib.Cordova.UI;
-using AudioResult = WPCordovaClassLib.Cordova.UI.AudioCaptureTask.AudioResult;
-using VideoResult = WPCordovaClassLib.Cordova.UI.VideoCaptureTask.VideoResult;
-using System.Windows;
-using System.Diagnostics;
-using Microsoft.Phone.Controls;
-
-namespace WPCordovaClassLib.Cordova.Commands
-{
- /// <summary>
- /// Provides access to the audio, image, and video capture capabilities of the device
- /// </summary>
- public class Capture : BaseCommand
- {
- #region Internal classes (options and resultant objects)
-
- /// <summary>
- /// Represents captureImage action options.
- /// </summary>
- [DataContract]
- public class CaptureImageOptions
- {
- /// <summary>
- /// The maximum number of images the device user can capture in a single capture operation. The value must be greater than or equal to 1 (defaults to 1).
- /// </summary>
- [DataMember(IsRequired = false, Name = "limit")]
- public int Limit { get; set; }
-
- public static CaptureImageOptions Default
- {
- get { return new CaptureImageOptions() { Limit = 1 }; }
- }
- }
-
- /// <summary>
- /// Represents captureAudio action options.
- /// </summary>
- [DataContract]
- public class CaptureAudioOptions
- {
- /// <summary>
- /// The maximum number of audio files the device user can capture in a single capture operation. The value must be greater than or equal to 1 (defaults to 1).
- /// </summary>
- [DataMember(IsRequired = false, Name = "limit")]
- public int Limit { get; set; }
-
- public static CaptureAudioOptions Default
- {
- get { return new CaptureAudioOptions() { Limit = 1 }; }
- }
- }
-
- /// <summary>
- /// Represents captureVideo action options.
- /// </summary>
- [DataContract]
- public class CaptureVideoOptions
- {
- /// <summary>
- /// The maximum number of video files the device user can capture in a single capture operation. The value must be greater than or equal to 1 (defaults to 1).
- /// </summary>
- [DataMember(IsRequired = false, Name = "limit")]
- public int Limit { get; set; }
-
- public static CaptureVideoOptions Default
- {
- get { return new CaptureVideoOptions() { Limit = 1 }; }
- }
- }
-
- /// <summary>
- /// Represents getFormatData action options.
- /// </summary>
- [DataContract]
- public class MediaFormatOptions
- {
- /// <summary>
- /// File path
- /// </summary>
- [DataMember(IsRequired = true, Name = "fullPath")]
- public string FullPath { get; set; }
-
- /// <summary>
- /// File mime type
- /// </summary>
- [DataMember(Name = "type")]
- public string Type { get; set; }
-
- }
-
- /// <summary>
- /// Stores image info
- /// </summary>
- [DataContract]
- public class MediaFile
- {
-
- [DataMember(Name = "name")]
- public string FileName { get; set; }
-
- [DataMember(Name = "fullPath")]
- public string FilePath { get; set; }
-
- [DataMember(Name = "type")]
- public string Type { get; set; }
-
- [DataMember(Name = "lastModifiedDate")]
- public string LastModifiedDate { get; set; }
-
- [DataMember(Name = "size")]
- public long Size { get; set; }
-
- public MediaFile(string filePath, Picture image)
- {
- this.FilePath = filePath;
- this.FileName = System.IO.Path.GetFileName(this.FilePath);
- this.Type = MimeTypeMapper.GetMimeType(FileName);
- this.Size = image.GetImage().Length;
-
- using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
- {
- this.LastModifiedDate = storage.GetLastWriteTime(filePath).DateTime.ToString();
- }
-
- }
-
- public MediaFile(string filePath, Stream stream)
- {
- this.FilePath = filePath;
- this.FileName = System.IO.Path.GetFileName(this.FilePath);
- this.Type = MimeTypeMapper.GetMimeType(FileName);
- this.Size = stream.Length;
-
- using (IsolatedStorageFile storage = IsolatedStorageFile.GetUserStoreForApplication())
- {
- this.LastModifiedDate = storage.GetLastWriteTime(filePath).DateTime.ToString();
- }
- }
- }
-
- /// <summary>
- /// Stores additional media file data
- /// </summary>
- [DataContract]
- public class MediaFileData
- {
- [DataMember(Name = "height")]
- public int Height { get; set; }
-
- [DataMember(Name = "width")]
- public int Width { get; set; }
-
- [DataMember(Name = "bitrate")]
- public int Bitrate { get; set; }
-
- [DataMember(Name = "duration")]
- public int Duration { get; set; }
-
- [DataMember(Name = "codecs")]
- public string Codecs { get; set; }
-
- public MediaFileData(WriteableBitmap image)
- {
- this.Height = image.PixelHeight;
- this.Width = image.PixelWidth;
- this.Bitrate = 0;
- this.Duration = 0;
- this.Codecs = "";
- }
- }
-
- #endregion
-
- /// <summary>
- /// Folder to store captured images
- /// </summary>
- private string isoFolder = "CapturedImagesCache";
-
- /// <summary>
- /// Capture Image options
- /// </summary>
- protected CaptureImageOptions captureImageOptions;
-
- /// <summary>
- /// Capture Audio options
- /// </summary>
- protected CaptureAudioOptions captureAudioOptions;
-
- /// <summary>
- /// Capture Video options
- /// </summary>
- protected CaptureVideoOptions captureVideoOptions;
-
- /// <summary>
- /// Used to open camera application
- /// </summary>
- private CameraCaptureTask cameraTask;
-
- /// <summary>
- /// Used for audio recording
- /// </summary>
- private AudioCaptureTask audioCaptureTask;
-
- /// <summary>
- /// Used for video recording
- /// </summary>
- private VideoCaptureTask videoCaptureTask;
-
- /// <summary>
- /// Stores information about captured files
- /// </summary>
- List<MediaFile> files = new List<MediaFile>();
-
- /// <summary>
- /// Launches default camera application to capture image
- /// </summary>
- /// <param name="options">may contains limit or mode parameters</param>
- public void captureImage(string options)
- {
- try
- {
- try
- {
-
- string args = JSON.JsonHelper.Deserialize<string[]>(options)[0];
- this.captureImageOptions = String.IsNullOrEmpty(args) ? CaptureImageOptions.Default : JSON.JsonHelper.Deserialize<CaptureImageOptions>(args);
-
- }
- catch (Exception ex)
- {
- this.DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION, ex.Message));
- return;
- }
-
-
- cameraTask = new CameraCaptureTask();
- cameraTask.Completed += this.cameraTask_Completed;
- cameraTask.Show();
- }
- catch (Exception e)
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, e.Message));
- }
- }
-
- /// <summary>
- /// Launches our own audio recording control to capture audio
- /// </summary>
- /// <param name="options">may contains additional parameters</param>
- public void captureAudio(string options)
- {
- try
- {
- try
- {
- string args = JSON.JsonHelper.Deserialize<string[]>(options)[0];
- this.captureAudioOptions = String.IsNullOrEmpty(args) ? CaptureAudioOptions.Default : JSON.JsonHelper.Deserialize<CaptureAudioOptions>(args);
-
- }
- catch (Exception ex)
- {
- this.DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION, ex.Message));
- return;
- }
-
- audioCaptureTask = new AudioCaptureTask();
- audioCaptureTask.Completed += audioRecordingTask_Completed;
- audioCaptureTask.Show();
-
- }
- catch (Exception e)
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, e.Message));
- }
- }
-
- /// <summary>
- /// Launches our own video recording control to capture video
- /// </summary>
- /// <param name="options">may contains additional parameters</param>
- public void captureVideo(string options)
- {
- try
- {
- try
- {
- string args = JSON.JsonHelper.Deserialize<string[]>(options)[0];
- this.captureVideoOptions = String.IsNullOrEmpty(args) ? CaptureVideoOptions.Default : JSON.JsonHelper.Deserialize<CaptureVideoOptions>(args);
-
- }
- catch (Exception ex)
- {
- this.DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION, ex.Message));
- return;
- }
-
- videoCaptureTask = new VideoCaptureTask();
- videoCaptureTask.Completed += videoRecordingTask_Completed;
- videoCaptureTask.Show();
-
- }
- catch (Exception e)
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, e.Message));
- }
- }
-
- /// <summary>
- /// Retrieves the format information of the media file.
- /// </summary>
- /// <param name="options"></param>
- public void getFormatData(string options)
- {
- try
- {
- MediaFormatOptions mediaFormatOptions;
- try
- {
- mediaFormatOptions = new MediaFormatOptions();
- string[] optionStrings = JSON.JsonHelper.Deserialize<string[]>(options);
- mediaFormatOptions.FullPath = optionStrings[0];
- mediaFormatOptions.Type = optionStrings[1];
- }
- catch (Exception ex)
- {
- this.DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION, ex.Message));
- return;
- }
-
- if (string.IsNullOrEmpty(mediaFormatOptions.FullPath))
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION));
- }
-
- string mimeType = mediaFormatOptions.Type;
-
- if (string.IsNullOrEmpty(mimeType))
- {
- mimeType = MimeTypeMapper.GetMimeType(mediaFormatOptions.FullPath);
- }
-
- if (mimeType.Equals("image/jpeg"))
- {
- Deployment.Current.Dispatcher.BeginInvoke(() =>
- {
- WriteableBitmap image = ExtractImageFromLocalStorage(mediaFormatOptions.FullPath);
-
- if (image == null)
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "File not found"));
- return;
- }
-
- MediaFileData mediaData = new MediaFileData(image);
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, mediaData));
- });
- }
- else
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR));
- }
- }
- catch (Exception)
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR));
- }
- }
-
- /// <summary>
- /// Opens specified file in media player
- /// </summary>
- /// <param name="options">MediaFile to play</param>
- public void play(string options)
- {
- try
- {
- MediaFile file;
-
- try
- {
- file = String.IsNullOrEmpty(options) ? null : JSON.JsonHelper.Deserialize<MediaFile[]>(options)[0];
-
- }
- catch (Exception ex)
- {
- this.DispatchCommandResult(new PluginResult(PluginResult.Status.JSON_EXCEPTION, ex.Message));
- return;
- }
-
- if (file == null || String.IsNullOrEmpty(file.FilePath))
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "File path is missing"));
- return;
- }
-
- // if url starts with '/' media player throws FileNotFound exception
- Uri fileUri = new Uri(file.FilePath.TrimStart(new char[] { '/', '\\' }), UriKind.Relative);
-
- MediaPlayerLauncher player = new MediaPlayerLauncher();
- player.Media = fileUri;
- player.Location = MediaLocationType.Data;
- player.Show();
-
- this.DispatchCommandResult(new PluginResult(PluginResult.Status.OK));
-
- }
- catch (Exception e)
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, e.Message));
- }
- }
-
-
- /// <summary>
- /// Handles result of capture to save image information
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e">stores information about current captured image</param>
- private void cameraTask_Completed(object sender, PhotoResult e)
- {
-
- if (e.Error != null)
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR));
- return;
- }
-
- switch (e.TaskResult)
- {
- case TaskResult.OK:
- try
- {
- string fileName = System.IO.Path.GetFileName(e.OriginalFileName);
-
- // Save image in media library
- MediaLibrary library = new MediaLibrary();
- Picture image = library.SavePicture(fileName, e.ChosenPhoto);
-
- int orient = ImageExifHelper.getImageOrientationFromStream(e.ChosenPhoto);
- int newAngle = 0;
- switch (orient)
- {
- case ImageExifOrientation.LandscapeLeft:
- newAngle = 90;
- break;
- case ImageExifOrientation.PortraitUpsideDown:
- newAngle = 180;
- break;
- case ImageExifOrientation.LandscapeRight:
- newAngle = 270;
- break;
- case ImageExifOrientation.Portrait:
- default: break; // 0 default already set
- }
-
- Stream rotImageStream = ImageExifHelper.RotateStream(e.ChosenPhoto, newAngle);
-
- // Save image in isolated storage
-
- // we should return stream position back after saving stream to media library
- rotImageStream.Seek(0, SeekOrigin.Begin);
-
- byte[] imageBytes = new byte[rotImageStream.Length];
- rotImageStream.Read(imageBytes, 0, imageBytes.Length);
- rotImageStream.Dispose();
- string pathLocalStorage = this.SaveImageToLocalStorage(fileName, isoFolder, imageBytes);
- imageBytes = null;
- // Get image data
- MediaFile data = new MediaFile(pathLocalStorage, image);
-
- this.files.Add(data);
-
- if (files.Count < this.captureImageOptions.Limit)
- {
- cameraTask.Show();
- }
- else
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, files));
- files.Clear();
- }
- }
- catch (Exception)
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Error capturing image."));
- }
- break;
-
- case TaskResult.Cancel:
- if (files.Count > 0)
- {
- // User canceled operation, but some images were made
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, files));
- files.Clear();
- }
- else
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Canceled."));
- }
- break;
-
- default:
- if (files.Count > 0)
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, files));
- files.Clear();
- }
- else
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Did not complete!"));
- }
- break;
- }
- }
-
- /// <summary>
- /// Handles result of audio recording tasks
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e">stores information about current captured audio</param>
- private void audioRecordingTask_Completed(object sender, AudioResult e)
- {
-
- if (e.Error != null)
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR));
- return;
- }
-
- switch (e.TaskResult)
- {
- case TaskResult.OK:
- try
- {
- // Get image data
- MediaFile data = new MediaFile(e.AudioFileName, e.AudioFile);
-
- this.files.Add(data);
-
- if (files.Count < this.captureAudioOptions.Limit)
- {
- audioCaptureTask.Show();
- }
- else
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, files));
- files.Clear();
- }
- }
- catch (Exception)
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Error capturing audio."));
- }
- break;
-
- case TaskResult.Cancel:
- if (files.Count > 0)
- {
- // User canceled operation, but some audio clips were made
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, files));
- files.Clear();
- }
- else
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Canceled."));
- }
- break;
-
- default:
- if (files.Count > 0)
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, files));
- files.Clear();
- }
- else
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Did not complete!"));
- }
- break;
- }
- }
-
- /// <summary>
- /// Handles result of video recording tasks
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e">stores information about current captured video</param>
- private void videoRecordingTask_Completed(object sender, VideoResult e)
- {
-
- if (e.Error != null)
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR));
- return;
- }
-
- switch (e.TaskResult)
- {
- case TaskResult.OK:
- try
- {
- // Get image data
- MediaFile data = new MediaFile(e.VideoFileName, e.VideoFile);
-
- this.files.Add(data);
-
- if (files.Count < this.captureVideoOptions.Limit)
- {
- videoCaptureTask.Show();
- }
- else
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, files));
- files.Clear();
- }
- }
- catch (Exception)
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Error capturing video."));
- }
- break;
-
- case TaskResult.Cancel:
- if (files.Count > 0)
- {
- // User canceled operation, but some video clips were made
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, files));
- files.Clear();
- }
- else
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Canceled."));
- }
- break;
-
- default:
- if (files.Count > 0)
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.OK, files));
- files.Clear();
- }
- else
- {
- DispatchCommandResult(new PluginResult(PluginResult.Status.ERROR, "Did not complete!"));
- }
- break;
- }
- }
-
- /// <summary>
- /// Extract file from Isolated Storage as WriteableBitmap object
- /// </summary>
- /// <param name="filePath"></param>
- /// <returns></returns>
- private WriteableBitmap ExtractImageFromLocalStorage(string filePath)
- {
- try
- {
-
- var isoFile = IsolatedStorageFile.GetUserStoreForApplication();
-
- using (var imageStream = isoFile.OpenFile(filePath, FileMode.Open, FileAccess.Read))
- {
- var imageSource = PictureDecoder.DecodeJpeg(imageStream);
- return imageSource;
- }
- }
- catch (Exception)
- {
- return null;
- }
- }
-
-
- /// <summary>
- /// Saves captured image in isolated storage
- /// </summary>
- /// <param name="imageFileName">image file name</param>
- /// <param name="imageFolder">folder to store images</param>
- /// <returns>Image path</returns>
- private string SaveImageToLocalStorage(string imageFileName, string imageFolder, byte[] imageBytes)
- {
- if (imageBytes == null)
- {
- throw new ArgumentNullException("imageBytes");
- }
- try
- {
- var isoFile = IsolatedStorageFile.GetUserStoreForApplication();
-
- if (!isoFile.DirectoryExists(imageFolder))
- {
- isoFile.CreateDirectory(imageFolder);
- }
- string filePath = System.IO.Path.Combine("/" + imageFolder + "/", imageFileName);
-
- using (IsolatedStorageFileStream stream = isoFile.CreateFile(filePath))
- {
- stream.Write(imageBytes, 0, imageBytes.Length);
- }
-
- return filePath;
- }
- catch (Exception)
- {
- //TODO: log or do something else
- throw;
- }
- }
-
-
- }
-}
diff --git a/src/wp/UI/AudioCaptureTask.cs b/src/wp/UI/AudioCaptureTask.cs
deleted file mode 100644
index c7ed2d9..0000000
--- a/src/wp/UI/AudioCaptureTask.cs
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-using System;
-using System.IO;
-using System.Windows;
-using Microsoft.Phone.Controls;
-using Microsoft.Phone.Tasks;
-
-namespace WPCordovaClassLib.Cordova.UI
-{
- /// <summary>
- /// Allows an application to launch the Audio Recording application.
- /// Use this to allow users to record audio from your application.
- /// </summary>
- public class AudioCaptureTask
- {
- /// <summary>
- /// Represents recorded audio returned from a call to the Show method of
- /// a WPCordovaClassLib.Cordova.Controls.AudioCaptureTask object
- /// </summary>
- public class AudioResult : TaskEventArgs
- {
- /// <summary>
- /// Initializes a new instance of the AudioResult class.
- /// </summary>
- public AudioResult()
- { }
-
- /// <summary>
- /// Initializes a new instance of the AudioResult class
- /// with the specified Microsoft.Phone.Tasks.TaskResult.
- /// </summary>
- /// <param name="taskResult">Associated Microsoft.Phone.Tasks.TaskResult</param>
- public AudioResult(TaskResult taskResult)
- : base(taskResult)
- { }
-
- /// <summary>
- /// Gets the file name of the recorded audio.
- /// </summary>
- public Stream AudioFile { get; internal set; }
-
- /// <summary>
- /// Gets the stream containing the data for the recorded audio.
- /// </summary>
- public string AudioFileName { get; internal set; }
- }
-
- /// <summary>
- /// Occurs when a audio recording task is completed.
- /// </summary>
- public event EventHandler<AudioResult> Completed;
-
- /// <summary>
- /// Shows Audio Recording application
- /// </summary>
- public void Show()
- {
- Deployment.Current.Dispatcher.BeginInvoke(() =>
- {
- var root = Application.Current.RootVisual as PhoneApplicationFrame;
-
- root.Navigated += new System.Windows.Navigation.NavigatedEventHandler(NavigationService_Navigated);
-
- string baseUrl = "/";
- // dummy parameter is used to always open a fresh version
- root.Navigate(new System.Uri(baseUrl + "Plugins/org.apache.cordova.core.media-capture/AudioRecorder.xaml?dummy=" + Guid.NewGuid().ToString(), UriKind.Relative));
-
- });
- }
-
- /// <summary>
- /// Performs additional configuration of the recording application.
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void NavigationService_Navigated(object sender, System.Windows.Navigation.NavigationEventArgs e)
- {
- if (!(e.Content is AudioRecorder)) return;
-
- (Application.Current.RootVisual as PhoneApplicationFrame).Navigated -= NavigationService_Navigated;
-
- AudioRecorder audioRecorder = (AudioRecorder)e.Content;
-
- if (audioRecorder != null)
- {
- audioRecorder.Completed += this.Completed;
- }
- else if (this.Completed != null)
- {
- this.Completed(this, new AudioResult(TaskResult.Cancel));
- }
- }
- }
-}
diff --git a/src/wp/UI/AudioRecorder.xaml b/src/wp/UI/AudioRecorder.xaml
deleted file mode 100644
index 0fd26ab..0000000
--- a/src/wp/UI/AudioRecorder.xaml
+++ /dev/null
@@ -1,66 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<phone:PhoneApplicationPage
- x:Class="WPCordovaClassLib.Cordova.UI.AudioRecorder"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
- xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- FontFamily="{StaticResource PhoneFontFamilyNormal}"
- FontSize="{StaticResource PhoneFontSizeNormal}"
- Foreground="{StaticResource PhoneForegroundBrush}"
- SupportedOrientations="Portrait" Orientation="Portrait"
- mc:Ignorable="d" d:DesignHeight="768" d:DesignWidth="480"
- shell:SystemTray.IsVisible="True">
-
- <!--LayoutRoot is the root grid where all page content is placed-->
- <Grid x:Name="LayoutRoot" Background="Transparent">
- <Grid.RowDefinitions>
- <RowDefinition Height="Auto"/>
- <RowDefinition Height="*"/>
- </Grid.RowDefinitions>
-
- <!--TitlePanel contains the name of the application and page title-->
- <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="0,17,0,28">
- <TextBlock x:Name="PageTitle" Text="Audio recorder" Margin="9,-7,0,0" Style="{StaticResource PhoneTextTitle1Style}"/>
- </StackPanel>
-
- <!--ContentPanel - place additional content here-->
- <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
- <Button Name="btnStartStop" Content="Start" Height="72" HorizontalAlignment="Left" Margin="156,96,0,0" VerticalAlignment="Top" Width="160" Click="btnStartStop_Click" />
- <Button Name="btnTake" Content="Take" IsEnabled="False" Height="72" HorizontalAlignment="Left" Margin="155,182,0,0" VerticalAlignment="Top" Width="160" Click="btnTake_Click" />
- <TextBlock Height="30" HorizontalAlignment="Left" Margin="168,60,0,0" Name="txtDuration" Text="Duration: 00:00" VerticalAlignment="Top" />
- </Grid>
- </Grid>
-
- <!--Sample code showing usage of ApplicationBar-->
- <!--<phone:PhoneApplicationPage.ApplicationBar>
- <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True">
- <shell:ApplicationBarIconButton IconUri="/Images/appbar_button1.png" Text="Button 1"/>
- <shell:ApplicationBarIconButton IconUri="/Images/appbar_button2.png" Text="Button 2"/>
- <shell:ApplicationBar.MenuItems>
- <shell:ApplicationBarMenuItem Text="MenuItem 1"/>
- <shell:ApplicationBarMenuItem Text="MenuItem 2"/>
- </shell:ApplicationBar.MenuItems>
- </shell:ApplicationBar>
- </phone:PhoneApplicationPage.ApplicationBar>-->
-
-</phone:PhoneApplicationPage>
diff --git a/src/wp/UI/AudioRecorder.xaml.cs b/src/wp/UI/AudioRecorder.xaml.cs
deleted file mode 100644
index bb4b8bc..0000000
--- a/src/wp/UI/AudioRecorder.xaml.cs
+++ /dev/null
@@ -1,330 +0,0 @@
-/*
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-using Microsoft.Phone.Controls;
-using Microsoft.Phone.Tasks;
-using Microsoft.Xna.Framework;
-using Microsoft.Xna.Framework.Audio;
-using System;
-using System.IO;
-using System.IO.IsolatedStorage;
-using System.Windows;
-using System.Windows.Threading;
-using WPCordovaClassLib.Cordova.Commands;
-using AudioResult = WPCordovaClassLib.Cordova.UI.AudioCaptureTask.AudioResult;
-
-namespace WPCordovaClassLib.Cordova.UI
-{
- /// <summary>
- /// Implements Audio Recording application
- /// </summary>
- public partial class AudioRecorder : PhoneApplicationPage
- {
-
- #region Constants
-
- private const string RecordingStartCaption = "Start";
- private const string RecordingStopCaption = "Stop";
-
- private const string LocalFolderName = "AudioCache";
- private const string FileNameFormat = "Audio-{0}.wav";
-
- #endregion
-
- #region Callbacks
-
- /// <summary>
- /// Occurs when a audio recording task is completed.
- /// </summary>
- public event EventHandler<AudioResult> Completed;
-
- #endregion
-
- #region Fields
-
- /// <summary>
- /// Audio source
- /// </summary>
- private Microphone microphone;
-
- /// <summary>
- /// Temporary buffer to store audio chunk
- /// </summary>
- private byte[] buffer;
-
- /// <summary>
- /// Recording duration
- /// </summary>
- private TimeSpan duration;
-
- /// <summary>
- /// Output buffer
- /// </summary>
- private MemoryStream memoryStream;
-
- /// <summary>
- /// Xna game loop dispatcher
- /// </summary>
- DispatcherTimer dtXna;
-
- /// <summary>
- /// Recording result, dispatched back when recording page is closed
- /// </summary>
- private AudioResult result = new AudioResult(TaskResult.Cancel);
-
- /// <summary>
- /// Whether we are recording audio now
- /// </summary>
- private bool IsRecording
- {
- get
- {
- return (this.microphone != null && this.microphone.State == MicrophoneState.Started);
- }
- }
-
- #endregion
-
- /// <summary>
- /// Creates new instance of the AudioRecorder class.
- /// </summary>
- public AudioRecorder()
- {
-
- this.InitializeXnaGameLoop();
-
- // microphone requires special XNA initialization to work
- InitializeComponent();
- }
-
- /// <summary>
- /// Starts recording, data is stored in memory
- /// </summary>
- private void StartRecording()
- {
- this.microphone = Microphone.Default;
- this.microphone.BufferDuration = TimeSpan.FromMilliseconds(500);
-
- this.btnTake.IsEnabled = false;
- this.btnStartStop.Content = RecordingStopCaption;
-
- this.buffer = new byte[microphone.GetSampleSizeInBytes(this.microphone.BufferDuration)];
- this.microphone.BufferReady += new EventHandler<EventArgs>(MicrophoneBufferReady);
-
- MemoryStream stream = new MemoryStream();
- this.memoryStream = stream;
- int numBits = 16;
- int numBytes = numBits / 8;
-
- // inline version from AudioFormatsHelper
- stream.Write(System.Text.Encoding.UTF8.GetBytes("RIFF"), 0, 4);
- stream.Write(BitConverter.GetBytes(0), 0, 4);
- stream.Write(System.Text.Encoding.UTF8.GetBytes("WAVE"), 0, 4);
- stream.Write(System.Text.Encoding.UTF8.GetBytes("fmt "), 0, 4);
- stream.Write(BitConverter.GetBytes(16), 0, 4);
- stream.Write(BitConverter.GetBytes((short)1), 0, 2);
- stream.Write(BitConverter.GetBytes((short)1), 0, 2);
- stream.Write(BitConverter.GetBytes(this.microphone.SampleRate), 0, 4);
- stream.Write(BitConverter.GetBytes(this.microphone.SampleRate * numBytes), 0, 4);
- stream.Write(BitConverter.GetBytes((short)(numBytes)), 0, 2);
- stream.Write(BitConverter.GetBytes((short)(numBits)), 0, 2);
- stream.Write(System.Text.Encoding.UTF8.GetBytes("data"), 0, 4);
- stream.Write(BitConverter.GetBytes(0), 0, 4);
-
- this.duration = new TimeSpan(0);
-
- this.microphone.Start();
- }
-
- /// <summary>
- /// Stops recording
- /// </summary>
- private void StopRecording()
- {
- this.microphone.Stop();
-
- this.microphone.BufferReady -= MicrophoneBufferReady;
-
- this.microphone = null;
-
- btnStartStop.Content = RecordingStartCaption;
-
- // check there is some data
- this.btnTake.IsEnabled = true;
- }
-
- /// <summary>
- /// Handles Start/Stop events
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnStartStop_Click(object sender, RoutedEventArgs e)
- {
-
- if (this.IsRecording)
- {
- this.StopRecording();
- }
- else
- {
- this.StartRecording();
- }
- }
-
- /// <summary>
- /// Handles Take button click
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void btnTake_Click(object sender, RoutedEventArgs e)
- {
- this.result = this.SaveAudioClipToLocalStorage();
-
- if (Completed != null)
- {
- Completed(this, result);
- }
-
- if (this.NavigationService.CanGoBack)
- {
- this.NavigationService.GoBack();
- }
- }
-
- /// <summary>
- /// Handles page closing event, stops recording if needed and dispatches results.
- /// </summary>
- /// <param name="e"></param>
- protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e)
- {
- if (IsRecording)
- {
- StopRecording();
- }
-
- this.FinalizeXnaGameLoop();
-
- base.OnNavigatedFrom(e);
- }
-
- /// <summary>
- /// Copies data from microphone to memory storages and updates recording state
- /// </summary>
- /// <param name="sender"></param>
- /// <param name="e"></param>
- private void MicrophoneBufferReady(object sender, EventArgs e)
- {
- this.microphone.GetData(this.buffer);
- this.memoryStream.Write(this.buffer, 0, this.buffer.Length);
- TimeSpan bufferDuration = this.microphone.BufferDuration;
-
- this.Dispatcher.BeginInvoke(() =>
- {
- this.duration += bufferDuration;
-
- this.txtDuration.Text = "Duration: " +
- this.duration.Minutes.ToString().PadLeft(2, '0') + ":" +
- this.duration.Seconds.ToString().PadLeft(2, '0');
- });
-
- }
-
- /// <summary>
- /// Writes audio data from memory to isolated storage
- /// </summary>
- /// <returns></returns>
- private AudioResult SaveAudioClipToLocalStorage()
- {
- if (this.memoryStream == null || this.memoryStream.Length <= 0)
- {
- return new AudioResult(TaskResult.Cancel);
- }
-
- //this.memoryStream.UpdateWavStream();
- long position = memoryStream.Position;
- memoryStream.Seek(4, SeekOrigin.Begin);
- memoryStream.Write(BitConverter.GetBytes((int)memoryStream.Length - 8), 0, 4);
- memoryStream.Seek(40, SeekOrigin.Begin);
- memoryStream.Write(BitConverter.GetBytes((int)memoryStream.Length - 44), 0, 4);
- memoryStream.Seek(position, SeekOrigin.Begin);
-
- // save audio data to local isolated storage
-
- string filename = String.Format(FileNameFormat, Guid.NewGuid().ToString());
-
- try
- {
- using (IsolatedStorageFile isoFile = IsolatedStorageFile.GetUserStoreForApplication())
- {
-
- if (!isoFile.DirectoryExists(LocalFolderName))
- {
- isoFile.CreateDirectory(LocalFolderName);
- }
-
- string filePath = System.IO.Path.Combine("/" + LocalFolderName + "/", filename);
-
- this.memoryStream.Seek(0, SeekOrigin.Begin);
-
- using (IsolatedStorageFileStream fileStream = isoFile.CreateFile(filePath))
- {
-
- this.memoryStream.CopyTo(fileStream);
- }
-
- AudioResult result = new AudioResult(TaskResult.OK);
- result.AudioFileName = filePath;
-
- result.AudioFile = this.memoryStream;
- result.AudioFile.Seek(0, SeekOrigin.Begin);
-
- return result;
- }
-
-
-
- }
- catch (Exception)
- {
- //TODO: log or do something else
- throw;
- }
- }
-
- /// <summary>
- /// Special initialization required for the microphone: XNA game loop
- /// </summary>
- private void InitializeXnaGameLoop()
- {
- // Timer to simulate the XNA game loop (Microphone is from XNA)
- this.dtXna = new DispatcherTimer();
- this.dtXna.Interval = TimeSpan.FromMilliseconds(33);
- this.dtXna.Tick += delegate { try { FrameworkDispatcher.Update(); } catch { } };
- this.dtXna.Start();
- }
- /// <summary>
- /// Finalizes XNA game loop for microphone
- /// </summary>
- private void FinalizeXnaGameLoop()
- {
- // Timer to simulate the XNA game loop (Microphone is from XNA)
- if (dtXna != null)
- {
- dtXna.Stop();
- dtXna = null;
- }
- }
-
- }
-}
diff --git a/src/wp/UI/VideoCaptureTask.cs b/src/wp/UI/VideoCaptureTask.cs
deleted file mode 100644
index 8770189..0000000
--- a/src/wp/UI/VideoCaptureTask.cs
+++ /dev/null
@@ -1,105 +0,0 @@
-/*
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-using System;
-using System.IO;
-using System.Windows;
-using Microsoft.Phone.Controls;
-using Microsoft.Phone.Tasks;
-
-namespace WPCordovaClassLib.Cordova.UI
-{
- /// <summary>
- /// Allows an application to launch the Video Recording application.
- /// Use this to allow users to record video from your application.
- /// </summary>
- public class VideoCaptureTask
- {
- /// <summary>
- /// Represents recorded video returned from a call to the Show method of
- /// a WPCordovaClassLib.Cordova.Controls.VideoCaptureTask object
- /// </summary>
- public class VideoResult : TaskEventArgs
- {
- /// <summary>
- /// Initializes a new instance of the VideoResult class.
- /// </summary>
- public VideoResult()
- { }
-
- /// <summary>
- /// Initializes a new instance of the VideoResult class
- /// with the specified Microsoft.Phone.Tasks.TaskResult.
- /// </summary>
- /// <param name="taskResult">Associated Microsoft.Phone.Tasks.TaskResult</param>
- public VideoResult(TaskResult taskResult)
- : base(taskResult)
- { }
-
- /// <summary>
- /// Gets the file name of the recorded Video.
- /// </summary>
- public Stream VideoFile { get; internal set; }
-
- /// <summary>
- /// Gets the stream containing the data for the recorded Video.
- /// </summary>
- public string VideoFileName { get; internal set; }
- }
-
- /// <summary>
- /// Occurs when a Video recording task is completed.
- /// </summary>
- public event EventHandler<VideoResult> Completed;
-
- /// <summary>
- /// Shows Video Recording application
- /// </summary>
- public void Show()
- {
- Deployment.Current.Dispatcher.BeginInvoke(() =>
- {
- var root = Application.Current.RootVisual as PhoneApplicationFrame;
-
- root.Navigated += new System.Windows.Navigation.NavigatedEventHandler(NavigationService_Navigated);
-
- string baseUrl = "/";
- // dummy parameter is used to always open a fresh version
- root.Navigate(new System.Uri(baseUrl + "Plugins/org.apache.cordova.core.media-capture/VideoRecorder.xaml?dummy=" + Guid.NewGuid().ToString(), UriKind.Relative));
- });
- }
-
- /// <summary>
- /// Performs additional configuration of the recording application.
- /// </summary>
- private void NavigationService_Navigated(object sender, System.Windows.Navigation.NavigationEventArgs e)
- {
- if (!(e.Content is VideoRecorder)) return;
-
- (Application.Current.RootVisual as PhoneApplicationFrame).Navigated -= NavigationService_Navigated;
-
- VideoRecorder VideoRecorder = (VideoRecorder)e.Content;
-
- if (VideoRecorder != null)
- {
- VideoRecorder.Completed += this.Completed;
- }
- else if (this.Completed != null)
- {
- this.Completed(this, new VideoResult(TaskResult.Cancel));
- }
- }
-
- }
-}
diff --git a/src/wp/UI/VideoRecorder.xaml b/src/wp/UI/VideoRecorder.xaml
deleted file mode 100644
index c78fdb0..0000000
--- a/src/wp/UI/VideoRecorder.xaml
+++ /dev/null
@@ -1,52 +0,0 @@
-<!--
- Licensed to the Apache Software Foundation (ASF) under one
- or more contributor license agreements. See the NOTICE file
- distributed with this work for additional information
- regarding copyright ownership. The ASF licenses this file
- to you under the Apache License, Version 2.0 (the
- "License"); you may not use this file except in compliance
- with the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing,
- software distributed under the License is distributed on an
- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- KIND, either express or implied. See the License for the
- specific language governing permissions and limitations
- under the License.
--->
-<phone:PhoneApplicationPage
- x:Class="WPCordovaClassLib.Cordova.UI.VideoRecorder"
- xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
- xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
- xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
- xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
- mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="480"
- FontFamily="{StaticResource PhoneFontFamilyNormal}"
- FontSize="{StaticResource PhoneFontSizeNormal}"
- Foreground="{StaticResource PhoneForegroundBrush}"
- SupportedOrientations="Landscape" Orientation="LandscapeLeft"
- shell:SystemTray.IsVisible="False">
-
- <Canvas x:Name="LayoutRoot" Background="Transparent" Grid.ColumnSpan="1" Grid.Column="0">
-
- <Rectangle
- x:Name="viewfinderRectangle"
- Width="640"
- Height="480"
- HorizontalAlignment="Left"
- Canvas.Left="80"/>
-
- </Canvas>
-
- <phone:PhoneApplicationPage.ApplicationBar>
- <shell:ApplicationBar IsVisible="True" IsMenuEnabled="True" x:Name="PhoneAppBar" Opacity="0.0">
- <shell:ApplicationBarIconButton IconUri="/Images/appbar.feature.video.rest.png" Text="Record" x:Name="btnStartRecording" Click="StartRecording_Click" />
- <shell:ApplicationBarIconButton IconUri="/Images/appbar.save.rest.png" Text="Take" x:Name="btnTakeVideo" Click="TakeVideo_Click"/>
- </shell:ApplicationBar>
- </phone:PhoneApplicationPage.ApplicationBar>
-
-</phone:PhoneApplicationPage>
diff --git a/src/wp/UI/VideoRecorder.xaml.cs b/src/wp/UI/VideoRecorder.xaml.cs
deleted file mode 100644
index 75bcfd9..0000000
--- a/src/wp/UI/VideoRecorder.xaml.cs
+++ /dev/null
@@ -1,405 +0,0 @@
-/*
- Licensed under the Apache License, Version 2.0 (the "License");
- you may not use this file except in compliance with the License.
- You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
-*/
-
-using System;
-using System.IO;
-using System.IO.IsolatedStorage;
-using System.Windows.Media;
-using System.Windows.Navigation;
-using Microsoft.Phone.Controls;
-using Microsoft.Phone.Shell;
-using Microsoft.Phone.Tasks;
-using VideoResult = WPCordovaClassLib.Cordova.UI.VideoCaptureTask.VideoResult;
-
-namespace WPCordovaClassLib.Cordova.UI
-{
- public partial class VideoRecorder : PhoneApplicationPage
- {
-
- #region Constants
-
- /// <summary>
- /// Caption for record button in ready state
- /// </summary>
- private const string RecordingStartCaption = "Record";
-
- /// <summary>
- /// Caption for record button in recording state
- /// </summary>
- private const string RecordingStopCaption = "Stop";
-
- /// <summary>
- /// Start record icon URI
- /// </summary>
- private const string StartIconUri = "/Images/appbar.feature.video.rest.png";
-
- /// <summary>
- /// Stop record icon URI
- /// </summary>
- private const string StopIconUri = "/Images/appbar.stop.rest.png";
-
- /// <summary>
- /// Folder to save video clips
- /// </summary>
- private const string LocalFolderName = "VideoCache";
-
- /// <summary>
- /// File name format
- /// </summary>
- private const string FileNameFormat = "Video-{0}.mp4";
-
- /// <summary>
- /// Temporary file name
- /// </summary>
- private const string defaultFileName = "NewVideoFile.mp4";
-
- #endregion
-
- #region Callbacks
- /// <summary>
- /// Occurs when a video recording task is completed.
- /// </summary>
- public event EventHandler<VideoResult> Completed;
-
- #endregion
-
- #region Fields
-
- /// <summary>
- /// Viewfinder for capturing video
- /// </summary>
- private VideoBrush videoRecorderBrush;
-
- /// <summary>
- /// Path to save video clip
- /// </summary>
- private string filePath;
-
- /// <summary>
- /// Source for capturing video.
- /// </summary>
- private CaptureSource captureSource;
-
- /// <summary>
- /// Video device
- /// </summary>
- private VideoCaptureDevice videoCaptureDevice;
-
- /// <summary>
- /// File sink so save recording video in Isolated Storage
- /// </summary>
- private FileSink fileSink;
-
- /// <summary>
- /// For managing button and application state
- /// </summary>
- private enum VideoState { Initialized, Ready, Recording, CameraNotSupported };
-
- /// <summary>
- /// Current video state
- /// </summary>
- private VideoState currentVideoState;
-
- /// <summary>
- /// Stream to return result
- /// </summary>
- private MemoryStream memoryStream;
-
- /// <summary>
- /// Recording result, dispatched back when recording page is closed
- /// </summary>
- private VideoResult result = new VideoResult(TaskResult.Cancel);
-
- #endregion
-
- /// <summary>
- /// Initializes components
- /// </summary>
- public VideoRecorder()
- {
- InitializeComponent();
-
- PhoneAppBar = (ApplicationBar)ApplicationBar;
- PhoneAppBar.IsVisible = true;
- btnStartRecording = ((ApplicationBarIconButton)ApplicationBar.Buttons[0]);
- btnTakeVideo = ((ApplicationBarIconButton)ApplicationBar.Buttons[1]);
- }
-
- /// <summary>
- /// Initializes the video recorder then page is loading
- /// </summary>
- protected override void OnNavigatedTo(NavigationEventArgs e)
- {
- base.OnNavigatedTo(e);
- this.InitializeVideoRecorder();
- }
-
- /// <summary>
- /// Disposes camera and media objects then leave the page
- /// </summary>
- protected override void OnNavigatedFrom(NavigationEventArgs e)
- {
- this.DisposeVideoRecorder();
-
- if (this.Completed != null)
- {
- this.Completed(this, result);
- }
- base.OnNavigatedFrom(e);
- }
-
- /// <summary>
- /// Handles TakeVideo button click
- /// </summary>
- private void TakeVideo_Click(object sender, EventArgs e)
- {
- this.result = this.SaveVideoClip();
- this.NavigateBack();
- }
-
- private void NavigateBack()
- {
- if (this.NavigationService.CanGoBack)
- {
- this.NavigationService.GoBack();
- }
- }
-
- /// <summary>
- /// Resaves video clip from temporary directory to persistent
- /// </summary>
- private VideoResult SaveVideoClip()
- {
- try
- {
- using (IsolatedStorageFile isoFile = IsolatedStorageFile.GetUserStoreForApplication())
- {
- if (string.IsNullOrEmpty(filePath) || (!isoFile.FileExists(filePath)))
- {
- return new VideoResult(TaskResult.Cancel);
- }
-
- string fileName = String.Format(FileNameFormat, Guid.NewGuid().ToString());
- string newPath = Path.Combine("/" + LocalFolderName + "/", fileName);
- isoFile.CopyFile(filePath, newPath);
- isoFile.DeleteFile(filePath);
-
- memoryStream = new MemoryStream();
- using (IsolatedStorageFileStream fileStream = new IsolatedStorageFileStream(newPath, FileMode.Open, isoFile))
- {
- fileStream.CopyTo(memoryStream);
- }
-
- VideoResult result = new VideoResult(TaskResult.OK);
- result.VideoFileName = newPath;
- result.VideoFile = this.memoryStream;
- result.VideoFile.Seek(0, SeekOrigin.Begin);
- return result;
- }
-
- }
- catch (Exception)
- {
- return new VideoResult(TaskResult.None);
- }
- }
-
- /// <summary>
- /// Updates the buttons on the UI thread based on current state.
- /// </summary>
- /// <param name="currentState">current UI state</param>
- private void UpdateUI(VideoState currentState)
- {
- Dispatcher.BeginInvoke(delegate
- {
- switch (currentState)
- {
- case VideoState.CameraNotSupported:
- btnStartRecording.IsEnabled = false;
- btnTakeVideo.IsEnabled = false;
- break;
-
- case VideoState.Initialized:
- btnStartRecording.Text = RecordingStartCaption;
- btnStartRecording.IconUri = new Uri(StartIconUri, UriKind.Relative);
- btnTakeVideo.IsEnabled = false;
- break;
-
- case VideoState.Ready:
- btnStartRecording.Text = RecordingStartCaption;
- btnStartRecording.IconUri = new Uri(StartIconUri, UriKind.Relative);
- btnTakeVideo.IsEnabled = true;
- break;
-
- case VideoState.Recording:
- btnStartRecording.Text = RecordingStopCaption;
- btnStartRecording.IconUri = new Uri(StopIconUri, UriKind.Relative);
- btnTakeVideo.IsEnabled = false;
- break;
-
- default:
- break;
- }
- currentVideoState = currentState;
- });
- }
-
- /// <summary>
- /// Initializes VideoRecorder
- /// </summary>
- public void InitializeVideoRecorder()
- {
- if (captureSource == null)
- {
- captureSource = new CaptureSource();
- fileSink = new FileSink();
- videoCaptureDevice = CaptureDeviceConfiguration.GetDefaultVideoCaptureDevice();
-
- if (videoCaptureDevice != null)
- {
- videoRecorderBrush = new VideoBrush();
- videoRecorderBrush.SetSource(captureSource);
- viewfinderRectangle.Fill = videoRecorderBrush;
- captureSource.Start();
- this.UpdateUI(VideoState.Initialized);
- }
- else
- {
- this.UpdateUI(VideoState.CameraNotSupported);
- }
- }
- }
-
- /// <summary>
- /// Sets recording state: start recording
- /// </summary>
- private void StartVideoRecording()
- {
- try
- {
- if ((captureSource.VideoCaptureDevice != null) && (captureSource.State == CaptureState.Started))
- {
- captureSource.Stop();
- fileSink.CaptureSource = captureSource;
- filePath = System.IO.Path.Combine("/" + LocalFolderName + "/", defaultFileName);
-
- using (IsolatedStorageFile isoFile = IsolatedStorageFile.GetUserStoreForApplication())
- {
- if (!isoFile.DirectoryExists(LocalFolderName))
- {
- isoFile.CreateDirectory(LocalFolderName);
- }
-
- if (isoFile.FileExists(filePath))
- {
- isoFile.DeleteFile(filePath);
- }
- }
-
- fileSink.IsolatedStorageFileName = filePath;
- }
-
- if (captureSource.VideoCaptureDevice != null
- && captureSource.State == CaptureState.Stopped)
- {
- captureSource.Start();
- }
- this.UpdateUI(VideoState.Recording);
- }
- catch (Exception)
- {
- this.result = new VideoResult(TaskResult.None);
- this.NavigateBack();
- }
- }
-
- /// <summary>
- /// Sets the recording state: stop recording
- /// </summary>
- private void StopVideoRecording()
- {
- try
- {
- if ((captureSource.VideoCaptureDevice != null) && (captureSource.State == CaptureState.Started))
- {
- captureSource.Stop();
- fileSink.CaptureSource = null;
- fileSink.IsolatedStorageFileName = null;
- this.StartVideoPreview();
- }
- }
- catch (Exception)
- {
- this.result = new VideoResult(TaskResult.None);
- this.NavigateBack();
- }
- }
-
- /// <summary>
- /// Sets the recording state: display the video on the viewfinder.
- /// </summary>
- private void StartVideoPreview()
- {
- try
- {
- if ((captureSource.VideoCaptureDevice != null) && (captureSource.State == CaptureState.Stopped))
- {
- videoRecorderBrush.SetSource(captureSource);
- viewfinderRectangle.Fill = videoRecorderBrush;
- captureSource.Start();
- this.UpdateUI(VideoState.Ready);
- }
- }
- catch (Exception)
- {
- this.result = new VideoResult(TaskResult.None);
- this.NavigateBack();
- }
- }
-
- /// <summary>
- /// Starts video recording
- /// </summary>
- private void StartRecording_Click(object sender, EventArgs e)
- {
- if (currentVideoState == VideoState.Recording)
- {
- this.StopVideoRecording();
- }
- else
- {
- this.StartVideoRecording();
- }
- }
-
- /// <summary>
- /// Releases resources
- /// </summary>
- private void DisposeVideoRecorder()
- {
- if (captureSource != null)
- {
- if ((captureSource.VideoCaptureDevice != null) && (captureSource.State == CaptureState.Started))
- {
- captureSource.Stop();
- }
- captureSource = null;
- videoCaptureDevice = null;
- fileSink = null;
- videoRecorderBrush = null;
- }
- }
-
- }
-}
diff --git a/www/CaptureAudioOptions.js b/www/CaptureAudioOptions.js
deleted file mode 100644
index b5f5605..0000000
--- a/www/CaptureAudioOptions.js
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-/**
- * Encapsulates all audio capture operation configuration options.
- */
-var CaptureAudioOptions = function(){
- // Upper limit of sound clips user can record. Value must be equal or greater than 1.
- this.limit = 1;
- // Maximum duration of a single sound clip in seconds.
- this.duration = 0;
-};
-
-module.exports = CaptureAudioOptions;
diff --git a/www/CaptureError.js b/www/CaptureError.js
deleted file mode 100644
index 6fb7a47..0000000
--- a/www/CaptureError.js
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-/**
- * The CaptureError interface encapsulates all errors in the Capture API.
- */
-var CaptureError = function(c) {
- this.code = c || null;
-};
-
-// Camera or microphone failed to capture image or sound.
-CaptureError.CAPTURE_INTERNAL_ERR = 0;
-// Camera application or audio capture application is currently serving other capture request.
-CaptureError.CAPTURE_APPLICATION_BUSY = 1;
-// Invalid use of the API (e.g. limit parameter has value less than one).
-CaptureError.CAPTURE_INVALID_ARGUMENT = 2;
-// User exited camera application or audio capture application before capturing anything.
-CaptureError.CAPTURE_NO_MEDIA_FILES = 3;
-// The requested capture operation is not supported.
-CaptureError.CAPTURE_NOT_SUPPORTED = 20;
-
-module.exports = CaptureError;
diff --git a/www/CaptureImageOptions.js b/www/CaptureImageOptions.js
deleted file mode 100644
index 1fb5615..0000000
--- a/www/CaptureImageOptions.js
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-/**
- * Encapsulates all image capture operation configuration options.
- */
-var CaptureImageOptions = function(){
- // Upper limit of images user can take. Value must be equal or greater than 1.
- this.limit = 1;
-};
-
-module.exports = CaptureImageOptions;
diff --git a/www/CaptureVideoOptions.js b/www/CaptureVideoOptions.js
deleted file mode 100644
index adb306f..0000000
--- a/www/CaptureVideoOptions.js
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-/**
- * Encapsulates all video capture operation configuration options.
- */
-var CaptureVideoOptions = function(){
- // Upper limit of videos user can record. Value must be equal or greater than 1.
- this.limit = 1;
- // Maximum duration of a single video clip in seconds.
- this.duration = 0;
-};
-
-module.exports = CaptureVideoOptions;
diff --git a/www/ConfigurationData.js b/www/ConfigurationData.js
deleted file mode 100644
index 57cfbf5..0000000
--- a/www/ConfigurationData.js
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-/**
- * Encapsulates a set of parameters that the capture device supports.
- */
-function ConfigurationData() {
- // The ASCII-encoded string in lower case representing the media type.
- this.type = null;
- // The height attribute represents height of the image or video in pixels.
- // In the case of a sound clip this attribute has value 0.
- this.height = 0;
- // The width attribute represents width of the image or video in pixels.
- // In the case of a sound clip this attribute has value 0
- this.width = 0;
-}
-
-module.exports = ConfigurationData;
diff --git a/www/MediaFile.js b/www/MediaFile.js
deleted file mode 100644
index 17f12ef..0000000
--- a/www/MediaFile.js
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-var utils = require('cordova/utils'),
- exec = require('cordova/exec'),
- File = require('org.apache.cordova.file.File'),
- CaptureError = require('./CaptureError');
-/**
- * Represents a single file.
- *
- * name {DOMString} name of the file, without path information
- * fullPath {DOMString} the full path of the file, including the name
- * type {DOMString} mime type
- * lastModifiedDate {Date} last modified date
- * size {Number} size of the file in bytes
- */
-var MediaFile = function(name, localURL, type, lastModifiedDate, size){
- MediaFile.__super__.constructor.apply(this, arguments);
-};
-
-utils.extend(MediaFile, File);
-
-/**
- * Request capture format data for a specific file and type
- *
- * @param {Function} successCB
- * @param {Function} errorCB
- */
-MediaFile.prototype.getFormatData = function(successCallback, errorCallback) {
- if (typeof this.fullPath === "undefined" || this.fullPath === null) {
- errorCallback(new CaptureError(CaptureError.CAPTURE_INVALID_ARGUMENT));
- } else {
- exec(successCallback, errorCallback, "Capture", "getFormatData", [this.localURL, this.type]);
- }
-};
-
-module.exports = MediaFile;
diff --git a/www/MediaFileData.js b/www/MediaFileData.js
deleted file mode 100644
index 75e467b..0000000
--- a/www/MediaFileData.js
+++ /dev/null
@@ -1,39 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-/**
- * MediaFileData encapsulates format information of a media file.
- *
- * @param {DOMString} codecs
- * @param {long} bitrate
- * @param {long} height
- * @param {long} width
- * @param {float} duration
- */
-var MediaFileData = function(codecs, bitrate, height, width, duration){
- this.codecs = codecs || null;
- this.bitrate = bitrate || 0;
- this.height = height || 0;
- this.width = width || 0;
- this.duration = duration || 0;
-};
-
-module.exports = MediaFileData;
diff --git a/www/capture.js b/www/capture.js
deleted file mode 100644
index fd17474..0000000
--- a/www/capture.js
+++ /dev/null
@@ -1,96 +0,0 @@
-/*
- *
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- *
-*/
-
-var exec = require('cordova/exec'),
- MediaFile = require('./MediaFile');
-
-/**
- * Launches a capture of different types.
- *
- * @param (DOMString} type
- * @param {Function} successCB
- * @param {Function} errorCB
- * @param {CaptureVideoOptions} options
- */
-function _capture(type, successCallback, errorCallback, options) {
- var win = function(pluginResult) {
- var mediaFiles = [];
- var i;
- for (i = 0; i < pluginResult.length; i++) {
- var mediaFile = new MediaFile();
- mediaFile.name = pluginResult[i].name;
-
- // Backwards compatibility
- mediaFile.localURL = pluginResult[i].localURL || pluginResult[i].fullPath;
- mediaFile.fullPath = pluginResult[i].fullPath;
- mediaFile.type = pluginResult[i].type;
- mediaFile.lastModifiedDate = pluginResult[i].lastModifiedDate;
- mediaFile.size = pluginResult[i].size;
- mediaFiles.push(mediaFile);
- }
- successCallback(mediaFiles);
- };
- exec(win, errorCallback, "Capture", type, [options]);
-}
-/**
- * The Capture interface exposes an interface to the camera and microphone of the hosting device.
- */
-function Capture() {
- this.supportedAudioModes = [];
- this.supportedImageModes = [];
- this.supportedVideoModes = [];
-}
-
-/**
- * Launch audio recorder application for recording audio clip(s).
- *
- * @param {Function} successCB
- * @param {Function} errorCB
- * @param {CaptureAudioOptions} options
- */
-Capture.prototype.captureAudio = function(successCallback, errorCallback, options){
- _capture("captureAudio", successCallback, errorCallback, options);
-};
-
-/**
- * Launch camera application for taking image(s).
- *
- * @param {Function} successCB
- * @param {Function} errorCB
- * @param {CaptureImageOptions} options
- */
-Capture.prototype.captureImage = function(successCallback, errorCallback, options){
- _capture("captureImage", successCallback, errorCallback, options);
-};
-
-/**
- * Launch device camera application for recording video(s).
- *
- * @param {Function} successCB
- * @param {Function} errorCB
- * @param {CaptureVideoOptions} options
- */
-Capture.prototype.captureVideo = function(successCallback, errorCallback, options){
- _capture("captureVideo", successCallback, errorCallback, options);
-};
-
-
-module.exports = new Capture();