Comments (5)
Hello @ryanheise ,
I was reading in-depth the documentation and I realized that AVAudioSession playAndRecord category solve my problems:
- plays audio through earpiece
- locks the screen
Both for android and ios the code would be something like
final session = await AudioSession.instance;
final AndroidAudioAttributes currentAndroidAttributes = session.configuration.androidAudioAttributes;
await session.configure(
session.configuration.copyWith(
androidAudioAttributes: AndroidAudioAttributes(
usage: AndroidAudioUsage.voiceCommunication,
flags: currentAndroidAttributes.flags,
contentType: currentAndroidAttributes.contentType,
),
avAudioSessionCategory: AVAudioSessionCategory.playAndRecord,
),
);
I think it would be interesting to encapsulate a similar logic in a public function in the AudioPlayer.
Thanks for the support!
from audio_session.
Hi @mmartinalo , the eventual goal is to implement all of the AVAudioSession API but I started with just the features that I personally needed. If you take a look at the source documentation for Apple's AVAudioSession , perhaps you can identify which features you need, then you can let me know and I can add those features next.
from audio_session.
Glad you found a solution. I'd rather have a clear separation of concerns between these two plugins so that audio_session is responsible for switching between devices or detecting when a switch occurs, while just_audio doesn't need to know.
Interestingly, the name "just" audio actually stemmed from a goal to build an audio plugin that didn't take on any other responsibilities besides the audio signal itself, while different plugins could handle settings for the hardware devices, etc.
from audio_session.
Hello @ryanheise ,
I was reading in-depth the documentation and I realized that AVAudioSession playAndRecord category solve my problems:
- plays audio through earpiece
- locks the screen
Both for android and ios the code would be something like
final session = await AudioSession.instance; final AndroidAudioAttributes currentAndroidAttributes = session.configuration.androidAudioAttributes; await session.configure( session.configuration.copyWith( androidAudioAttributes: AndroidAudioAttributes( usage: AndroidAudioUsage.voiceCommunication, flags: currentAndroidAttributes.flags, contentType: currentAndroidAttributes.contentType, ), avAudioSessionCategory: AVAudioSessionCategory.playAndRecord, ), );I think it would be interesting to encapsulate a similar logic in a public function in the AudioPlayer.
Thanks for the support!
thanks , you saved my time :X
from audio_session.
Would you mind sharing your solution on this issue? #37
The goal of that issue is to provide a convenience method in the AudioSession
class to handle this common use case in a platform-independent way (while still keeping the native APIs available for more advanced use cases).
from audio_session.
Related Issues (20)
- Can't build on android when targetting android 34 HOT 11
- Add privacy manifest for Apple HOT 6
- [iOS] Background audio not playing on iPhone 13+ HOT 3
- AVAudioSessionCategoryOptions.mixWithOthers stops background music the first time when audio is player, after continuing the music further sounds no longer stop the music HOT 1
- Call requires API level 23 (current min is 16) HOT 1
- Can not play by speaker on iOS HOT 3
- Is it possible to play audio when Do Not Disturb mode is on, but not in silent mode? HOT 1
- `AVAudioSessionCategoryOptions`'s `contains` method takes `AVAudioSessionInterruptionOptions`. Maybe it should be `AVAudioSessionCategoryOptions`? HOT 5
- Dependency causing an ANR in the Background HOT 3
- The music played by IOS17 is not output from Bluetooth earphones HOT 2
- Android detects the headset as if it is connected even if it is not HOT 1
- Trouble closing an audio session HOT 1
- Echo cancellation HOT 3
- Can't get current audio device HOT 1
- failed for task ':audio_session:compileReleaseJavaWithJavac' (target SDK 33) HOT 1
- AudioSessionConfiguration with multiple categories causes PlatformException(-50)
- Execution failed for task ':audio_session:compileDebugJavaWithJavac'
- [Question] Can audio playback be started while app is in the background in IOS? HOT 1
- file or directory '/home/user/.pub-cache/hosted/pub.dev/audio_session-0.1.19/android/src/debug/java', not found
- java issue to even run the project
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from audio_session.