Comments (3)
@johnareid54 I don't understand. Have you created your Soundpool instance with StreamType.music
?
I assume you want to control which audio output your app should use. Is that what you need?
How can I test the problem you've described?
from soundpool.
I agree it is a strange problem. It looks similar to the issue Sounds don't play on iOS physical device #28 It was apparently using ringer volume,
My code is very simple but works very well! I just have to find a way to make it uses the media audio on both Android and IOS.
`import 'dart:async';
import 'package:soundpool/soundpool.dart';
import 'package:flutter/services.dart';
class SoundAudio {
Soundpool _soundpool;
bool loop = false;
int _correct;
int _wrong;
int _word;
Timer _timer;
Future<void> load() async {
_soundpool = Soundpool(streamType: StreamType.notification);
var asset = await rootBundle.load("assets/audio/right.mp3");
_correct = await _soundpool.load(asset);
asset = await rootBundle.load("assets/audio/wrong.mp3");
_wrong = await _soundpool.load(asset);
}
Future<void> correct() async {
_soundpool.stop(_word);
_timer?.cancel();
loop = false;
await _soundpool.play(_correct);
}
Future<void> wrong() async {
await _soundpool.play(_wrong);
}
Future<bool> loadWord(int file) async {
_timer?.cancel();
loop = false;
String subfolder = "0";
if (file > 99) subfolder = file.toString().substring(0, 1);
var asset = await rootBundle.load("assets/words/$subfolder/$file.mp3");
_word = await _soundpool.load(asset);
return true;
}
Future<void> word() async {
await _soundpool.play(_word);
}
Future<void> correctword() async {
await _soundpool.play(_correct);
await _soundpool.play(_word);
}
Future<void> loadPlay(int file) async {
await loadWord(file);
repeat(3);
}
void repeat(int seconds) {
loop = false;
Future.delayed(Duration(seconds: 1), () {
loop = true;
word();
_timer = Timer.periodic(Duration(seconds: seconds), (timer) {
word();
});
});
}
stop() {
_soundpool.stop(_word);
_timer?.cancel();
}
Future<void> test() async {
var asset = await rootBundle.load("assets/audio/190.mp3");
await _soundpool.loadAndPlay(asset);
}
SoundAudio() {
load();
}
void dispose() {
_soundpool.dispose();
_timer?.cancel();
}
}
`
from soundpool.
I found the solution to this issue - the channel is controlled by this line--
_soundpool = Soundpool(streamType: StreamType.notification);
Instead of StreamType.notification) change it to StreamType.music.
from soundpool.
Related Issues (20)
- Question about `load` HOT 2
- Soundpool Audio Not Heard When Running on Mobile Device's Chrome Web Browser
- Admob interstitial ads are silent after they are displayed.
- Package Upgrade issue HOT 3
- Could not find method namesapce() for arguments [pl.ukaszapps.soundpool] on extension 'android' of type com.android.build.gradle.LibraryExtension.
- stop() not working with loadAndPlayUri and loadAndPlayUint8List HOT 2
- setVolume resets to default 1.0 when maxStreams > 1
- Namespace not specified. Specify a namespace in the module's build file HOT 3
- Soundpool Plugin Causing Crash on Flutter iOS App HOT 3
- soundpool_windux is incompatible with soundpool_web due to http version dependency HOT 1
- soundpool.play returned streamId==0 HOT 4
- Windux: setVolume throws UnimplementedError although it has been implemented in Rust.
- Initial sound playback defaults to volume 1.0 regardless of set value HOT 1
- Feature Request: Pitch Adjustment for Soundpool HOT 1
- iOS - .play() works only the first time HOT 2
- Raster Jank HOT 1
- Playing sound stops background music on Android HOT 2
- 'Soundpool.new' is deprecated and shouldn't be used. Use fromOptions instead.
- 16 Warning Message when Building Signed APK
- Comments: /// [repeat] is ignored. The sound is played only once. are untrue?
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 soundpool.