rive-app / rive-flutter

Flutter runtime for Rive
https://rive.app
MIT License
1.23k stars 194 forks source link

About Audio playback #414

Open Masataka-n opened 3 months ago

Masataka-n commented 3 months ago

Description

I'm trying to play audio with a simple one-shot animation.

In the iOS SDK, audio plays without specifying a stateMachine, but in the Flutter SDK, audio does not play unless a stateMachine is specified.

Is this intentional? Also, are there plans to fix this in future updates?

Sample code ```dart import 'package:flutter/material.dart'; import 'package:rive/rive.dart'; class RiveTestPage extends StatefulWidget { const RiveTestPage({super.key}); @override State createState() => _RiveTestPageState(); } class _RiveTestPageState extends State { RiveFile? _riveAudioAssetFile; @override void initState() { super.initState(); _loadRiveFile(); } Future _loadRiveFile() async { final riveFile = await RiveFile.asset( 'assets/anims/sound_kari.riv', ); setState(() { _riveAudioAssetFile = riveFile; }); } @override Widget build(BuildContext context) { if (_riveAudioAssetFile == null) { return const Center(child: CircularProgressIndicator()); } return Scaffold( appBar: AppBar( title: const Text('Sample'), ), body: Center( child: RiveAnimation.direct( _riveAudioAssetFile!, // ↓ If this is not specified, audio will not be played. // stateMachines: const ['State Machine 1'], fit: BoxFit.cover, ), ), ); } } ```

Source .riv/.rev file

sample_resource.zip

Device & Versions (please complete the following information)

HayesGordon commented 3 months ago

Hi @Masataka-n the Flutter runtime does not report events outside of a state machine. We could look into adding this, but currently, there is a larger engineering effort to update the Rive Flutter runtime to use the same underlying Rive C++ runtime that iOS (and the other runtimes) uses. And this is our current focus for Flutter.

Once that change is done, then the behaviour should be the same. We're hard at work on that and in the upcoming weeks it'll be updated.

Masataka-n commented 3 months ago

Hi @HayesGordon Thank you for your response. I appreciate the hard work your team is putting into this. I’m looking forward to the upcoming updates.