代码
import 'package:flutter/material.dart'; import 'package:just_audio/just_audio.dart'; void main() { runApp(MyApp1()); } class MyApp1 extends StatelessWidget { final AudioPlayer audioPlayer = AudioPlayer(); @override Widget build(BuildContext context) { return MaterialApp( title: 'Audio Player', theme: ThemeData( primarySwatch: Colors.blue, ), home: Scaffold( appBar: AppBar( title: Text('Audio Player'), ), body: Center( child: ElevatedButton( onPressed: () async { await audioPlayer.setUrl('https://dashanbook.oss-cn-shenzhen.aliyuncs.com/av/2023/12/04/fbcd583f278c4c2fa0c83fcfc6fc08b4.mp3'); await audioPlayer.play(); }, child: Icon( audioPlayer.playing ? Icons.pause : Icons.play_arrow, size: 48.0, ), ), ), ), ); } }
标签:播放器,just,Icons,audioPlayer,title,MyApp1,audio From: https://www.cnblogs.com/xbinbin/p/17919869.html