Skip to content

Instantly share code, notes, and snippets.

@doyle-flutter
Created October 10, 2023 14:20
Show Gist options
  • Save doyle-flutter/d798e63b0728e0907d07eb5bc376dd91 to your computer and use it in GitHub Desktop.
Save doyle-flutter/d798e63b0728e0907d07eb5bc376dd91 to your computer and use it in GitHub Desktop.
audio 2023
import 'package:audioplayers/audioplayers.dart';
import 'package:flutter/material.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) => MaterialApp(
home: MainPage(),
);
}
class MainPage extends StatelessWidget {
const MainPage({super.key});
@override
Widget build(BuildContext context) => Scaffold(
appBar: AppBar(title: Text("Audio 2023"),),
floatingActionButton: FloatingActionButton(
child: Icon(Icons.play_arrow),
onPressed: () async{
AudioPlayer audioPlayer = AudioPlayer();
await audioPlayer.play(
AssetSource('sample/base.mp3')
);
},
),
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment