如何使用cordova检查this/any文件夹是否包含android中的任何mp4文件?

How to check whether this/any folder contains any mp4 file or not in android using cordova?

假设我在 android 中有一个文件夹,它可能在内部或外部存储中: "VIKAS KOHLI" 文件夹,我想查看 "VIKAS KOHLI" 是否有任何 .mp4 文件。 那我如何使用 cordova 来检查呢?

提前致谢!

您需要使用文件插件。这里有一些基本的示例代码:

window.resolveLocalFileSystemURL(DIR_FULL_PATH, function(dirEntry) {
    var directoryReader = dirEntry.createReader();
    console.log(dirEntry);

    // Get a list of all the entries in the directory
    directoryReader.readEntries(success,fail);
});

function success(entries) {
    var i;
    for (i=0; i<entries.length; i++) {
    //Here you can check the entries ofject for the file name and do stuff    
    console.log('En - ', entries[i]);
    }
}
function fail(error) {
    console.log("Failed to list directory contents: ", error);
}

引用文件插件:https://github.com/apache/cordova-plugin-file