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

About Audio playback #414

Open
Masataka-n opened this issue Aug 26, 2024 · 2 comments
Open

About Audio playback #414

Masataka-n opened this issue Aug 26, 2024 · 2 comments
Labels
enhancement New feature or request

Comments

@Masataka-n
Copy link

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
import 'package:flutter/material.dart';
import 'package:rive/rive.dart';

class RiveTestPage extends StatefulWidget {
  const RiveTestPage({super.key});

  @override
  State<RiveTestPage> createState() => _RiveTestPageState();
}

class _RiveTestPageState extends State<RiveTestPage> {
  RiveFile? _riveAudioAssetFile;

  @override
  void initState() {
    super.initState();
    _loadRiveFile();
  }

  Future<void> _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)

  • Device: [Android, iOS]
  • OS: [Android SDK API Level 34, iOS 17.5.1]
  • Flutter Version:
Flutter 3.22.2 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 761747bfc5 (3 months ago) • 2024-06-05 22:15:13 +0200
Engine • revision edd8546116
Tools • Dart 3.4.3 • DevTools 2.34.3
@Masataka-n Masataka-n added the bug Something isn't working label Aug 26, 2024
@rive-app rive-app deleted a comment Aug 26, 2024
@HayesGordon
Copy link
Contributor

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
Copy link
Author

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.

@HayesGordon HayesGordon added enhancement New feature or request and removed bug Something isn't working labels Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants