diff --git a/.github/workflows/build-web.yml b/.github/workflows/build-web.yml index 7e173a3..97a293c 100644 --- a/.github/workflows/build-web.yml +++ b/.github/workflows/build-web.yml @@ -37,7 +37,6 @@ jobs: pub-cache-key: "flutter-pub:os:-:channel:-:version:-:arch:-:hash:" # optional, change this to force refresh cache of dart pub get dependencies pub-cache-path: "${{ runner.tool_cache }}/flutter/:channel:-:version:-:arch:" # optional, change this to specify the cache path - run: flutter --version - - run: make removemk - run: flutter pub get - run: make patch # - run: flutter test diff --git a/Makefile b/Makefile index 7ee1f1b..85f1847 100644 --- a/Makefile +++ b/Makefile @@ -3,8 +3,3 @@ proto: patch: dart run patch_package apply - -removemk: - # so yucky... - sed -i -e '/media_kit/d' pubspec.yaml lib/controller/play.dart - sed -i -e '/MediaKit/d' pubspec.yaml lib/controller/play.dart diff --git a/lib/controller/audio_mediakit.dart b/lib/controller/audio_mediakit.dart new file mode 100644 index 0000000..a7f2476 --- /dev/null +++ b/lib/controller/audio_mediakit.dart @@ -0,0 +1,7 @@ +import 'package:just_audio_media_kit/just_audio_media_kit.dart'; + +class AudioInitializer { + void audioInit() { + JustAudioMediaKit.ensureInitialized(); + } +} diff --git a/lib/controller/audio_none.dart b/lib/controller/audio_none.dart new file mode 100644 index 0000000..6c6f840 --- /dev/null +++ b/lib/controller/audio_none.dart @@ -0,0 +1,3 @@ +class AudioInitializer { + void audioInit() {} +} diff --git a/lib/controller/audio_web.dart b/lib/controller/audio_web.dart new file mode 100644 index 0000000..6c6f840 --- /dev/null +++ b/lib/controller/audio_web.dart @@ -0,0 +1,3 @@ +class AudioInitializer { + void audioInit() {} +} diff --git a/lib/controller/play.dart b/lib/controller/play.dart index 68c25e3..ace8f15 100644 --- a/lib/controller/play.dart +++ b/lib/controller/play.dart @@ -1,6 +1,8 @@ import 'package:flutter/services.dart'; import 'package:just_audio/just_audio.dart' as justaudio; -import 'package:just_audio_media_kit/just_audio_media_kit.dart'; +import 'audio_none.dart' + if (dart.library.io) 'audio_mediakit.dart' + if (dart.library.html) 'audio_web.dart'; //import 'package:audioplayers/audioplayers.dart' as auplay; //import 'dart:io' show Platform; @@ -39,9 +41,10 @@ class AudioPlayersDriver implements AudioDriver { class JustAudioDriver implements AudioDriver { final player = justaudio.AudioPlayer(); + final initializer = AudioInitializer(); JustAudioDriver() { - JustAudioMediaKit.ensureInitialized(); + initializer.audioInit(); } @override