flame-engine / flame_audio Goto Github PK
View Code? Open in Web Editor NEWAudio capabilities and helpers for playing sounds, music and effects on Flame games
License: MIT License
Audio capabilities and helpers for playing sounds, music and effects on Flame games
License: MIT License
After the first version is merged, we need to write a proper readme with badges, links and setup the build
Hey after checking on discord .... it seems like this is a bug
Im working with the latest FlameAudio with flame rc5
BUT everytime I press HOME button, the BGM music keeps on playing. I have to knocked the app out via the task manager to kill the music.
It doesnt happen with the BACK button.... Only with the HOME button.
Any idea how to solve this?
I'm trying to use flame_audio to target builds to the web platform, which audioplayers v0.19.0 now supports. I want to help contribute to updating flame_audio to use audioplayers v0.19.0 dependency, but I'm encountering some issues along the lines of the 'package:audioplayers/audio_cache.dart'
file missing and AudioPlayerState being undefined. I'll continue to tinker around, but would be far more happy to work alongside anyone on the team that may already have plans for supporting the web platform in the pipelines. Cheers!
here's a simple flame game:
class MyGame extends BaseGame {
Future<void> onLoad() async {
super.onLoad();
FlameAudio.bgm.initialize();
FlameAudio.bgm.play('music/background.mp3', volume: 0.75);
}
}
void main() {
final BaseGame myGame = MyGame();
runApp(
GameWidget(
game: myGame,
),
);
}
when I start the app with flutter run
and then type R in the terminal to hot restart, I get this error:
E/flutter (17559): [ERROR:flutter/lib/ui/ui_dart_state.cc(186)] Unhandled Exception: LateInitializationError: Field '_channel@669020947' has been assigned during initialization.
E/flutter (17559): #0 AudioPlayer._channel (package:audioplayers/audioplayers.dart)
E/flutter (17559): #1 AudioPlayer._invokeMethod (package:audioplayers/audioplayers.dart:283:12)
E/flutter (17559): #2 AudioPlayer.setReleaseMode (package:audioplayers/audioplayers.dart:469:12)
E/flutter (17559): #3 AudioCache.loop (package:audioplayers/audio_cache.dart:178:12)
E/flutter (17559): <asynchronous suspension>
E/flutter (17559): #4 Bgm.play (package:flame_audio/bgm.dart:57:19)
E/flutter (17559): <asynchronous suspension>
E/flutter (17559):
and the music stops
flutter doctor -v
:
[✓] Flutter (Channel stable, 2.0.5, on macOS 11.3 20E5196f darwin-x64, locale en-US)
• Flutter version 2.0.5 at /Users/suman/flutter
• Framework revision adc687823a (13 days ago), 2021-04-16 09:40:20 -0700
• Engine revision b09f014e96
• Dart version 2.12.3
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Users/suman/Library/Android/sdk/
• Platform android-30, build-tools 30.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.4, Build version 12D4e
• CocoaPods version 1.10.1
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 4.1)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
[✓] VS Code (version 1.55.2)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.21.0
[✓] Connected device (3 available)
• Z3351S (mobile) • 320295556323 • android-arm • Android 9 (API 28)
• macOS (desktop) • macos • darwin-x64 • macOS 11.3 20E5196f darwin-x64
• Chrome (web) • chrome • web-javascript • Google Chrome 90.0.4430.93
! Error: Sumanth Ratna is not connected. Xcode will continue when Sumanth Ratna is connected. (code -13)
• No issues found!
Your example is really nice. But I have used the previous verion with flame.audio to gain info from call backs and listeners.
Im finding it very hard to get that implemented with this new version.
May be you could show us how...
let me give you an idea in the old version i could do something like
homeBGM.seek(Duration.zero);
or may be even something like this
homeBGM.onPlayerCompletion.listen((event) {
I found what i need at FlameAudio.bgm.audioPlayer
But im not able to do this with an audioPlayer.... Im able to handle regular stuff with only bgm:
Would be great if you could show us how with this new version. Once again- Everything works in bgm via your example. But Im not able to get the required results if i follow the same steps for audioPlayer.
Thanks
The version of audioplayers has a bug v0.17.2: see here: stackOverflow
Please downgrade to 0.16.2, this worked fine.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.