Cordova list all files from application directory (WWW)

后端 未结 1 1675
执念已碎
执念已碎 2020-12-05 14:24

I am using Cordova 4.2.0 with plugins File and media. I have some mp3 files in audio folder inside www directory. I am able to play files through m

相关标签:
1条回答
  • 2020-12-05 15:08

    You can use this function to get all available files in www/audio/ folder

    function listDir(path){
      window.resolveLocalFileSystemURL(path,
        function (fileSystem) {
          var reader = fileSystem.createReader();
          reader.readEntries(
            function (entries) {
              console.log(entries);
            },
            function (err) {
              console.log(err);
            }
          );
        }, function (err) {
          console.log(err);
        }
      );
    }
    //example: list of www/audio/ folder in cordova/ionic app.
    listDir(cordova.file.applicationDirectory + "www/audio/");
    
    0 讨论(0)
提交回复
热议问题