File tree Expand file tree Collapse file tree 1 file changed +13
-4
lines changed
Expand file tree Collapse file tree 1 file changed +13
-4
lines changed Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import 'dart:async';
22import 'dart:io' ;
33import 'dart:typed_data' ;
44
5+ import 'package:flutter/foundation.dart' ;
56import 'package:flutter/services.dart' show rootBundle;
67import 'package:path_provider/path_provider.dart' ;
78
@@ -99,10 +100,10 @@ class AudioCache {
99100 bool isNotification,
100101 PlayerMode mode = PlayerMode .MEDIA_PLAYER ,
101102 bool stayAwake}) async {
102- File file = await load (fileName);
103+ String url = await getAbsaoluteUrl (fileName);
103104 AudioPlayer player = _player (mode);
104105 await player.play (
105- file.path ,
106+ url ,
106107 volume: volume,
107108 respectSilence: isNotification ?? respectSilence,
108109 stayAwake: stayAwake,
@@ -120,15 +121,23 @@ class AudioCache {
120121 bool isNotification,
121122 PlayerMode mode = PlayerMode .MEDIA_PLAYER ,
122123 bool stayAwake}) async {
123- File file = await load (fileName);
124+ String url = await getAbsaoluteUrl (fileName);
124125 AudioPlayer player = _player (mode);
125126 player.setReleaseMode (ReleaseMode .LOOP );
126127 player.play (
127- file.path ,
128+ url ,
128129 volume: volume,
129130 respectSilence: isNotification ?? respectSilence,
130131 stayAwake: stayAwake,
131132 );
132133 return player;
133134 }
135+
136+ Future <String > getAbsaoluteUrl (String fileName) async {
137+ if (kIsWeb) {
138+ return "assets/assets/$prefix $fileName " ;
139+ }
140+ File file = await load (fileName);
141+ return file.path;
142+ }
134143}
You can’t perform that action at this time.
0 commit comments