如何使用此Cordova插件 [英] How to use this cordova plugin
问题描述
我正在使用ionic构建视频共享应用. 我想当用户想要上传视频时,它将为他们提供预览,以便他们可以修剪视频.现在,我找到了可以使用它的Cordova插件,但是我不知道如何使用它 这是插件
来自https://www.npmjs.com/package/cordova-plugin-video-trim
的 cordova-plugin-video-trim
现在,请问如何在离子应用程序中使用此插件
转到项目根目录并运行以下命令:
cordova plugin add cordova-plugin-video-trim
然后运行:
npm i cordova-plugin-video-trim
然后打开您的app.module.ts并将其导入并放入提供程序中:
import {YourPlugin} from './path-to-your-plugin-in-node_modules';
@NgModule({
...
providers: [
...
YourPlugin
...
],
...
})
export class AppModule {
}
现在,您可以将其导入到组件控制器(.page.ts文件)中,并在构造函数中创建它的实例,并使用其方法:
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) {
}
}
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
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) {
}
}
这篇关于如何使用此Cordova插件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!