nstudio / nativescript-audio

:microphone: NativeScript plugin to record and play audio :musical_note:
Other
150 stars 104 forks source link

Getting android context fixed #103

Closed mehyaa closed 6 years ago

bradmartin commented 6 years ago

Thanks for the PR. One suggestion and explanation for that private function with the timeout I was using. Several users were using this plugin and complaining about it throwing due to the app not being fully initialized, thus the context not returning to get the service.

So perhaps, let's take your approach and put it inside that private function instead, with the timeout to get the context, just to prevent this throwing for users who initialize the player before the app full inits.

Hope that makes sense, if you want to change and resubmit the PR that's fine. If not, then I can take your snippet and put into that method and push it out.

If you were running into issues with the previous approach feel free to let me know so we can work together to solve it for everyone 😄

mehyaa commented 6 years ago

Actually i've got the usage from natviescript source itself when looking a better way to get the context. I'm using the change locally until it'll be fixed on the package.

I've changed as you suggested. Hope it's ok.

Robbt commented 6 years ago

Hey just wondering what the status of this PR is - I ran into TypeError: Cannot read property 'getSystemService' of undefined while trying to use this nativescript plugin that error is directly related to the Android Context that this PR references.

I'm using vue-nativescript and so it is possible that I'm doing something wrong but it appears to fail at this point. I'll see if I can test these changes and see if they resolve the problem.

Robbt commented 6 years ago

Actually I believe the issue I ran into was #112 that is marked as closed (but there is no documentation that this approach is required in the documentation etc). So how can I best contribute an improvement to the documentation/readme so that others don't run into this.

I only found out about this solution by crawling the web when I stumbled upon - https://github.com/nativescript-vue/vue-cli-template/issues/22