Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

trying to get audio file size, on promise return, context (this) is lost #75

Open
sdetweil opened this issue Feb 18, 2023 · 0 comments
Open

Comments

@sdetweil
Copy link

sdetweil commented Feb 18, 2023

Describe the bug
ios16, xcode 14, ionic vue 6, capacitor 4.
tried with .then() as well.

        async doLoad() {
              await  NativeAudio.preload({
                assetId: "ping",
                assetPath: "sonar-ping-95840.mp3",
                audioChannelNum: 1,
                isUrl: false
            })
                this.LogIt("ping getting audio duration")
            let result= await  NativeAudio.getDuration({
                    assetId: 'ping'
                })
            let r = result.duration * 1000
            this.LogIt("in ms =" + r)
            this.setms(r)

see output

⚡️  To Native ->  NativeAudio getDuration 58430391
⚡️  [log] - 1676737401023 ping getting audio duration
⚡️  TO JS {"duration":1.0187755102040816}
⚡️  [log] - 1676737401025 in ms =1018.7755102040817

then
⚡️ TO JS undefined
⚡️ TO JS undefined

tried calling from IonicViewDidEnter()
and created()
tried using self instead of this

I am trying to save the ms elapsed so I can wait til the play finishes, so i  don't keep chopping it off while playing. 
not clear if play waits to return until finished. 

**Expected behavior**
A clear and concise description of what you expected to happen.

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
 - OS: [e.g. iOS] Mac OS
 - Browser [e.g. chrome, safari]  this is native mode app
 - Version [e.g. 22]

**Smartphone (please complete the following information):**
 - Device: [e.g. iPhone6]  iphone 12
 - OS: [e.g. iOS8.1] ios 16.2
 - Browser [e.g. stock browser, safari]???
 - Version [e.g. 22]???

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant