SalvatoreAD / media

Capacitor plugin to activate extra media features

Home Page:https://capacitor.ionicframework.com/docs/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool


Capacitor Media

@capacitor-community/media

Capacitor community plugin for enabling extra media capabilities


Sponsors

Intenseloop

Maintainers

Maintainer GitHub Social
Stewan Silva stewones @StewanSilva

Notice πŸš€

We're starting fresh under an official org. If you were using the previous npm package capacitor-media, please update your package.json to @capacitor-community/media. Check out changelog for more info.

Installation

Using npm:

npm install @capacitor-community/media

Using yarn:

yarn add @capacitor-community/media

Sync native files:

npx cap sync

API

  • savePhoto
  • saveVideo
  • saveGif
  • createAlbum
  • getAlbums
  • getMedias only ios for now

Usage

import { Media } from '@capacitor-community/media';

//
// Save video to a specific album
Media.saveVideo({ path: '/path/to/the/file', album: 'My Album' })
  .then(console.log) // on android it returns {filePath: 'uri to media'}
  .catch(console.log);

//
// Get a list of user albums
Media.getAlbums()
  .then(console.log) // -> { albums: [{name:'My Album', identifier:'A1-B2-C3-D4'}, {name:'My Another Album', identifier:'E5-F6-G7-H8'}]}
  .catch(console.log);

Disclaimer

Make sure you pass the correct album parameter according to the platform

album: this.platform.is('ios') ? album.identifier : album.name;

iOS setup

  • ionic start my-cap-app --capacitor
  • cd my-cap-app
  • npm install β€”-save @capacitor-community/media
  • mkdir www && touch www/index.html
  • npx cap add ios
  • npx cap open ios
  • sign your app at xcode (general tab)

Tip: every time you change a native code you may need to clean up the cache (Product > Clean build folder) and then run the app again.

Android setup

  • ionic start my-cap-app --capacitor
  • cd my-cap-app
  • npm install β€”-save @capacitor-community/media
  • mkdir www && touch www/index.html
  • npx cap add android
  • npx cap open android
  • [extra step] in android case we need to tell Capacitor to initialise the plugin:

on your MainActivity.java file add import com.getcapacitor.community.media.MediaPlugin; and then inside the init callback add(MediaPlugin.class);

Now you should be set to go. Try to run your client using ionic cap run android --livereload.

Tip: every time you change a native code you may need to clean up the cache (Build > Clean Project | Build > Rebuild Project) and then run the app again.

Example

Still WIP. Please send your PR with more examples!

License

MIT

Contributors ✨

Thanks goes to these wonderful people (emoji key):


Stew

πŸ’» πŸ“– 🚧

Zachary Keeton

πŸ’»

Pierre Grimaud

πŸ“–

Talles Alves

🚧

Zyad Yasser

🚧

Manuel RodrΓ­guez

πŸ’» 🚧

Michael

πŸ’»

This project follows the all-contributors specification. Contributions of any kind welcome!

About

Capacitor plugin to activate extra media features

https://capacitor.ionicframework.com/docs/


Languages

Language:Swift 30.7%Language:TypeScript 23.5%Language:Java 23.3%Language:SCSS 13.1%Language:JavaScript 3.5%Language:Ruby 2.4%Language:HTML 2.2%Language:Objective-C 1.5%