Skip to content

Commit

Permalink
优化播放页面和侧滑动画;解决部分机型锁60帧率的问题;自定义背景;缓存歌曲;开启高音质选项(不是破解版,需要会员);新增滑动切歌;修复部分…
Browse files Browse the repository at this point in the history
…酷友提交的bug;
  • Loading branch information
2697a committed Feb 13, 2023
1 parent 109aeb0 commit caeba1b
Show file tree
Hide file tree
Showing 205 changed files with 11,163 additions and 1,468 deletions.
4 changes: 2 additions & 2 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ apply plugin: 'kotlin-android'
apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle"

android {
compileSdkVersion flutter.compileSdkVersion
compileSdkVersion 31
ndkVersion flutter.ndkVersion

compileOptions {
Expand All @@ -56,7 +56,7 @@ android {
// You can update the following values to match your application needs.
// For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-build-configuration.
minSdkVersion flutter.minSdkVersion
targetSdkVersion flutter.targetSdkVersion
targetSdkVersion 31
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true //添加在此
Expand Down
1 change: 1 addition & 0 deletions android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
android:exported="true"
android:hardwareAccelerated="true"
android:launchMode="singleTop"
android:screenOrientation="portrait"
android:theme="@style/LaunchTheme"
android:windowSoftInputMode="adjustResize">

Expand Down
Binary file removed assets/font/tabler.ttf
Binary file not shown.
Binary file added assets/images/coffee.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
12 changes: 6 additions & 6 deletions ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 24;
CURRENT_PROJECT_VERSION = 25;
DEVELOPMENT_TEAM = ZQN678KJFF;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
Expand All @@ -367,7 +367,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.0.4;
MARKETING_VERSION = 2.0.5;
PRODUCT_BUNDLE_IDENTIFIER = com.sixbugs.bujuan;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down Expand Up @@ -492,7 +492,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 24;
CURRENT_PROJECT_VERSION = 25;
DEVELOPMENT_TEAM = ZQN678KJFF;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
Expand All @@ -501,7 +501,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.0.4;
MARKETING_VERSION = 2.0.5;
PRODUCT_BUNDLE_IDENTIFIER = com.sixbugs.bujuan;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand All @@ -520,7 +520,7 @@
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 24;
CURRENT_PROJECT_VERSION = 25;
DEVELOPMENT_TEAM = ZQN678KJFF;
ENABLE_BITCODE = NO;
INFOPLIST_FILE = Runner/Info.plist;
Expand All @@ -529,7 +529,7 @@
"$(inherited)",
"@executable_path/Frameworks",
);
MARKETING_VERSION = 2.0.4;
MARKETING_VERSION = 2.0.5;
PRODUCT_BUNDLE_IDENTIFIER = com.sixbugs.bujuan;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
Expand Down
67 changes: 41 additions & 26 deletions lib/common/bujuan_audio_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ class BujuanAudioHandler extends BaseAudioHandler with SeekHandler, QueueHandler

@override
Future<void> addFmItems(List<MediaItem> mediaItems, bool isAddcurIndex) async {
if (HomeController.to.fm.value && _playList.length >= 3) {
if (Home.to.fm.value && _playList.length >= 3) {
_playList.removeRange(0, queue.value.length - 1);
updateQueue(_playList);
addQueueItems(mediaItems);
Expand All @@ -197,7 +197,7 @@ class BujuanAudioHandler extends BaseAudioHandler with SeekHandler, QueueHandler
_curIndex = 0;
_playList.addAll(mediaItems);
if (isAddcurIndex) _curIndex++;
if (!HomeController.to.fm.value) HomeController.to.fm.value = true;
if (!Home.to.fm.value) Home.to.fm.value = true;
playIndex(_curIndex);
List<String> playList = mediaItems
.map((e) => jsonEncode(MediaItemMessage(
Expand Down Expand Up @@ -225,19 +225,19 @@ class BujuanAudioHandler extends BaseAudioHandler with SeekHandler, QueueHandler
@override
Future<void> fastForward() async {
// updateMediaItem(mediaItem.value?.copyWith(extras: {'liked':'true'})??const MediaItem(id: 'id', title: 'title'));
HomeController.to.likeSong(liked: true);
Home.to.likeSong(liked: true);
}

//更改为喜欢按钮
@override
Future<void> rewind() async {
HomeController.to.likeSong(liked: false);
Home.to.likeSong(liked: false);
}

@override
Future<void> changeQueueLists(List<MediaItem> list, {int index = 0, bool init = false}) async {
if (!init && HomeController.to.fm.value) {
HomeController.to.fm.value = false;
if (!init && Home.to.fm.value) {
Home.to.fm.value = false;
StorageUtil().setBool(fmSp, false);
}
_playList
Expand Down Expand Up @@ -270,30 +270,47 @@ class BujuanAudioHandler extends BaseAudioHandler with SeekHandler, QueueHandler

@override
Future<void> readySongUrl({bool isNext = true, bool playIt = true}) async {
bool high = !playIt ? StorageUtil().getBool(highSong) : HomeController.to.high.value;
bool high = !playIt ? StorageUtil().getBool(highSong) : Home.to.high.value;
bool cache = !playIt ? StorageUtil().getBool(cacheSp) : Home.to.cache.value;
// 这里是获取歌曲url
if (queue.value.isEmpty) return;
var song = queue.value[_curIndex];
//根据缓存地址获取
String? url = DownloadCacheManager.getCachedFilePath(song.id);
//如果是本地音乐,直接取地址
if (song.extras?['type'] == MediaType.local.name) url = song.extras?['url'];
if (url != null) {
// print('缓存过了=========$url');
mediaItem.add(song);
//缓存过的或者是本地音乐
playIt ? await _player.play(DeviceFileSource(url), mode: PlayerMode.mediaPlayer) : await _player.setSourceDeviceFile(url);
String? url;
if (cache && !PlatformUtils.isIOS) {
//根据缓存地址获取
url = DownloadCacheManager.getCachedFilePath(song.id);
//如果是本地音乐,直接取地址
if (song.extras?['type'] == MediaType.local.name) url = song.extras?['url'];
if (url != null) {
print('缓存过了=========$url');
mediaItem.add(song);
//缓存过的或者是本地音乐
playIt ? await _player.play(DeviceFileSource(url), mode: PlayerMode.mediaPlayer) : await _player.setSourceDeviceFile(url);
} else {
// 未缓存过
// 获取URL
SongUrlListWrap songUrl = await NeteaseMusicApi().songDownloadUrl([song.id], level: high ? 'lossless' : 'exhigh');
url = ((songUrl.data ?? [])[0].url ?? '').split('?')[0];
if (url.isNotEmpty) {
mediaItem.add(song);
playIt ? await _player.play(UrlSource(url), mode: PlayerMode.mediaPlayer) : await _player.setSourceUrl(url);
Downloader.downloadFile(url, song.id, onProgress: (int progress, int total) {
// print('object==============$progress======$total');
});
} else {
if (isNext) {
await skipToNext();
} else {
await skipToPrevious();
}
}
}
} else {
// 未缓存过
// 获取URL
SongUrlListWrap songUrl = await NeteaseMusicApi().songDownloadUrl([song.id], level: high ? 'lossless' : 'exhigh');
url = ((songUrl.data ?? [])[0].url ?? '').split('?')[0];
if (url.isNotEmpty) {
mediaItem.add(song);
playIt ? await _player.play(UrlSource(url), mode: PlayerMode.mediaPlayer) : await _player.setSourceUrl(url);
Downloader.downloadFile(url, song.id, onProgress: (int progress, int total) {
// print('object==============$progress======$total');
});
} else {
if (isNext) {
await skipToNext();
Expand All @@ -304,9 +321,7 @@ class BujuanAudioHandler extends BaseAudioHandler with SeekHandler, QueueHandler
}
}

downloadUrl( url){

}
downloadUrl(url) {}

@override
Future<void> pause() async => await _player.pause();
Expand All @@ -323,11 +338,11 @@ class BujuanAudioHandler extends BaseAudioHandler with SeekHandler, QueueHandler
Future<void> skipToNext() async {
_setCurrIndex(next: true);
await readySongUrl();
if (HomeController.to.fm.value) {
if (Home.to.fm.value) {
// 如果是私人fm
if (_curIndex == queue.value.length - 1) {
// 判断如果是最后一首
HomeController.to.getFmSongList();
Home.to.getFmSongList();
}
}
}
Expand Down
4 changes: 3 additions & 1 deletion lib/common/constants/key.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ String topLyricSp = 'TOP_LYRIC';
String highSong = 'HIGH_SONG';
String fmSp = 'FM_SP';
String noFirstOpen = 'NO_FIRST_OPEN';
String loginData = 'LOGIN_DATA';
String loginData = 'LOGIN_DATA';
String backgroundSp = 'BACKGROUND';
String cacheSp = 'CACHE';
3 changes: 3 additions & 0 deletions lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import 'package:bujuan/pages/user/user_controller.dart';
import 'package:bujuan/routes/router.gr.dart';
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:flutter_displaymode/flutter_displaymode.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:flutter_zoom_drawer/config.dart';
import 'package:get/get.dart';
Expand All @@ -26,11 +27,13 @@ main() async {
bool isMobile = PlatformUtils.isAndroid || PlatformUtils.isIOS || PlatformUtils.isFuchsia || PlatformUtils.isWeb;
WidgetsFlutterBinding.ensureInitialized();
await DownloadCacheManager.init();
await FlutterDisplayMode.setHighRefreshRate();
await DownloadCacheManager.setExpireDate(daysToExpire: 100);
final getIt = GetIt.instance;
await _initAudioServer(getIt);
final rootRouter = getIt<RootRouter>();
HomeBinding().dependencies();
// debugProfileBuildsEnabled = true;
runApp(OrientationBuilder(builder: (context, orientation) {
return ScreenUtilInit(
rebuildFactor: RebuildFactors.orientation,
Expand Down
9 changes: 4 additions & 5 deletions lib/pages/artists/artists_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import 'package:flutter_tabler_icons/flutter_tabler_icons.dart';
import '../../common/constants/other.dart';
import '../../common/netease_api/src/dio_ext.dart';
import '../../common/netease_api/src/netease_handler.dart';
import '../../routes/router.gr.dart';
import '../../widget/app_bar.dart';

class ArtistsView extends StatefulWidget {
Expand Down Expand Up @@ -46,7 +45,7 @@ class _ArtistsViewState extends State<ArtistsView> {
childBuilder: (artistDetails) {
_items
..clear()
..addAll(HomeController.to.song2ToMedia(artistDetails.hotSongs ?? []));
..addAll(Home.to.song2ToMedia(artistDetails.hotSongs ?? []));
return Scaffold(
backgroundColor: Colors.transparent,
appBar: MyAppBar(
Expand Down Expand Up @@ -151,8 +150,8 @@ class _ArtistsViewState extends State<ArtistsView> {
actions: [const SheetAction<String>(label: '下一首播放', icon: TablerIcons.player_play, key: 'next')],
).then((value) {
if (value != null) {
if (HomeController.to.audioServeHandler.playbackState.value.queueIndex != 0) {
HomeController.to.audioServeHandler.insertQueueItem(HomeController.to.audioServeHandler.playbackState.value.queueIndex! + 1, data);
if (Home.to.audioServeHandler.playbackState.value.queueIndex != 0) {
Home.to.audioServeHandler.insertQueueItem(Home.to.audioServeHandler.playbackState.value.queueIndex! + 1, data);
WidgetUtil.showToast('已添加到下一曲');
} else {
WidgetUtil.showToast('未知错误');
Expand All @@ -167,7 +166,7 @@ class _ArtistsViewState extends State<ArtistsView> {
],
),
),
onTap: () => HomeController.to.playByIndex(index, artists?.id ?? '-1', mediaItem: _items),
onTap: () => Home.to.playByIndex(index, artists?.id ?? '-1', mediaItem: _items),
);
}
}
19 changes: 5 additions & 14 deletions lib/pages/guide/guide_view.dart
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ import 'package:bujuan/common/storage.dart';
import 'package:bujuan/routes/router.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:get_it/get_it.dart';
import 'package:lottie/lottie.dart';
import 'package:notification_permissions/notification_permissions.dart';
import 'dart:math' as math;

import '../../common/bujuan_audio_handler.dart';

class GuideView extends StatefulWidget {
const GuideView({Key? key}) : super(key: key);
Expand Down Expand Up @@ -42,18 +40,12 @@ class _GuideViewState extends State<GuideView> with WidgetsBindingObserver {
});
});
_bottomData = [
BottomData('是否开启全局动效', '请观看上方图片示例', onCancel: () {
_jumpToPage(2);
StorageUtil().setBool(leftImageSp, false);
}, onOk: () {
_jumpToPage(2);
StorageUtil().setBool(leftImageSp, true);
}),
BottomData('title', 'subTitle'),
BottomData('是否开启播放页渐变', '请观看上方图片示例', onCancel: () {
_jumpToPage(3);
_jumpToPage(2);
StorageUtil().setBool(gradientBackgroundSp, false);
}, onOk: () {
_jumpToPage(3);
_jumpToPage(2);
StorageUtil().setBool(gradientBackgroundSp, true);
}),
BottomData('为了更好的为您服务', '请授予通知权限', onCancel: () {
Expand Down Expand Up @@ -99,7 +91,6 @@ class _GuideViewState extends State<GuideView> with WidgetsBindingObserver {
@override
Widget build(BuildContext context) {
return Scaffold(
backgroundColor: Colors.transparent,
body: Stack(
alignment: Alignment.topRight,
children: [
Expand All @@ -108,7 +99,7 @@ class _GuideViewState extends State<GuideView> with WidgetsBindingObserver {
physics: const NeverScrollableScrollPhysics(),
children: [
_buildWelcome(),
_buildLeftImage(context),
// _buildLeftImage(context),
_buildSolidBackground(context),
_buildNotification(),
],
Expand All @@ -119,7 +110,7 @@ class _GuideViewState extends State<GuideView> with WidgetsBindingObserver {
child: IconButton(
onPressed: () {
AutoRouter.of(context).replaceNamed(Routes.home);
StorageUtil().setBool(leftImageSp, true);
StorageUtil().setBool(leftImageSp, false);
StorageUtil().setBool(gradientBackgroundSp, true);
},
icon: Text(
Expand Down
43 changes: 0 additions & 43 deletions lib/pages/home/home.dart

This file was deleted.

2 changes: 1 addition & 1 deletion lib/pages/home/home_binding.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class HomeBinding extends Bindings{
@override
void dependencies() {
// Get.lazyPut(() => UserController());
Get.lazyPut(() => HomeController());
Get.lazyPut(() => Home());
// Get.lazyPut<IndexController>(() => IndexController());
// Get.lazyPut(() => PlayListController());
// Get.lazyPut(() => LoginController());
Expand Down
Loading

0 comments on commit caeba1b

Please sign in to comment.