capacitor-jok-helper
Advanced tools
Comparing version 0.26.0 to 0.27.0
@@ -72,2 +72,3 @@ declare module '@capacitor/core' { | ||
name: string; | ||
path?: string; | ||
} | ||
@@ -74,0 +75,0 @@ export interface ViewAppPageProps { |
import { WebPlugin } from '@capacitor/core'; | ||
import { JokHelperPlugin, SetKeychainItemProps, SetOrientationLockProps, LoadProductsProps, SKProduct, RequestPaymentProps, FinishPaymentProps, ViewAppPageProps, PlayAudioProps } from './definitions'; | ||
import { FinishPaymentProps, JokHelperPlugin, LoadProductsProps, PlayAudioProps, RequestPaymentProps, SetKeychainItemProps, SetOrientationLockProps, SKProduct, ViewAppPageProps } from './definitions'; | ||
export declare class JokHelperWeb extends WebPlugin implements JokHelperPlugin { | ||
@@ -58,3 +58,4 @@ constructor(); | ||
}>; | ||
playAudio(_data: PlayAudioProps): Promise<{ | ||
private audioCache; | ||
playAudio(data: PlayAudioProps): Promise<{ | ||
value: boolean; | ||
@@ -61,0 +62,0 @@ }>; |
@@ -9,3 +9,3 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
}; | ||
import { WebPlugin } from '@capacitor/core'; | ||
import { registerWebPlugin, WebPlugin } from '@capacitor/core'; | ||
export class JokHelperWeb extends WebPlugin { | ||
@@ -17,2 +17,3 @@ constructor() { | ||
}); | ||
this.audioCache = new Map(); | ||
} | ||
@@ -108,4 +109,15 @@ echo(options) { | ||
} | ||
playAudio(_data) { | ||
return Promise.resolve({ value: false }); | ||
playAudio(data) { | ||
const { name, path = '/assets/audios' } = data; | ||
const url = `${path}/${name}.mp3`; | ||
if (!this.audioCache.has(url)) { | ||
this.audioCache.set(url, new Audio(url)); | ||
} | ||
const audioElement = this.audioCache.get(url); | ||
if (!audioElement) { | ||
return Promise.resolve({ value: false }); | ||
} | ||
audioElement.currentTime = 0; | ||
audioElement.play(); | ||
return Promise.resolve({ value: true }); | ||
} | ||
@@ -125,4 +137,3 @@ openMailbox() { | ||
export { JokHelper }; | ||
import { registerWebPlugin } from '@capacitor/core'; | ||
registerWebPlugin(JokHelper); | ||
//# sourceMappingURL=web.js.map |
{ | ||
"name": "capacitor-jok-helper", | ||
"version": "0.26.0", | ||
"version": "0.27.0", | ||
"description": "Helper functions for jok projects", | ||
@@ -5,0 +5,0 @@ "main": "dist/esm/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
418892
492