How to use this cordova plugin

情到浓时终转凉″ 提交于 2020-06-09 07:05:30

问题


I am building a video sharing app with ionic. I want when users wants to upload videos and it will give them a preview where they can trim the video, now I found the Cordova plugin that can do it, but I don't knowhow to use it Here is the plugin

cordova-plugin-video-trim from https://www.npmjs.com/package/cordova-plugin-video-trim

Now please, how can I use this plugin in my ionic application


回答1:


Go to the project root and run these commands:

cordova plugin add cordova-plugin-video-trim

then run:

npm i cordova-plugin-video-trim

then open your app.module.ts and import it and put it in providers:

import {YourPlugin} from './path-to-your-plugin-in-node_modules';

@NgModule({
  ...
  providers: [
    ...
    YourPlugin
    ...
  ],
  ...
})
export class AppModule {
}

and now you can import it in your component controller (.page.ts file) and make an instance of it in the constructor and use its methods:

import {YourPlugin} from './path-to-your-plugin-in-node_modules';

@Component({
  selector: 'app-somepage',
  templateUrl: './somepage.page.html',
  styleUrls: ['./somepage.page.scss'],
})
export class SomepagePage implements OnInit, AfterViewInit {

  constructor(private plugin: YourPlugin) {
  }
}


来源:https://stackoverflow.com/questions/62184451/how-to-use-this-cordova-plugin

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!