adapt for web prod; add icon; fix a few bugs

This commit is contained in:
poka 2022-04-30 19:29:24 +02:00
parent cca3d63737
commit 7592660c0b
43 changed files with 110 additions and 49 deletions

4
.gitignore vendored
View File

@ -45,7 +45,5 @@ app.*.map.json
/android/app/profile
/android/app/release
# API custom token
api-token.json
assets/
# Windows build setup
Output/

View File

@ -3,7 +3,7 @@
<application
android:label="fip_parser_ui"
android:name="${applicationName}"
android:icon="@mipmap/ic_launcher">
android:icon="@mipmap/launcher_icon">
<activity
android:name=".MainActivity"
android:exported="true"

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 11 KiB

View File

@ -1,3 +0,0 @@
{
"token": "xxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"
}

BIN
assets/logo.jpg Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.1 KiB

View File

@ -478,4 +478,4 @@
/* End XCConfigurationList section */
};
rootObject = 97C146E61CF9000F007C117D /* Project object */;
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 117 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 564 B

After

Width:  |  Height:  |  Size: 467 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 KiB

After

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.0 KiB

After

Width:  |  Height:  |  Size: 712 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.7 KiB

After

Width:  |  Height:  |  Size: 1.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 5.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

After

Width:  |  Height:  |  Size: 9.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 7.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 8.7 KiB

View File

@ -1,4 +1,7 @@
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
late String token;
TextStyle globalTextStyle = TextStyle(color: Colors.grey[350]);
const proxyHeader =
kDebugMode || !kIsWeb ? 'https://' : 'http://127.0.0.1:8080/';

View File

@ -1,18 +1,13 @@
import 'dart:convert';
import 'package:fip_parser_ui/globals.dart';
import 'package:fip_parser_ui/providers/home.dart';
import 'package:fip_parser_ui/providers/player.dart';
import 'package:fip_parser_ui/screens/home.dart';
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import 'package:flutter/services.dart';
import 'package:kplayer/kplayer.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
Player.boot();
final tokenFile = await rootBundle.loadString('assets/api-token.json');
token = json.decode(tokenFile)['token'];
runApp(const FipyApp());
}

View File

