apache / cordova-plugin-media

Apache Cordova Media Plugin
https://cordova.apache.org/
Apache License 2.0
388 stars 767 forks source link

feat(ios): support file scheme #352

Closed knaito-asial closed 2 years ago

knaito-asial commented 2 years ago

Platforms affected

iOS platform

Motivation and Context

In iOS, this plugin does not support file:// scheme. Therefore following code does not work

  window.requestFileSystem(
      LocalFileSystem.PERSISTENT,
      0,
      function (fs) {
          const pathPrefix = fs.root.toURL();
          file = pathPrefix + fileName;
          mediaRec = new Media(file, mediaRecordSuccess, mediaError, mediaRecordStatus);
          mediaRec.startRecord();
      },
      function (err) {
          alert("LocalFileSystem Error");
      }
  );

On the other hand, this code works in Android.

The actual file variable in the above code is like file:///var/mobile/Containers/Data/Application/6DAC6E88-C38A-4A8B-A7E9-456345E5D25D/Library/NoCloud/myrecording.m4a where the file:// scheme is used. But the current this plugin does not support file:// scheme in iOS and not work in iOS.

This is inconsistent with in Android.

Description

This PR improves Media plugin to support file:// scheme in iOS.

Testing

In my local Mac, I create a sample cordova project and add this modified media plugin. Check the Recording and Playing audio with file path using file:// scheme and confirm it works well.

Checklist