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

Any plan to add a pause() function ? #1

Open
maximilien0405 opened this issue May 17, 2024 · 3 comments
Open

Any plan to add a pause() function ? #1

maximilien0405 opened this issue May 17, 2024 · 3 comments

Comments

@maximilien0405
Copy link

maximilien0405 commented May 17, 2024

Hello there ! I just saw your plugin, i haven't tested it yet but if it works this will solve a problem i've been having on my application (i can't play large voice messages on IOS with HTML audio, i get this error : https://forums.developer.apple.com/forums/thread/740354).

My app needs to play small to large voice messages (maybe up to 5-10 MB) that are going to be uploaded to a S3. Theses messages will be played back, however i just saw that there is no pause function :/

Is there any plan to implement it one day ? It would be very useful for my project !

@BarnabasSzabolcs
Copy link
Owner

BarnabasSzabolcs commented May 18, 2024

Hi @maximilien0405!

S3 means that you probably want to access these audio files by their urls, in which case this is the only solution I know of. I have tried to make all other plugins work, in vain, because in reality they can only play audio that is shipped with the app as resource.

It is a nice idea to add a togglePause and/or a stop!
Later, I will probably do it for an upcoming project but at the moment I have no capacity.

As for implementing it, if you search for play, you'll see where the pause can be added.
I can see that you'll have to move the audio object out of play in web.ts as a class member.
You'll need to implement togglePause in java, and swift and there will be a few additional files where you'll have to register this function. If you just do a global search for "play" you'll see all the parts that have to be amended.

If you do it, I'm more than ready/happy to merge it.

Good luck,
Barney

@maximilien0405
Copy link
Author

Okay thanks ! I know nothing about plugin developpemnt, or Swift or Java, but i'll try ! It's probably not that complicated
Thanks for theses indications, this will surely help me for my task 👍
I will keep you updated if i try to make something work, if not then i'll be waiting patiently for your implementation :)

@BarnabasSzabolcs
Copy link
Owner

Awesome! 🤩 If you get stuck, just let me know 🙌
The plugin works on my iphone 7 and on Android simulator on Apple M2 Sonoma, plus on the web ofc.

I also didn't know much about plugin dev, Swift or Java, just used copilot, some online documentation, some trial and error and some banging my head against the wall because copilot is not that strong in this area.

Frankly, most of the code is just boilerplate it does nothing. The difficult part was figuring out where the play functions go and which objects to use to make the playback actually work without crashing randomly XD. The swift and java classes probably use a concept called separation of interface and implementation, not sure why. It was an awesome trick for c++ but imho it has no value in java. It is what it is.
The point is you have to write the classes "twice" and call implementation.play(). 🙈

This may or may not help, probably you have seen it already: https://capacitorjs.com/docs/plugins/ios
For audio playback, I didn't have to request permissions.

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

2 participants