我在下面尝试了什么:
第 1 步: 尝试点击此链接https://ionicframework.com/docs/v5/native/photo-library.
第 2 步: 我已经在下面的命令下安装了这个
$ ionic cordova 插件添加 cordova-plugin-photo-library
$ npm install @awesome-cordova-plugins/photo-library
第三步: 以下代码供参考
import { PhotoLibrary } from '@awesome-cordova-plugins/photo-library/ngx';
constructor(private photoLibrary: PhotoLibrary) { }
this.photoLibrary.requestAuthorization().then(() => {
this.photoLibrary.getLibrary().subscribe({
next: library => {
library.forEach(function(libraryItem) {
console.log(libraryItem.id); // ID of the photo
console.log(libraryItem.photoURL); // Cross-platform access to photo
console.log(libraryItem.thumbnailURL);// Cross-platform access to thumbnail
console.log(libraryItem.fileName); // array of ids of appropriate AlbumItem, only of includeAlbumsData was used
});
},
error: err => { console.log('could not get photos'); },
complete: () => { console.log('done getting photos'); }
});
})
.catch(err => console.log('permissions weren\'t granted'));
我面临的问题:
基于我的研究的解决方法
onst options: GetLibraryOptions = {includeVideos:true};
方法中提供getLibrary()
作为参数。如何使用此选项打印图库中的视频。
请告诉我如何在不打开图库的情况下从图库中获取所有视频和图像。