UNPKG

capacitor-audio-engine

Version:

High-quality audio recording Capacitor plugin with native iOS & Android support. Features pause/resume, microphone management, real-time monitoring, audio trimming, and comprehensive mobile audio recording capabilities.

2 lines (1 loc) 6.8 kB
var capacitorNativeAudio=function(o,e){"use strict";function r(o){if(!o.startsWith("data:"))return{isCompressed:!1,data:o,mimeType:"audio/m4a"};const[e,r]=o.split(",",2);return e.includes("lzfse:")?{isCompressed:!0,algorithm:"lzfse",data:r,mimeType:e.split(";")[0].replace("data:","")}:{isCompressed:!1,data:r,mimeType:e.split(";")[0].replace("data:","")}}const n=e.registerPlugin("CapacitorAudioEngine",{web:()=>Promise.resolve().then(function(){return s}).then(o=>new o.CapacitorAudioEngineWeb)});class t extends e.WebPlugin{async echo(o){return console.log("ECHO",o),o}async checkPermission(){return console.warn("checkPermission is not supported on web platform. For web implementation, consider using navigator.permissions.query API directly."),{granted:!1}}async requestPermission(){return console.warn("requestPermission is not supported on web platform. For web implementation, consider using navigator.mediaDevices.getUserMedia API directly."),{granted:!1}}async startRecording(o){throw console.warn("startRecording is not supported on web platform. For web implementation, consider using MediaRecorder API directly."),new Error("startRecording is not supported on web platform")}async stopRecording(){throw console.warn("stopRecording is not supported on web platform. For web implementation, consider using MediaRecorder API directly."),new Error("stopRecording is not supported on web platform")}async pauseRecording(){throw console.warn("pauseRecording is not supported on web platform. For web implementation, consider using MediaRecorder API directly."),new Error("pauseRecording is not supported on web platform")}async resumeRecording(){throw console.warn("resumeRecording is not supported on web platform. For web implementation, consider using MediaRecorder API directly."),new Error("resumeRecording is not supported on web platform")}async resetRecording(){throw console.warn("resetRecording is not supported on web platform. For web implementation, consider managing MediaRecorder state directly."),new Error("resetRecording is not supported on web platform")}async getDuration(){return console.warn("getDuration is not supported on web platform. For web implementation, consider using MediaRecorder API directly."),{duration:0}}async getStatus(){return console.warn("getStatus is not supported on web platform. For web implementation, consider using MediaRecorder API directly."),{status:"idle",isRecording:!1,duration:0}}async trimAudio({uri:o,start:e,end:r}){throw console.warn(`trimAudio is not supported on web platform. Attempted to trim file: ${o} from ${e}s to ${r}s. For web implementation, consider using Web Audio API directly.`),new Error("trimAudio is not supported on web platform")}async addListener(o,e){console.warn(`${o} event is not supported on web platform. Callback will not be invoked. For web implementation, consider using MediaRecorder events directly.`);return{remove:()=>Promise.resolve()}}async isMicrophoneBusy(){throw console.warn("isMicrophoneBusy is not supported on web platform."),new Error("isMicrophoneBusy is not supported on web platform")}async getAvailableMicrophones(){throw console.warn("getAvailableMicrophones is not supported on web platform."),new Error("getAvailableMicrophones is not supported on web platform")}async switchMicrophone(o){throw console.warn(`switchMicrophone is not supported on web platform. Attempted to switch to microphone ID: ${o.microphoneId}`),new Error("switchMicrophone is not supported on web platform")}async removeAllListeners(){console.warn("removeAllListeners is not supported on web platform.")}async preloadTracks(o){console.warn("preloadTracks is not supported on web platform. For web implementation, consider using HTML5 Audio API directly.");return{tracks:o.tracks.map(o=>({url:o,loaded:!1}))}}async playAudio(){throw console.warn("playAudio is not supported on web platform. For web implementation, consider using HTML5 Audio API directly."),new Error("playAudio is not supported on web platform")}async pauseAudio(){throw console.warn("pauseAudio is not supported on web platform. For web implementation, consider using HTML5 Audio API directly."),new Error("pauseAudio is not supported on web platform")}async resumeAudio(){throw console.warn("resumeAudio is not supported on web platform. For web implementation, consider using HTML5 Audio API directly."),new Error("resumeAudio is not supported on web platform")}async stopAudio(){throw console.warn("stopAudio is not supported on web platform. For web implementation, consider using HTML5 Audio API directly."),new Error("stopAudio is not supported on web platform")}async seekAudio(o){throw console.warn("seekAudio is not supported on web platform. For web implementation, consider using HTML5 Audio API directly."),new Error("seekAudio is not supported on web platform")}async skipToNext(){throw console.warn("skipToNext is not supported on web platform. For web implementation, consider using HTML5 Audio API directly."),new Error("skipToNext is not supported on web platform")}async skipToPrevious(){throw console.warn("skipToPrevious is not supported on web platform. For web implementation, consider using HTML5 Audio API directly."),new Error("skipToPrevious is not supported on web platform")}async skipToIndex(o){throw console.warn("skipToIndex is not supported on web platform. For web implementation, consider using HTML5 Audio API directly."),new Error("skipToIndex is not supported on web platform")}async getPlaybackInfo(){throw console.warn("getPlaybackInfo is not supported on web platform. For web implementation, consider using HTML5 Audio API directly."),new Error("getPlaybackInfo is not supported on web platform")}async openAppSettings(){console.warn("openAppSettings is not fully supported on web platform. Showing alert with instructions.");alert('To manage permissions:\n\n1. Click the lock icon in your browser\'s address bar\n2. Select "Site settings" or "Permissions"\n3. Adjust microphone and other permissions as needed\n\nOr access browser settings directly through the browser menu.')}}var s=Object.freeze({__proto__:null,CapacitorAudioEngineWeb:t});return o.CapacitorAudioEngine=n,o.base64ToBlob=function(o){const e=r(o),n=atob(e.data),t=new Array(n.length);for(let o=0;o<n.length;o++)t[o]=n.charCodeAt(o);const s=new Uint8Array(t);return new Blob([s],{type:e.mimeType})},o.getCompressionInfo=function(o){const e=r(o);if(!e.isCompressed)return{isCompressed:!1};const n=Math.floor(3*e.data.length/4);return{isCompressed:!0,algorithm:e.algorithm,compressedSize:n}},o.getDataURL=function(o){return o.startsWith("data:")?o:`data:audio/m4a;base64,${o}`},o.getRawBase64Data=function(o){return r(o).data},o.isCompressedBase64=function(o){return r(o).isCompressed},o.parseBase64Data=r,o}({},capacitorExports);