Skip to content

Commit ee05bb1

Browse files
committed
rollback main.dart
1 parent f0b6e33 commit ee05bb1

File tree

2 files changed

+17
-19
lines changed

2 files changed

+17
-19
lines changed

example/lib/main.dart

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import 'dart:developer' as dev;
2-
import 'dart:io';
32

43
import 'package:flutter/foundation.dart';
54
import 'package:flutter/material.dart';
@@ -61,24 +60,23 @@ class _HelloFlutterSoLoudState extends State<HelloFlutterSoLoud> {
6160
body: Center(
6261
child: ElevatedButton(
6362
onPressed: () async {
64-
// read the file bytes from "home/deimos/8/sample-1.ogg"
65-
// final f = File('/home/deimos/8/sample-1.ogg');
66-
// final bytes = f.readAsBytesSync();
63+
await SoLoud.instance.disposeAllSources();
6764

68-
// final waveformData = await SoLoud.instance.readSamplesFromMem(
69-
// bytes,
70-
// 2000,
71-
// // average: true, // Average samples to smooth out the waveform
72-
// );
65+
if (kIsWeb) {
66+
/// load the audio file using [LoadMode.disk] (better for the
67+
/// Web platform).
68+
currentSound = await SoLoud.instance.loadAsset(
69+
'assets/audio/8_bit_mentality.mp3',
70+
mode: LoadMode.disk,
71+
);
72+
} else {
73+
/// load the audio file
74+
currentSound = await SoLoud.instance
75+
.loadAsset('assets/audio/8_bit_mentality.mp3');
76+
}
7377

74-
final waveformData = await SoLoud.instance.readSamplesFromFile(
75-
'/home/deimos/8/sample-1.ogg',
76-
2000,
77-
// average: true, // Average samples to smooth out the waveform
78-
);
79-
bool b;
80-
b = true;
81-
print(b);
78+
/// play it
79+
await SoLoud.instance.play(currentSound!);
8280
},
8381
child: const Text(
8482
'play asset',

lib/src/bindings/bindings_player_web.dart

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1099,14 +1099,14 @@ class FlutterSoLoudWeb extends FlutterSoLoud {
10991099
final jsHeapF32 = wasmHeapF32Buffer;
11001100
// Convert the TypedArray view to a Dart Float32List
11011101
final samples = Float32List.sublistView(
1102-
jsHeapF32.toDart,
1102+
jsHeapF32.toDart,
11031103
samplesPtr ~/ 4, // divide by 4 because Float32 is 4 bytes
11041104
(samplesPtr ~/ 4) + numSamplesNeeded,
11051105
);
11061106

11071107
wasmFree(samplesPtr);
11081108
wasmFree(bufferPtr);
1109-
1109+
11101110
if (ReadSamplesErrors.fromValue(error) !=
11111111
ReadSamplesErrors.readSamplesNoError) {
11121112
throw SoLoudCppException.fromReadSampleError(

0 commit comments

Comments
 (0)