Coder Social home page Coder Social logo

cameraroll-phonegap-plugin's Introduction

PhoneGap CameraRoll plugin

WARNING: April 12th, 2014: this plugin is in a dormant state. It only supports iOS a little. You're better off not using this. I may pick this up in the future... but for now: look elsewhere.

for iOS, by Eddy Verbruggen

  1. Description
  2. Installation 2. Automatically (CLI / Plugman) 2. Manually 2. PhoneGap Build
  3. Usage
  4. License

1. Description

This plugin allows you to use photos from the cameraroll (photo album) of the mobile device.

  • For Cordova 3+
  • Compatible with Cordova Plugman
  • Submitted and waiting for approval at PhoneGap Build (more information)
  • You can count the total number of photos and/or videos.
  • You can find photos only (videos would likely crash your app).
  • You can limit the number of returned photos by passing a max parameter.
  • All methods work without showing the cameraroll to the user. Your app never looses control.

iOS specifics

  • Supported methods: find, count.

Android specifics

  • Work in progress..

2. Installation

Automatically (CLI / Plugman)

CameraRoll is compatible with Cordova Plugman and ready for the PhoneGap 3.0 CLI, here's how it works with the CLI:

$ phonegap local plugin add https://github.com/EddyVerbruggen/CameraRoll-PhoneGap-Plugin.git

or

$ cordova plugin add https://github.com/EddyVerbruggen/CameraRoll-PhoneGap-Plugin.git

don't forget to run this command afterwards:

$ cordova build

Manually

1. Add the following xml to your config.xml:

<!-- for iOS -->
<feature name="CameraRoll">
	<param name="ios-package" value="CameraRoll" />
</feature>
<!-- for Android as plugin (deprecated) -->
<plugin name="Calendar" value="nl.xservices.plugins.CameraRoll"/>
<!-- for Android as feature -->
<feature name="CameraRoll">
  <param name="android-package" value="nl.xservices.plugins.CameraRoll" />
</feature>

2. Grab a copy of CameraRoll.js, add it to your project and reference it in index.html:

<script type="text/javascript" src="js/CameraRoll.js"></script>

3. Download the source files for iOS and/or Android and copy them to your project.

iOS: Copy the four .h and .m to platforms/ios/<ProjectName>/Plugins

Android: Copy CameraRoll.java to platforms/android/src/nl/xservices/plugins (create the folders)

PhoneGap Build

Using CameraRoll with PhoneGap Build requires these simple steps:

1. Add the following xml to your config.xml to always use the latest version of this plugin:

<gap:plugin name="nl.x-services.plugins.cameraroll" />

or to use this exact version:

<gap:plugin name="nl.x-services.plugins.cameraroll" version="1.0" />

2. Reference the JavaScript code in your index.html:

<!-- below <script src="phonegap.js"></script> -->
<script src="js/plugins/CameraRoll.js"></script>

3. Usage

Counting the number of photos in the photo library:

  // prep some variables
  var includePhotos = true;
  var includeVideos = false;
  window.plugins.cameraRoll.count(includePhotos, includeVideos, showImageCount, cameraRollError);

  function showImageCount(count) {
    alert("Found " + count + " photos");
  }

Find and show max 10 photos from the photo library:

  var maxPhotos = 10;
  window.plugins.cameraRoll.find(maxPhotos, cameraRollFindResult, cameraRollError);

  function cameraRollFindResult(photos) {
    var content = '';
    for (var i in photos) {
      content += '<br/><img src="data:image/png;base64,'+photos[i]+'" style="max-width:240px"/>';
    }
    document.getElementById("imgContainer").innerHTML = content;
}

4. License

The MIT License (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

cameraroll-phonegap-plugin's People

Contributors

bitdeli-chef avatar eddyverbruggen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

cameraroll-phonegap-plugin's Issues

building issue on IOS /Android

Hi
I try to integrate this plugin with phonegap, having these issues:
android: when adding and then building as cordova build ...throwing error
IOS: it builds correctly and when i played on emulator: showing this error:
ERROR: Method 'count:' not defined in Plugin 'CameraRoll'
2014-01-08 20:23:24.437 PhotoApp[6475:c07] -[CDVCommandQueue executePending] [Line 127] FAILED pluginJSON = [
"CameraRoll565538587",
"CameraRoll",
"count",
[
true,
false
]
]

any idea how to resolve it?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.