diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1 @@ +{} \ No newline at end of file diff --git a/android/app/src/main/res/mipmap-hdpi/ic_launcher.png b/android/app/src/main/res/mipmap-hdpi/ic_launcher.png index 540ed27..87da42e 100644 Binary files a/android/app/src/main/res/mipmap-hdpi/ic_launcher.png and b/android/app/src/main/res/mipmap-hdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-mdpi/ic_launcher.png b/android/app/src/main/res/mipmap-mdpi/ic_launcher.png index 364bb38..936389e 100644 Binary files a/android/app/src/main/res/mipmap-mdpi/ic_launcher.png and b/android/app/src/main/res/mipmap-mdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png index 0729b13..901e9f0 100644 Binary files a/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png and b/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png index 8beae93..5475d08 100644 Binary files a/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png and b/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png differ diff --git a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png index 0f3b0e2..286fb92 100644 Binary files a/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png and b/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png differ diff --git a/assets/test.webm b/assets/test.webm deleted file mode 100644 index e65bfce..0000000 Binary files a/assets/test.webm and /dev/null differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png index 7a03e8f..e048f13 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-1024x1024@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png index a006de5..3a36d19 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png index 067504d..f8a3ca0 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png index 35b9c55..816e95a 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-20x20@3x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png index ab88be5..2f3242f 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png index afbd528..7191601 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png index 5792e0c..7b38d87 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-29x29@3x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png index 067504d..f8a3ca0 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png index 31c3e71..004dc31 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png index 0923e19..e54657a 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-40x40@3x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@1x.png index a28908c..8c2013f 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@1x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@2x.png index 54d3158..7080b9e 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@2x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-50x50@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@1x.png index db359ea..13d0779 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@1x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@2x.png index 039daa4..2e31718 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@2x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-57x57@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png index 0923e19..e54657a 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png index d080f7a..70422c5 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-60x60@3x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@1x.png index 540ed27..87da42e 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@1x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@2x.png index 8beae93..5475d08 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@2x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-72x72@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png index 3b0f963..e7c88ca 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@1x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png index 9a497b5..a43e8e4 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-76x76@2x.png differ diff --git a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png index 0a44c30..f2fbead 100644 Binary files a/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png and b/ios/Runner/Assets.xcassets/AppIcon.appiconset/Icon-App-83.5x83.5@2x.png differ diff --git a/lib/main.dart b/lib/main.dart index ca1adc6..4476653 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -4,12 +4,12 @@ import 'package:fipy/screens/home.dart'; import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import 'package:kplayer/kplayer.dart'; -// import 'package:kplayer_with_audioplayers/kplayer_with_audioplayers.dart' as kp; +import 'package:kplayer_with_audioplayers/kplayer_with_audioplayers.dart' as kp; Future main() async { WidgetsFlutterBinding.ensureInitialized(); Player.boot(); - // kp.Player.boot(); + kp.Player.boot(); runApp(const FipyApp()); } diff --git a/lib/providers/home.dart b/lib/providers/home.dart index 466a8d5..1e38b78 100644 --- a/lib/providers/home.dart +++ b/lib/providers/home.dart @@ -1,7 +1,6 @@ // ignore_for_file: avoid_print import 'dart:convert'; -import 'package:ffmpeg_cli/ffmpeg_cli.dart'; import 'package:fipy/globals.dart'; import 'package:flutter/foundation.dart'; import 'package:universal_io/io.dart'; @@ -13,11 +12,14 @@ import 'package:youtube_explode_dart/youtube_explode_dart.dart'; import 'package:fipy/providers/player.dart'; import 'package:provider/provider.dart'; import 'package:http/http.dart'; -// import 'package:kplayer_with_audioplayers/kplayer_with_audioplayers.dart' as kp; +import 'package:audioplayers/audioplayers.dart'; +import 'package:kplayer_with_audioplayers/kplayer_with_audioplayers.dart' as kp; class HomeProvider with ChangeNotifier { Track? currentTrack; PlayerController? player; + AudioPlayer audioPlayer = AudioPlayer(); + List trackList = []; int trackNbr = 0; int userPageNbr = 3; @@ -96,13 +98,19 @@ class HomeProvider with ChangeNotifier { 'invidious.snopyta.org', 'invidious.fdn.fr', ]; - // final media = PlayerMedia( - // type: PlayerMediaType.network, - // resource: - // "https://${invidiousUrl[0]}/latest_version?id=${track.id}&itag=140&local=true&listen=1"); - // player = kp.Player(media: media); - player = Player.network( - "https://${invidiousUrl[0]}/latest_version?id=${track.id}&itag=140&local=true&listen=1"); // https://${invidiousUrl[0]}/embed/${track.id}?listen=1&raw=1&local=true + + // audioPlayer.stop(); + // Future.delayed(const Duration(milliseconds: 5)); + // await audioPlayer.play(DeviceFileSource( + // "https://${invidiousUrl[1]}/latest_version?id=${track.id}&itag=140&local=true&listen=1")); + + final media = PlayerMedia( + type: PlayerMediaType.network, + resource: + "https://${invidiousUrl[1]}/latest_version?id=${track.id}&itag=140&local=true&listen=1"); + player = kp.Player(media: media); + // player = Player.network( + // "https://${invidiousUrl[0]}/latest_version?id=${track.id}&itag=140&local=true&listen=1"); // https://${invidiousUrl[0]}/embed/${track.id}?listen=1&raw=1&local=true player!.init(); print(player!.media.resource); @@ -120,9 +128,13 @@ class HomeProvider with ChangeNotifier { currentTrack!.duration = player!.duration; playerProvider.reload(); } - if (event.name == 'status' && player!.position == player!.duration) { + if (event.name == 'end' && + currentTrack == track && + (currentTrack!.duration!.inSeconds - player!.position.inSeconds <= + 1)) { var nextTrack = trackList .firstWhere((element) => element.number == track.number + 1); + currentTrack = nextTrack; playTrack(context, nextTrack); } }; @@ -208,27 +220,27 @@ class DownloadProvider with ChangeNotifier { } } -Future convertToMp3(String audioFile) async { - audioFile = 'E:\\Téléchargements/test.webm'; - final command = FfmpegCommand( - inputs: [FfmpegInput.asset(audioFile)], - args: [ - // CliArg(name: 'i', value: audioFile), - const CliArg(name: 'ab', value: '320'), - const CliArg(name: 'ar', value: '44100'), - ], - filterGraph: const FilterGraph( - chains: [ - FilterChain( - inputs: [], - filters: [], - outputs: [], - ), - ], - ), - outputFilepath: "E:\\Téléchargements/test.mp3", - ); +// Future convertToMp3(String audioFile) async { +// audioFile = 'E:\\Téléchargements/test.webm'; +// final command = FfmpegCommand( +// inputs: [FfmpegInput.asset(audioFile)], +// args: [ +// // CliArg(name: 'i', value: audioFile), +// const CliArg(name: 'ab', value: '320'), +// const CliArg(name: 'ar', value: '44100'), +// ], +// filterGraph: const FilterGraph( +// chains: [ +// FilterChain( +// inputs: [], +// filters: [], +// outputs: [], +// ), +// ], +// ), +// outputFilepath: "E:\\Téléchargements/test.mp3", +// ); -// Execute command - await Ffmpeg().run(command); -} +// // Execute command +// await Ffmpeg().run(command); +// } diff --git a/lib/screens/home.dart b/lib/screens/home.dart index 09f6e07..6d22593 100644 --- a/lib/screens/home.dart +++ b/lib/screens/home.dart @@ -5,6 +5,7 @@ import 'package:fipy/models/track.dart'; import 'package:fipy/providers/home.dart'; import 'package:fipy/providers/player.dart'; import 'package:flutter/material.dart'; +import 'package:flutter/services.dart'; import 'package:miniplayer/miniplayer.dart'; import 'package:provider/provider.dart'; import 'package:youtube_explode_dart/youtube_explode_dart.dart'; @@ -24,83 +25,74 @@ class _HomeScreenState extends State { HomeProvider hp = Provider.of(context, listen: false); final MiniplayerController controller = MiniplayerController(); - return Stack( - children: [ - Scaffold( - body: RawScrollbar( - thumbColor: Colors.grey[600], - radius: const Radius.circular(20), - thickness: 12, - // thumbVisibility: true, - mainAxisMargin: 70, - child: SingleChildScrollView( - child: Column( - children: [ - Container( - color: Colors.grey[900], - height: 50, - child: Row( - mainAxisAlignment: MainAxisAlignment.center, - children: [ - DropdownButton( - dropdownColor: Colors.grey[900], - value: radio, - style: TextStyle( - fontSize: 15, color: Colors.grey[300]), - underline: const SizedBox(), - iconSize: 22, - onChanged: (String? newRadio) { - setState(() { - radio = newRadio!; - }); - }, - items: hp.radioList), - const SizedBox(width: 50), - DropdownButton( - dropdownColor: Colors.grey[900], - value: hp.userPageNbr.toString(), - style: TextStyle( - fontSize: 15, color: Colors.grey[300]), - underline: const SizedBox(), - iconSize: 22, - onChanged: (String? newPageNumber) { - setState(() { - hp.userPageNbr = int.parse(newPageNumber!); - }); - }, - items: hp.pageList), - ]), - ), - FutureBuilder>( - future: hp.getTracks(radio), - builder: ( - BuildContext context, - AsyncSnapshot> snapshot, - ) { - print(snapshot.connectionState); - if (snapshot.connectionState == - ConnectionState.waiting) { - return Stack(children: [ - Container( - height: 10000, - width: 10000, - color: const Color(0xFF121212)), - Center( - child: Column(children: [ - const SizedBox(height: 20), - SizedBox( - height: 30, - width: 30, - child: CircularProgressIndicator( - color: Colors.amber[100], - ), - ), - ]), - ), - ]); - } else if (snapshot.connectionState == - ConnectionState.done) { - if (snapshot.hasError) { + return RawKeyboardListener( + autofocus: true, + focusNode: FocusNode(), + onKey: (RawKeyEvent event) { + if (event.runtimeType == RawKeyDownEvent && + event.data.logicalKey.keyId == 32) //Enter Key ID from keyboard + { + print('tata'); + hp.player?.playing ?? false ? hp.player?.pause() : hp.player?.play(); + } + }, + child: Stack( + children: [ + Scaffold( + body: RawScrollbar( + thumbColor: Colors.grey[600], + radius: const Radius.circular(20), + thickness: 12, + // thumbVisibility: true, + mainAxisMargin: 70, + child: SingleChildScrollView( + child: Column( + children: [ + Container( + color: Colors.grey[900], + height: 50, + child: Row( + mainAxisAlignment: MainAxisAlignment.center, + children: [ + DropdownButton( + dropdownColor: Colors.grey[900], + value: radio, + style: TextStyle( + fontSize: 15, color: Colors.grey[300]), + underline: const SizedBox(), + iconSize: 22, + onChanged: (String? newRadio) { + setState(() { + radio = newRadio!; + }); + }, + items: hp.radioList), + const SizedBox(width: 50), + DropdownButton( + dropdownColor: Colors.grey[900], + value: hp.userPageNbr.toString(), + style: TextStyle( + fontSize: 15, color: Colors.grey[300]), + underline: const SizedBox(), + iconSize: 22, + onChanged: (String? newPageNumber) { + setState(() { + hp.userPageNbr = + int.parse(newPageNumber!); + }); + }, + items: hp.pageList), + ]), + ), + FutureBuilder>( + future: hp.getTracks(radio), + builder: ( + BuildContext context, + AsyncSnapshot> snapshot, + ) { + print(snapshot.connectionState); + if (snapshot.connectionState == + ConnectionState.waiting) { return Stack(children: [ Container( height: 10000, @@ -109,251 +101,277 @@ class _HomeScreenState extends State { Center( child: Column(children: [ const SizedBox(height: 20), - Text( - 'Error: ' + snapshot.error.toString(), - style: TextStyle(color: Colors.grey[500]), + SizedBox( + height: 30, + width: 30, + child: CircularProgressIndicator( + color: Colors.amber[100], + ), ), ]), ), ]); - } else if (snapshot.hasData) { - return Table( - columnWidths: { - 0: const FlexColumnWidth(4), - 1: const FlexColumnWidth(2), - 2: const FlexColumnWidth(1), - }, - defaultVerticalAlignment: - TableCellVerticalAlignment.middle, - children: snapshot.data! - .map((item) => _buildTableRow(item, context)) - .toList() - ..insert( - 0, - _buildTableRow( - Track( - number: -1, - title: 'TITRE', - artiste: 'ARTISTE', - album: 'ALBUM', - id: 'URL'), - context), + } else if (snapshot.connectionState == + ConnectionState.done) { + if (snapshot.hasError) { + return Stack(children: [ + Container( + height: 10000, + width: 10000, + color: const Color(0xFF121212)), + Center( + child: Column(children: [ + const SizedBox(height: 20), + Text( + 'Error: ' + snapshot.error.toString(), + style: TextStyle(color: Colors.grey[500]), + ), + ]), ), - ); + ]); + } else if (snapshot.hasData) { + return Table( + columnWidths: { + 0: const FlexColumnWidth(4), + 1: const FlexColumnWidth(2), + 2: const FlexColumnWidth(1), + }, + defaultVerticalAlignment: + TableCellVerticalAlignment.middle, + children: snapshot.data! + .map( + (item) => _buildTableRow(item, context)) + .toList() + ..insert( + 0, + _buildTableRow( + Track( + number: -1, + title: 'TITRE', + artiste: 'ARTISTE', + album: 'ALBUM', + id: 'URL'), + context), + ), + ); + } else { + return const Text('Empty data'); + } } else { - return const Text('Empty data'); + return Text('State: ${snapshot.connectionState}'); } - } else { - return Text('State: ${snapshot.connectionState}'); - } - }, - ), - const SizedBox(height: 70) - ], - ), - )), - ), - Consumer(builder: (context, playerProvider, _) { - TextEditingController trackTitle = TextEditingController(); - TextEditingController trackArtiste = TextEditingController(); - trackTitle.text = hp.currentTrack?.title ?? ''; - trackArtiste.text = hp.currentTrack?.artiste ?? ''; - return Miniplayer( - controller: controller, - backgroundColor: Colors.grey[900]!, - minHeight: 70, - maxHeight: 70, - builder: (height, percentage) { - return Row( - // mainAxisAlignment: MainAxisAlignment.spaceBetween, - children: [ - hp.currentTrack?.imageUrl != '' && - hp.currentTrack?.imageUrl != null - ? Image.network( - hp.currentTrack!.imageUrl!, - width: 70, - ) - : const SizedBox(width: 70), - Expanded( - child: Column(children: [ - SizedBox( - height: 20, - child: TextField( - enabled: false, - maxLines: 1, - controller: trackTitle, - decoration: const InputDecoration( - border: InputBorder.none, - focusedBorder: InputBorder.none, - enabledBorder: InputBorder.none, - disabledBorder: InputBorder.none, - contentPadding: EdgeInsets.only(left: 15), - ), - style: TextStyle( - fontSize: 14, - color: Colors.grey[300], - ), - ), - ), - SizedBox( - height: 20, - child: TextField( - enabled: false, - maxLines: 1, - controller: trackArtiste, - decoration: const InputDecoration( - border: InputBorder.none, - focusedBorder: InputBorder.none, - enabledBorder: InputBorder.none, - disabledBorder: InputBorder.none, - contentPadding: EdgeInsets.only(left: 15), - ), - style: TextStyle( - fontSize: 12, - color: Colors.grey[500], - ), - ), - ), - ]), - ), - Column(children: [ - const Spacer(), - Row(children: [ - const SizedBox(width: 70), - Column(children: [ - IconButton( - padding: const EdgeInsets.all(0), - icon: Icon(Icons.skip_previous, - color: Colors.grey[500], size: 32), - onPressed: () { - if (hp.currentTrack != null && - hp.currentTrack!.number > 1) { - hp.currentTrack = hp.trackList.firstWhere( - (element) => - element.number == - hp.currentTrack!.number - 1); - hp.playTrack(context, hp.currentTrack!); - } - }), - ]), - const SizedBox(width: 1), - ElevatedButton( - onPressed: () { - hp.player?.playing ?? false - ? hp.player?.pause() - : hp.player?.play(); - playerProvider.reload(); }, - child: Icon( + ), + const SizedBox(height: 70) + ], + ), + )), + ), + Consumer(builder: (context, playerProvider, _) { + TextEditingController trackTitle = TextEditingController(); + TextEditingController trackArtiste = TextEditingController(); + trackTitle.text = hp.currentTrack?.title ?? ''; + trackArtiste.text = hp.currentTrack?.artiste ?? ''; + return Miniplayer( + controller: controller, + backgroundColor: Colors.grey[900]!, + minHeight: 70, + maxHeight: 70, + builder: (height, percentage) { + return Row( + // mainAxisAlignment: MainAxisAlignment.spaceBetween, + children: [ + hp.currentTrack?.imageUrl != '' && + hp.currentTrack?.imageUrl != null + ? Image.network( + hp.currentTrack!.imageUrl!, + width: 70, + ) + : const SizedBox(width: 70), + Expanded( + child: Column(children: [ + SizedBox( + height: 20, + child: TextField( + enabled: false, + maxLines: 1, + controller: trackTitle, + decoration: const InputDecoration( + border: InputBorder.none, + focusedBorder: InputBorder.none, + enabledBorder: InputBorder.none, + disabledBorder: InputBorder.none, + contentPadding: EdgeInsets.only(left: 15), + ), + style: TextStyle( + fontSize: 14, + color: Colors.grey[300], + ), + ), + ), + SizedBox( + height: 20, + child: TextField( + enabled: false, + maxLines: 1, + controller: trackArtiste, + decoration: const InputDecoration( + border: InputBorder.none, + focusedBorder: InputBorder.none, + enabledBorder: InputBorder.none, + disabledBorder: InputBorder.none, + contentPadding: EdgeInsets.only(left: 15), + ), + style: TextStyle( + fontSize: 12, + color: Colors.grey[500], + ), + ), + ), + ]), + ), + Column(children: [ + const Spacer(), + Row(children: [ + const SizedBox(width: 70), + Column(children: [ + IconButton( + padding: const EdgeInsets.all(0), + icon: Icon(Icons.skip_previous, + color: Colors.grey[500], size: 32), + onPressed: () { + if (hp.currentTrack != null && + hp.currentTrack!.number > 1) { + hp.currentTrack = hp.trackList.firstWhere( + (element) => + element.number == + hp.currentTrack!.number - 1); + hp.playTrack(context, hp.currentTrack!); + } + }), + ]), + const SizedBox(width: 1), + ElevatedButton( + onPressed: () { hp.player?.playing ?? false - ? Icons.pause - : Icons.play_arrow, - color: Colors.grey[900], - size: 30), - style: ElevatedButton.styleFrom( - shape: const CircleBorder(), - padding: const EdgeInsets.all(12), - primary: Colors.grey[300], - onPrimary: Colors.grey[900], - ), - ), - Column(children: [ - IconButton( - padding: const EdgeInsets.all(0), - icon: Icon(Icons.skip_next, - color: Colors.grey[500], size: 32), - onPressed: () { - if (hp.currentTrack != null && - hp.currentTrack!.number < - hp.trackList.last.number) { - hp.currentTrack = hp.trackList.firstWhere( - (element) => - element.number == - hp.currentTrack!.number + 1); - hp.playTrack(context, hp.currentTrack!); - } - }), - // const SizedBox(height: 7), - ]), - ]), - const Spacer(), - Row(children: [ - const SizedBox(width: 70), - Text( - timeFormat( - hp.player?.position ?? const Duration(seconds: 0)), - style: TextStyle(color: Colors.grey[500], fontSize: 12), - ), - const SizedBox(width: 3), - SliderTheme( - data: const SliderThemeData( - thumbShape: - RoundSliderThumbShape(enabledThumbRadius: 2), - overlayShape: - RoundSliderThumbShape(enabledThumbRadius: 5), - trackHeight: 2, - ), - child: SizedBox( - width: 300, - child: Slider( - value: double.parse( - hp.player?.position.inSeconds.toString() ?? - '0'), - max: double.parse( - hp.player?.duration.inSeconds.toString() ?? - '2000'), - onChanged: (double value) { - if (hp.player?.position != null) { - hp.player!.position = - Duration(seconds: value.toInt()); - playerProvider.reload(); - } - }, - activeColor: Colors.grey[400], - inactiveColor: Colors.grey[700], + ? hp.player?.pause() + : hp.player?.play(); + // playerProvider.reload(); + }, + child: Icon( + hp.player?.playing ?? false + ? Icons.pause + : Icons.play_arrow, + color: Colors.grey[900], + size: 30), + style: ElevatedButton.styleFrom( + shape: const CircleBorder(), + padding: const EdgeInsets.all(12), + primary: Colors.grey[300], + onPrimary: Colors.grey[900], ), ), - ), - const SizedBox(width: 3), - Text( - timeFormat( - hp.player?.duration ?? const Duration(seconds: 0)), - style: TextStyle(color: Colors.grey[500], fontSize: 12), - ), + Column(children: [ + IconButton( + padding: const EdgeInsets.all(0), + icon: Icon(Icons.skip_next, + color: Colors.grey[500], size: 32), + onPressed: () { + if (hp.currentTrack != null && + hp.currentTrack!.number < + hp.trackList.last.number) { + hp.currentTrack = hp.trackList.firstWhere( + (element) => + element.number == + hp.currentTrack!.number + 1); + hp.playTrack(context, hp.currentTrack!); + } + }), + // const SizedBox(height: 7), + ]), + ]), + const Spacer(), + Row(children: [ + const SizedBox(width: 70), + Text( + timeFormat(hp.player?.position ?? + const Duration(seconds: 0)), + style: + TextStyle(color: Colors.grey[500], fontSize: 12), + ), + const SizedBox(width: 3), + SliderTheme( + data: const SliderThemeData( + thumbShape: + RoundSliderThumbShape(enabledThumbRadius: 2), + overlayShape: + RoundSliderThumbShape(enabledThumbRadius: 5), + trackHeight: 2, + ), + child: SizedBox( + width: 300, + child: Slider( + value: double.parse( + hp.player?.position.inSeconds.toString() ?? + '0'), + max: double.parse( + hp.player?.duration.inSeconds.toString() ?? + '2000'), + onChanged: (double value) { + if (hp.player?.position != null) { + hp.player!.position = + Duration(seconds: value.toInt()); + playerProvider.reload(); + } + }, + activeColor: Colors.grey[400], + inactiveColor: Colors.grey[700], + ), + ), + ), + const SizedBox(width: 3), + Text( + timeFormat(hp.player?.duration ?? + const Duration(seconds: 0)), + style: + TextStyle(color: Colors.grey[500], fontSize: 12), + ), + ]), + const Spacer(), ]), const Spacer(), - ]), - const Spacer(), - SliderTheme( - data: const SliderThemeData( - thumbShape: RoundSliderThumbShape(enabledThumbRadius: 7), - overlayShape: - RoundSliderThumbShape(enabledThumbRadius: 8), - trackHeight: 2.5, - ), - child: SizedBox( - width: 130, - child: Slider( - value: hp.player?.volume ?? 1, - max: 1, - onChanged: (double value) { - if (hp.player?.volume != null) { - hp.player!.volume = value; - playerProvider.reload(); - } - }, - activeColor: Colors.grey[400], - inactiveColor: Colors.grey[700], + SliderTheme( + data: const SliderThemeData( + thumbShape: + RoundSliderThumbShape(enabledThumbRadius: 7), + overlayShape: + RoundSliderThumbShape(enabledThumbRadius: 8), + trackHeight: 2.5, + ), + child: SizedBox( + width: 130, + child: Slider( + value: hp.player?.volume ?? 1, + max: 1, + onChanged: (double value) { + if (hp.player?.volume != null) { + hp.player!.volume = value; + playerProvider.reload(); + } + }, + activeColor: Colors.grey[400], + inactiveColor: Colors.grey[700], + ), ), ), - ), - const SizedBox(width: 20) - ], - ); - }, - ); - }) - ], + const SizedBox(width: 20) + ], + ); + }, + ); + }) + ], + ), ); } } diff --git a/make_exe.iss b/make_exe.iss index 128a32b..f9eb85c 100644 --- a/make_exe.iss +++ b/make_exe.iss @@ -40,7 +40,7 @@ Source: "C:\Users\poka\dev\fipy\build\windows\runner\Release\dart_vlc_plugin.dll Source: "C:\Users\poka\dev\fipy\build\windows\runner\Release\flutter_windows.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "C:\Users\poka\dev\fipy\build\windows\runner\Release\libvlc.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "C:\Users\poka\dev\fipy\build\windows\runner\Release\libvlccore.dll"; DestDir: "{app}"; Flags: ignoreversion -Source: "C:\Users\poka\dev\fipy\build\windows\runner\Release\url_launcher_windows_plugin.dll"; DestDir: "{app}"; Flags: ignoreversion +Source: "C:\Users\poka\dev\fipy\build\windows\runner\Release\audioplayers_windows_plugin.dll"; DestDir: "{app}"; Flags: ignoreversion Source: "C:\Users\poka\dev\fipy\build\windows\runner\Release\data\*"; DestDir: "{app}\data"; Flags: ignoreversion recursesubdirs createallsubdirs Source: "C:\Users\poka\dev\fipy\build\windows\runner\Release\plugins\*"; DestDir: "{app}\plugins"; Flags: ignoreversion recursesubdirs createallsubdirs ; NOTE: Don't use "Flags: ignoreversion" on any shared system files diff --git a/pubspec.lock b/pubspec.lock index b8328e8..b5d2371 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -36,6 +36,48 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.10.0" + audioplayers: + dependency: transitive + description: + name: audioplayers + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0-rc.2" + audioplayers_android: + dependency: transitive + description: + name: audioplayers_android + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0-rc.2" + audioplayers_darwin: + dependency: transitive + description: + name: audioplayers_darwin + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0-rc.2" + audioplayers_platform_interface: + dependency: transitive + description: + name: audioplayers_platform_interface + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0-rc.2" + audioplayers_web: + dependency: transitive + description: + name: audioplayers_web + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0-rc.2" + audioplayers_windows: + dependency: transitive + description: + name: audioplayers_windows + url: "https://pub.dartlang.org" + source: hosted + version: "1.0.0-rc.2" boolean_selector: dependency: transitive description: @@ -70,7 +112,7 @@ packages: name: collection url: "https://pub.dartlang.org" source: hosted - version: "1.15.0" + version: "1.16.0" crypto: dependency: transitive description: @@ -112,7 +154,7 @@ packages: name: fake_async url: "https://pub.dartlang.org" source: hosted - version: "1.2.0" + version: "1.3.0" ffi: dependency: transitive description: @@ -120,13 +162,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.1.2" - ffmpeg_cli: - dependency: "direct main" - description: - name: ffmpeg_cli - url: "https://pub.dartlang.org" - source: hosted - version: "0.1.0" file: dependency: transitive description: @@ -204,7 +239,7 @@ packages: name: js url: "https://pub.dartlang.org" source: hosted - version: "0.6.3" + version: "0.6.4" json_annotation: dependency: transitive description: @@ -247,6 +282,13 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "0.0.12" + kplayer_with_audioplayers: + dependency: "direct main" + description: + name: kplayer_with_audioplayers + url: "https://pub.dartlang.org" + source: hosted + version: "0.0.10" kplayer_with_dart_vlc: dependency: transitive description: @@ -268,13 +310,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.0.1" - logging: - dependency: transitive - description: - name: logging - url: "https://pub.dartlang.org" - source: hosted - version: "1.0.2" matcher: dependency: transitive description: @@ -288,7 +323,7 @@ packages: name: material_color_utilities url: "https://pub.dartlang.org" source: hosted - version: "0.1.3" + version: "0.1.4" meta: dependency: transitive description: @@ -318,7 +353,7 @@ packages: name: path url: "https://pub.dartlang.org" source: hosted - version: "1.8.0" + version: "1.8.1" path_provider: dependency: "direct main" description: @@ -421,7 +456,7 @@ packages: name: source_span url: "https://pub.dartlang.org" source: hosted - version: "1.8.1" + version: "1.8.2" stack_trace: dependency: transitive description: @@ -456,7 +491,7 @@ packages: name: test_api url: "https://pub.dartlang.org" source: hosted - version: "0.4.8" + version: "0.4.9" typed_data: dependency: transitive description: @@ -471,62 +506,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "2.0.4" - url_launcher: - dependency: "direct main" - description: - name: url_launcher - url: "https://pub.dartlang.org" - source: hosted - version: "6.1.0" - url_launcher_android: - dependency: transitive - description: - name: url_launcher_android - url: "https://pub.dartlang.org" - source: hosted - version: "6.0.16" - url_launcher_ios: - dependency: transitive - description: - name: url_launcher_ios - url: "https://pub.dartlang.org" - source: hosted - version: "6.0.15" - url_launcher_linux: - dependency: transitive - description: - name: url_launcher_linux - url: "https://pub.dartlang.org" - source: hosted - version: "3.0.0" - url_launcher_macos: - dependency: transitive - description: - name: url_launcher_macos - url: "https://pub.dartlang.org" - source: hosted - version: "3.0.0" - url_launcher_platform_interface: - dependency: transitive - description: - name: url_launcher_platform_interface - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.5" - url_launcher_web: - dependency: transitive - description: - name: url_launcher_web - url: "https://pub.dartlang.org" - source: hosted - version: "2.0.9" - url_launcher_windows: - dependency: transitive - description: - name: url_launcher_windows - url: "https://pub.dartlang.org" - source: hosted - version: "3.0.0" uuid: dependency: transitive description: @@ -540,7 +519,7 @@ packages: name: vector_math url: "https://pub.dartlang.org" source: hosted - version: "2.1.1" + version: "2.1.2" win32: dependency: transitive description: @@ -577,5 +556,5 @@ packages: source: hosted version: "1.11.0" sdks: - dart: ">=2.16.2 <3.0.0" - flutter: ">=2.10.0" + dart: ">=2.17.0-266.5.beta <3.0.0" + flutter: ">=2.8.1" diff --git a/pubspec.yaml b/pubspec.yaml index 4e73cf4..439a56c 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -2,7 +2,7 @@ name: fipy description: Advanced FIP radio track explorer publish_to: 'none' # Remove this line if you wish to publish to pub.dev -version: 0.0.1+1 +version: 0.0.2+1 environment: sdk: ">=2.16.2 <3.0.0" @@ -15,10 +15,9 @@ dependencies: # git: # url: https://git.p2p.legal/poka/youtube_explode.git # ref: master - url_launcher: ^6.1.0 http: ^0.13.4 kplayer: ^0.1.18 - # kplayer_with_audioplayers: ^0.0.10 + kplayer_with_audioplayers: ^0.0.10 miniplayer: #^1.0.1 git: url: https://git.p2p.legal/poka/flutter_miniplayer.git @@ -26,7 +25,8 @@ dependencies: provider: ^6.0.1 path_provider: ^2.0.9 universal_io: ^2.0.4 - ffmpeg_cli: ^0.1.0 + # ffmpeg_cli: ^0.1.0 + # audioplayers: ^1.0.0-rc.2 dev_dependencies: flutter_test: @@ -40,14 +40,14 @@ flutter_icons: # macos: true windows: true web: true - image_path: "assets/logo_aquamarine.jpg" + image_path: "assets/logo_green_dark.jpg" flutter: uses-material-design: true # To add assets to your application, add an assets section, like this: - assets: - - assets/test.webm + # assets: + # - assets/test.webm # An image asset can refer to one or more resolution-specific "variants", see # https://flutter.dev/assets-and-images/#resolution-aware. diff --git a/web/favicon.png b/web/favicon.png index 4164b8f..d606bac 100644 Binary files a/web/favicon.png and b/web/favicon.png differ diff --git a/web/icons/Icon-192.png b/web/icons/Icon-192.png index 0f3b0e2..286fb92 100644 Binary files a/web/icons/Icon-192.png and b/web/icons/Icon-192.png differ diff --git a/web/icons/Icon-512.png b/web/icons/Icon-512.png index cb4a61d..3be6407 100644 Binary files a/web/icons/Icon-512.png and b/web/icons/Icon-512.png differ diff --git a/web/icons/Icon-maskable-192.png b/web/icons/Icon-maskable-192.png index 0f3b0e2..286fb92 100644 Binary files a/web/icons/Icon-maskable-192.png and b/web/icons/Icon-maskable-192.png differ diff --git a/web/icons/Icon-maskable-512.png b/web/icons/Icon-maskable-512.png index cb4a61d..3be6407 100644 Binary files a/web/icons/Icon-maskable-512.png and b/web/icons/Icon-maskable-512.png differ diff --git a/windows/CMakeLists.txt b/windows/CMakeLists.txt index ecb052b..c3a4094 100644 --- a/windows/CMakeLists.txt +++ b/windows/CMakeLists.txt @@ -1,13 +1,16 @@ +# Project-level configuration. cmake_minimum_required(VERSION 3.14) project(fipy LANGUAGES CXX) +# The name of the executable created for the application. Change this to change +# the on-disk name of your application. set(BINARY_NAME "fipy") +# Explicitly opt in to modern CMake behaviors to avoid warnings with recent +# versions of CMake. cmake_policy(SET CMP0063 NEW) -set(CMAKE_INSTALL_RPATH "$ORIGIN/lib") - -# Configure build options. +# Define build configuration option. get_property(IS_MULTICONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG) if(IS_MULTICONFIG) set(CMAKE_CONFIGURATION_TYPES "Debug;Profile;Release" @@ -20,7 +23,7 @@ else() "Debug" "Profile" "Release") endif() endif() - +# Define settings for the Profile build mode. set(CMAKE_EXE_LINKER_FLAGS_PROFILE "${CMAKE_EXE_LINKER_FLAGS_RELEASE}") set(CMAKE_SHARED_LINKER_FLAGS_PROFILE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE}") set(CMAKE_C_FLAGS_PROFILE "${CMAKE_C_FLAGS_RELEASE}") @@ -30,6 +33,10 @@ set(CMAKE_CXX_FLAGS_PROFILE "${CMAKE_CXX_FLAGS_RELEASE}") add_definitions(-DUNICODE -D_UNICODE) # Compilation settings that should be applied to most targets. +# +# Be cautious about adding new options here, as plugins use this function by +# default. In most cases, you should add new options to specific targets instead +# of modifying this function. function(APPLY_STANDARD_SETTINGS TARGET) target_compile_features(${TARGET} PUBLIC cxx_std_17) target_compile_options(${TARGET} PRIVATE /W4 /WX /wd"4100") @@ -38,12 +45,11 @@ function(APPLY_STANDARD_SETTINGS TARGET) target_compile_definitions(${TARGET} PRIVATE "$<$:_DEBUG>") endfunction() -set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") - # Flutter library and tool build rules. +set(FLUTTER_MANAGED_DIR "${CMAKE_CURRENT_SOURCE_DIR}/flutter") add_subdirectory(${FLUTTER_MANAGED_DIR}) -# Application build +# Application build; see runner/CMakeLists.txt. add_subdirectory("runner") # Generated plugin build rules, which manage building the plugins and adding diff --git a/windows/flutter/CMakeLists.txt b/windows/flutter/CMakeLists.txt index b2e4bd8..930d207 100644 --- a/windows/flutter/CMakeLists.txt +++ b/windows/flutter/CMakeLists.txt @@ -1,3 +1,4 @@ +# This file controls Flutter-level build steps. It should not be edited. cmake_minimum_required(VERSION 3.14) set(EPHEMERAL_DIR "${CMAKE_CURRENT_SOURCE_DIR}/ephemeral") diff --git a/windows/flutter/generated_plugin_registrant.cc b/windows/flutter/generated_plugin_registrant.cc index 471b9ba..7ffc1ef 100644 --- a/windows/flutter/generated_plugin_registrant.cc +++ b/windows/flutter/generated_plugin_registrant.cc @@ -6,12 +6,12 @@ #include "generated_plugin_registrant.h" +#include #include -#include void RegisterPlugins(flutter::PluginRegistry* registry) { + AudioplayersWindowsPluginRegisterWithRegistrar( + registry->GetRegistrarForPlugin("AudioplayersWindowsPlugin")); DartVlcPluginRegisterWithRegistrar( registry->GetRegistrarForPlugin("DartVlcPlugin")); - UrlLauncherWindowsRegisterWithRegistrar( - registry->GetRegistrarForPlugin("UrlLauncherWindows")); } diff --git a/windows/flutter/generated_plugins.cmake b/windows/flutter/generated_plugins.cmake index 523e4c3..2847f49 100644 --- a/windows/flutter/generated_plugins.cmake +++ b/windows/flutter/generated_plugins.cmake @@ -3,8 +3,11 @@ # list(APPEND FLUTTER_PLUGIN_LIST + audioplayers_windows dart_vlc - url_launcher_windows +) + +list(APPEND FLUTTER_FFI_PLUGIN_LIST ) set(PLUGIN_BUNDLED_LIBRARIES) @@ -15,3 +18,8 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST}) list(APPEND PLUGIN_BUNDLED_LIBRARIES $) list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/windows/runner/CMakeLists.txt b/windows/runner/CMakeLists.txt index de2d891..b9e550f 100644 --- a/windows/runner/CMakeLists.txt +++ b/windows/runner/CMakeLists.txt @@ -1,6 +1,11 @@ cmake_minimum_required(VERSION 3.14) project(runner LANGUAGES CXX) +# Define the application target. To change its name, change BINARY_NAME in the +# top-level CMakeLists.txt, not the value here, or `flutter run` will no longer +# work. +# +# Any new source files that you add to the application should be added here. add_executable(${BINARY_NAME} WIN32 "flutter_window.cpp" "main.cpp" @@ -10,8 +15,18 @@ add_executable(${BINARY_NAME} WIN32 "Runner.rc" "runner.exe.manifest" ) + +# Apply the standard set of build settings. This can be removed for applications +# that need different build settings. apply_standard_settings(${BINARY_NAME}) + +# Disable Windows macros that collide with C++ standard library functions. target_compile_definitions(${BINARY_NAME} PRIVATE "NOMINMAX") + +# Add dependency libraries and include directories. Add any application-specific +# dependencies here. target_link_libraries(${BINARY_NAME} PRIVATE flutter flutter_wrapper_app) target_include_directories(${BINARY_NAME} PRIVATE "${CMAKE_SOURCE_DIR}") + +# Run the Flutter tool portions of the build. This must not be removed. add_dependencies(${BINARY_NAME} flutter_assemble) diff --git a/windows/runner/resources/app_icon.ico b/windows/runner/resources/app_icon.ico index e8698fa..a1e320e 100644 Binary files a/windows/runner/resources/app_icon.ico and b/windows/runner/resources/app_icon.ico differ diff --git a/windows/runner/utils.cpp b/windows/runner/utils.cpp index d19bdbb..f5bf9fa 100644 --- a/windows/runner/utils.cpp +++ b/windows/runner/utils.cpp @@ -48,10 +48,10 @@ std::string Utf8FromUtf16(const wchar_t* utf16_string) { int target_length = ::WideCharToMultiByte( CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string, -1, nullptr, 0, nullptr, nullptr); - if (target_length == 0) { - return std::string(); - } std::string utf8_string; + if (target_length == 0 || target_length > utf8_string.max_size()) { + return utf8_string; + } utf8_string.resize(target_length); int converted_length = ::WideCharToMultiByte( CP_UTF8, WC_ERR_INVALID_CHARS, utf16_string,