mirror of
https://github.com/feeddeck/feeddeck.git
synced 2026-03-11 17:47:47 -05:00
[core] Fix Web Build (#185)
Fix web build be initializing `JustAudioMediaKit` only on Linux and Windows where it is really used. The corresponding issue for the broken web build can be found here https://github.com/Pato05/just_audio_media_kit/issues/15. To test the web build on every PR to avoid such issues, the CI/CD pipeline for the web build is now also run on every PR. On PRs we skip the upload to Cloudflare for the web build.
This commit is contained in:
@@ -7,7 +7,6 @@ import 'package:flutter/material.dart';
|
||||
import 'package:flutter_native_splash/flutter_native_splash.dart';
|
||||
import 'package:flutter_web_plugins/url_strategy.dart';
|
||||
import 'package:just_audio_background/just_audio_background.dart';
|
||||
import 'package:just_audio_media_kit/just_audio_media_kit.dart';
|
||||
import 'package:media_kit/media_kit.dart';
|
||||
import 'package:provider/provider.dart';
|
||||
import 'package:window_manager/window_manager.dart';
|
||||
@@ -20,6 +19,7 @@ import 'package:feeddeck/utils/constants.dart';
|
||||
import 'package:feeddeck/widgets/confirmation/confirmation.dart';
|
||||
import 'package:feeddeck/widgets/home/home.dart';
|
||||
import 'package:feeddeck/widgets/reset_password/reset_password.dart';
|
||||
import 'package:feeddeck/widgets/item/details/utils/item_audio_palyer/item_audio_player_init/item_audio_player_init.dart';
|
||||
|
||||
/// Before we are calling [runApp] we have to ensure that the widget bindings
|
||||
/// are initialized, so that we can preserve the splash screen until we are done
|
||||
@@ -51,7 +51,9 @@ void main() async {
|
||||
/// Initialize the [media_kit] packages, so that we can play audio and video
|
||||
/// files.
|
||||
MediaKit.ensureInitialized();
|
||||
JustAudioMediaKit.ensureInitialized();
|
||||
if (!kIsWeb && (Platform.isLinux || Platform.isWindows)) {
|
||||
ItemAudioPlayerInit().init();
|
||||
}
|
||||
|
||||
/// Initialize the [just_audio_background] package, so that we can play audio
|
||||
/// files in the background.
|
||||
|
||||
@@ -0,0 +1,11 @@
|
||||
library item_audio_player_init;
|
||||
|
||||
import 'item_audio_player_init_stub.dart'
|
||||
if (dart.library.io) 'item_audio_player_init_native.dart'
|
||||
if (dart.library.html) 'item_audio_player_init_web.dart';
|
||||
|
||||
abstract class ItemAudioPlayerInit {
|
||||
void init();
|
||||
|
||||
factory ItemAudioPlayerInit() => getItemAudioPlayerInit();
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
import 'package:just_audio_media_kit/just_audio_media_kit.dart';
|
||||
|
||||
import 'item_audio_player_init.dart';
|
||||
|
||||
class ItemAudioPlayerInitNative implements ItemAudioPlayerInit {
|
||||
@override
|
||||
void init() {
|
||||
JustAudioMediaKit.ensureInitialized();
|
||||
}
|
||||
}
|
||||
|
||||
ItemAudioPlayerInit getItemAudioPlayerInit() => ItemAudioPlayerInitNative();
|
||||
@@ -0,0 +1,5 @@
|
||||
import 'item_audio_player_init.dart';
|
||||
|
||||
ItemAudioPlayerInit getItemAudioPlayerInit() => throw UnsupportedError(
|
||||
'Can not ItemAudioPlayerInit without the packages dart:html or dart:io',
|
||||
);
|
||||
@@ -0,0 +1,8 @@
|
||||
import 'item_audio_player_init.dart';
|
||||
|
||||
class ItemAudioPlayerInitWeb implements ItemAudioPlayerInit {
|
||||
@override
|
||||
void init() {}
|
||||
}
|
||||
|
||||
ItemAudioPlayerInit getItemAudioPlayerInit() => ItemAudioPlayerInitWeb();
|
||||
Reference in New Issue
Block a user