Git Product home page Git Product logo

cordova-plugin-instagram-assets-picker's Introduction

Cordova Instagram Assets Picker Plugin 📷 📹 ✂️

This is a cordova plugin for iOS that provides an image picker like Instagram, allowing you to crop photo and video with GPUImage.

GIF

The app in the GIF shows how to use the cordova-plugin-video-editor and is using this plugin. Here is a YouTube video showing more of it. Here is the source code for the app shown in the gif and video.

I am no longer maintaining this project. PRs are welcome.

Installation

cordova plugin add cordova-plugin-instagram-assets-picker

InstagramAssetsPicker will be available globally after deviceready.

To install the latest code from this repo (may be unstable) -

cordova plugin add https://github.com/rossmartin/cordova-plugin-instagram-assets-picker.git

You may have to update your Xcode project Header Search Paths manually

If you see Could not locate build.xcconfig, you will need to set HEADER_SEARCH_PATHS manually. in the CLI output when adding the plugin you will need to add an entry to your Xcode project Header Search Paths. I have this step automated but for some reason it isn't working for everyone. To do this navigate to your project Build Settings and add "$(SRCROOT)/$(PRODUCT_NAME)/cordova-plugin-instagram-assets-picker/GPUImageHeaders" to your Header Search Paths. See the screenshot below for reference -

PNG

Usage

Show the picker with videos, photos, or all media

InstagramAssetsPicker.getMedia(
  function(result) { // success cb
    console.log('getMedia success, result: ', JSON.stringify(result, null, 2));
    // result will be an object with at least a phAssetId, filePath, and type property
    // you will only get the rect object when 'cropAfterSelect' is false
    // the rect object is required for the cropAsset function documented below

    /* example of result when the 'cropAfterSelect' option is set to false
    {
      phAssetId: "A1785F1A-EF0F-458C-9AF9-C439981CE0FB/L0/001",
      type: "video",
      rect: {
        Width: 0.5625000293366611,
        Height: 0.9999999823048711,
        Y: 0,
        X: 0.2496093880181434
      },
      filePath: "file:///Users/rossmartin/Library/Developer/CoreSimulator/Devices/6465544C-C262-4EA8-BA7C-8BAB4AB98597/data/Media/DCIM/100APPLE/IMG_0006.m4v"
    }
    */
  },
  function(err) { // error cb
    console.log('getMedia error, err: ', err);
  },
  { // options
    type: 'video', // accepts 'photo', 'video', or 'all' - defaults to all
    cropAfterSelect: false, // see the note above for when this is false - defaults to false
    showGrid: false // determines whether to show the grid for cropping - defaults to false
  }
);

A note about the cropAfterSelect option with getMedia

The reason this option exists is to provide a better user experience. It takes time to crop an asset with GPUImage so in most cases for a better UX you'll want to call cropAsset later with the result from the getMedia function. This also allows showing your own UI loading indicator while the cropping is being performed.

A note about cropping using getMedia or cropAsset

The iOS simulator will not finish a crop using getMedia (with cropAfterSelect set to true) or cropAsset. It works fine on a device. I will be looking into why it doesn't work on the simulator.

Crop a media asset from the device library

InstagramAssetsPicker.cropAsset(
  function(result) { // success cb
    // result is an object with a filePath and type property
    console.log('cropAsset success, result: ', result);
    /* example of result
    {
      type: "video",
      filePath: "file:///Users/rossmartin/Library/Developer/CoreSimulator/Devices/6465544C-C262-4EA8-BA7C-8BAB4AB98597/data/Media/DCIM/100APPLE/IMG_0006.m4v"
    }
    */
  },
  function(err) { // error cb
    console.log('cropAsset error, err: ', err);
  },
  { // options, both properties below are required
    phAssetId: "A1785F1A-EF0F-458C-9AF9-C439981CE0FB/L0/001",
    rect: {
      Width: 1,
      Height: 0.5625,
      Y: 0.249609375,
      X: 0
    }
  }
);

Author

Ross Martin

Reference

InstagramAssetsPicker (Modified by me to add features for this plugin and subtle improvements.)

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.

cordova-plugin-instagram-assets-picker's People

Contributors

rossmartin avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

cordova-plugin-instagram-assets-picker's Issues

Error: Cannot read property 'indexOf' of undefined & Could not resolve external type c:

Hi Ross,

I have tried to use it but running into a lot of warning: Could not resolve external type c: xxxxxxxx
Then I tryied to uninstall it and it shows me this error:
Instagram Assets Picker BeforePluginUninstall.js, attempting to modify build.xcconfig xcConfigBuildFilePath: /Users/xxxxxxxx/platforms/ios/cordova/build.xcconfig Error: Cannot read property 'indexOf' of undefined

Black screen

Even though I select a video in the video picker below, the above screen stays black. Using in an ionic 1 project.

Can't build iOS after install

Tried the plugin and can't somehow build on iOS.

Caught this in the build output:
Check dependencies warning: skipping file '/App/platforms/ios/App/Plugins/cordova-plugin-instagram-assets-picker/GPUImageHeaders' (unexpected file type 'folder' in Frameworks & Libraries build phase)

Android build works fine. Got the latest Cordova 6.1.1 and Xcode 7.2.

Any ideas?

Multiselect

Hi can you add options like multiple select and select media(image,video) from specific folder ?!

Android support

Woow!

This is exactly what I have been looking for, thank you so much!

Are you planning to support Android also?

[Playback] ❗️Failed to queue any items

Hi, I successfully installed the plugin in ios. But displaying selected videos takes very long time, or sometimes even no videos are displayed after user select. The log in XCode says:
[Playback] ❗️Failed to queue any items
Anyone help?? Thanks!

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.