@ -1,4 +1,4 @@
import 'dart:io';
import 'package:universal_io/io.dart';
class Track {
final int number;

View File

@ -1,7 +1,9 @@
// ignore_for_file: avoid_print
import 'dart:convert';
import 'dart:io';
import 'package:fip_parser_ui/globals.dart';
import 'package:flutter/foundation.dart';
import 'package:universal_io/io.dart';
import 'package:fip_parser_ui/models/track.dart';
import 'package:flutter/material.dart';
import 'package:kplayer/kplayer.dart';
@ -25,11 +27,12 @@ class HomeProvider with ChangeNotifier {
bool stop = false;
while (pageNbr < userPageNbr && !stop) {
final req = Uri.parse(
'https://www.radiofrance.fr/api/v1.7/stations/fip/webradios/$radio/songs?pageCursor=$cursor');
'${proxyHeader}www.radiofrance.fr:443/api/v1.7/stations/fip/webradios/$radio/songs?pageCursor=$cursor');
final res = await get(req, headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, HEAD, POST, OPTIONS"
"Access-Control-Allow-Methods": "GET, HEAD, POST, OPTIONS",
'Content-Type': 'text/plain'
});
if (res.statusCode == 200) {
Map body = jsonDecode(res.body);
@ -76,22 +79,22 @@ class HomeProvider with ChangeNotifier {
currentTrack = track;
final currentVolume = player?.volume ?? 1;
player?.dispose();
if (player?.playing ?? false) player?.stop();
Future.delayed(const Duration(milliseconds: 5));
if (track.file == null) {
if (track.id == null) {
final secondMatch = track.artiste == '' ? track.album : track.artiste;
final resultUrl =
await yt.search.search(track.title + ' ' + secondMatch!);
track.id = resultUrl.first.id.value;
}
player = Player.network(
"https://invidious.fdn.fr/embed/${track.id}?raw=1&?listen=1");
print(track.id);
} else {
player = Player.asset(track.file!.path);
if (track.id == null) {
final secondMatch = track.artiste == '' ? track.album : track.artiste;
final resultUrl =
await yt.search.search(track.title + ' ' + secondMatch!);
track.id = resultUrl.first.id.value;
}
const invidiousUrl =
'yewtu.be'; //yewtu.be vid.puffyan.us invidious.snopyta.org invidious.fdn.fr
player = Player.network(
"https://$invidiousUrl/embed/${track.id}?raw=1&listen=1&quality=dash");
print(track.id);
player!.volume = currentVolume;
try {
@ -101,11 +104,12 @@ class HomeProvider with ChangeNotifier {
}
Future.delayed(const Duration(milliseconds: 500));
player!.callback = (PlayerEvent event) {
print(event.name);
if (event.name == 'position') {
currentTrack!.duration = player!.duration;
playerProvider.reload();
}
if (event.name == 'status') {
if (event.name == 'status' && player!.position == player!.duration) {
var nextTrack = trackList
.firstWhere((element) => element.number == track.number + 1);
playTrack(context, nextTrack);
@ -123,8 +127,6 @@ class HomeProvider with ChangeNotifier {
var streamManifest = StreamManifest(manifest.streams);
var streamInfo = streamManifest.audioOnly.withHighestBitrate();
var stream = yt.videos.streamsClient.get(streamInfo);
final filePath = await getDownloadsDirectory();
final fileName = '${track.title} - ${track.artiste}'
.replaceAll('\\', '')
.replaceAll('/', '')
@ -135,20 +137,25 @@ class HomeProvider with ChangeNotifier {
.replaceAll('<', '')
.replaceAll('>', '')
.replaceAll('|', '');
var file = File('${filePath!.path}/$fileName.webm');
var fileStream = file.openWrite();
await stream.pipe(fileStream);
if (!kIsWeb) {
final filePath = Platform.isAndroid
? Directory('/storage/emulated/0/Download')
: await getDownloadsDirectory();
await fileStream.flush();
await fileStream.close();
yt.close();
var file = File('${filePath!.path}/$fileName.webm');
var fileStream = file.openWrite();
// Play it
track.file = file;
// playTrack(context, track);
await stream.pipe(fileStream);
print(file.path);
await fileStream.flush();
await fileStream.close();
yt.close();
track.file = file;
print(file.path);
}
}
List<DropdownMenuItem<String>> get radioList {

View File

@ -409,7 +409,7 @@ TableRow _buildTableRow(Track track, BuildContext context) {
return Text(track.title,
style: TextStyle(
fontWeight: FontWeight.normal,
color: hp.currentTrack == track
color: hp.currentTrack?.title == track.title && hp.currentTrack?.artiste == track.artiste
? Colors.green
: Colors.grey[350],
fontSize: 14));
@ -454,8 +454,7 @@ TableRow _buildTableRow(Track track, BuildContext context) {
},
child: track.number == -1
? Text('TÉLÉCHARGER', style: textStyle)
: Consumer<DownloadProvider>(
builder: (context, playerProvider, _) {
: Consumer<DownloadProvider>(builder: (context, _, __) {
return Row(children: [
const SizedBox(width: 37),
isDownloading == track.number

View File

@ -7,6 +7,9 @@ list(APPEND FLUTTER_PLUGIN_LIST
url_launcher_linux
)
list(APPEND FLUTTER_FFI_PLUGIN_LIST
)
set(PLUGIN_BUNDLED_LIBRARIES)
foreach(plugin ${FLUTTER_PLUGIN_LIST})
@ -15,3 +18,8 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST})
list(APPEND PLUGIN_BUNDLED_LIBRARIES $<TARGET_FILE:${plugin}_plugin>)
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}/linux plugins/${ffi_plugin})
list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries})
endforeach(ffi_plugin)

View File

@ -1,6 +1,20 @@
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
archive:
dependency: transitive
description:
name: archive
url: "https://pub.dartlang.org"
source: hosted
version: "3.3.0"
args:
dependency: transitive
description:
name: args
url: "https://pub.dartlang.org"
source: hosted
version: "2.3.0"
async:
dependency: transitive
description:
@ -118,6 +132,13 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
flutter_launcher_icons_maker:
dependency: "direct dev"
description:
name: flutter_launcher_icons_maker
url: "https://pub.dartlang.org"
source: hosted
version: "0.10.2"
flutter_lints:
dependency: "direct dev"
description:
@ -163,6 +184,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "4.0.0"
image:
dependency: transitive
description:
name: image
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.3"
js:
dependency: transitive
description:
@ -422,6 +450,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "1.3.0"
universal_io:
dependency: "direct main"
description:
name: universal_io
url: "https://pub.dartlang.org"
source: hosted
version: "2.0.4"
url_launcher:
dependency: "direct main"
description:
@ -513,6 +548,13 @@ packages:
url: "https://pub.dartlang.org"
source: hosted
version: "5.3.1"
yaml:
dependency: transitive
description:
name: yaml
url: "https://pub.dartlang.org"
source: hosted
version: "3.1.0"
youtube_explode_dart:
dependency: "direct main"
description:

View File

@ -11,7 +11,10 @@ dependencies:
flutter:
sdk: flutter
cupertino_icons: ^1.0.2
youtube_explode_dart: ^1.10.9+1
youtube_explode_dart: #^1.10.9+1
# git:
# url: https://git.p2p.legal/poka/youtube_explode.git
# ref: master
url_launcher: ^6.1.0
http: ^0.13.4
kplayer: ^0.1.12
@ -21,19 +24,28 @@ dependencies:
ref: master
provider: ^6.0.1
path_provider: ^2.0.9
universal_io: ^2.0.4
dev_dependencies:
flutter_test:
sdk: flutter
flutter_lints: ^1.0.0
flutter_launcher_icons_maker: ^0.10.2
flutter_icons:
android: "launcher_icon"
ios: true
macos: true
windows: true
web: true
image_path: "assets/logo.jpg"
flutter:
uses-material-design: true
# To add assets to your application, add an assets section, like this:
assets:
- assets/api-token.json
- assets/logo.jpg
# An image asset can refer to one or more resolution-specific "variants", see
# https://flutter.dev/assets-and-images/#resolution-aware.

Binary file not shown.

Before

Width:  |  Height:  |  Size: 917 B

After

Width:  |  Height:  |  Size: 394 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 5.2 KiB

After

Width:  |  Height:  |  Size: 11 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 8.1 KiB

After

Width:  |  Height:  |  Size: 43 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 33 KiB

After

Width:  |  Height:  |  Size: 825 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 825 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB