Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
canxin121 committed May 15, 2024
2 parents 900eec0 + 1ab41f3 commit 41083b5
Show file tree
Hide file tree
Showing 19 changed files with 526 additions and 434 deletions.
Binary file added assets/blank.mp3
Binary file not shown.
Binary file removed assets/nature.mp3
Binary file not shown.
7 changes: 4 additions & 3 deletions lib/comp/play_page_comp/lyric.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class LyricDisplayState extends State<LyricDisplay> {
var lyricModel =
LyricsModelBuilder.create().bindLyricToMain("[00:00.00]无歌词").getModel();
var lyricUI = UINetease(lyricAlign: LyricAlign.CENTER, highlight: true);
late StreamSubscription<PlayMusic?> stream;
late StreamSubscription<Music?> stream;
@override
void initState() {
super.initState();
Expand Down Expand Up @@ -70,7 +70,7 @@ class LyricDisplayState extends State<LyricDisplay> {
globalAudioHandler.seek(toSeek).then((value) {
confirm.call();
// 这里是考虑到在暂停状态下。需要开启播放
if (!globalAudioHandler.isPlaying()) {
if (!globalAudioHandler.isPlaying) {
globalAudioHandler.play();
}
});
Expand All @@ -87,7 +87,8 @@ class LyricDisplayState extends State<LyricDisplay> {
),
Text(
formatDuration(Duration(milliseconds: progress).inSeconds),
style: const TextStyle(color: CupertinoColors.white).useSystemChineseFont(),
style: const TextStyle(color: CupertinoColors.white)
.useSystemChineseFont(),
)
],
);
Expand Down
22 changes: 9 additions & 13 deletions lib/comp/play_page_comp/music_list.dart
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:pull_down_button/pull_down_button.dart';

// PlayMusicList组件
class PlayMusicList extends StatelessWidget {
// MusicList组件
class MusicListComp extends StatelessWidget {
final double maxHeight;
final EdgeInsets picPadding;
final double itemHeight;
const PlayMusicList(
const MusicListComp(
{super.key,
required this.maxHeight,
required this.picPadding,
Expand All @@ -29,7 +29,7 @@ class PlayMusicList extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Obx(() {
var musics = globalAudioHandler.playMusicList;
var musics = globalAudioHandler.musicList;

return Container(
constraints: BoxConstraints(maxHeight: maxHeight),
Expand Down Expand Up @@ -77,7 +77,7 @@ class PlayMusicList extends StatelessWidget {
// 播放展示界面的列表中的音乐卡片的长按触发操作
List<PullDownMenuEntry> displayListMusicCardPullDown(
BuildContext context,
PlayMusic music,
Music music,
Future<void> Function() onDelete,
Rect position,
) =>
Expand Down Expand Up @@ -143,11 +143,8 @@ List<PullDownMenuEntry> displayListMusicCardPullDown(
if (context.mounted) {
await showPullDownMenu(
context: context,
items: addToMusicListPullDown(
context,
musicLists,
Future.value([DisplayMusic(music.ref, info_: music.info)]),
position),
items: addToMusicListPullDown(context, musicLists,
Future.value([Music(music.ref)]), position),
position: position);
}
},
Expand Down Expand Up @@ -181,9 +178,8 @@ List<PullDownMenuEntry> displayListMusicCardPullDown(
),
PullDownMenuItem(
onTap: () async {
globalTopUiController.updateWidget(InMusicAlbumListPage(
key: UniqueKey(),
music: DisplayMusic(music.ref, info_: music.info)));
globalTopUiController.updateWidget(
InMusicAlbumListPage(key: UniqueKey(), music: Music(music.ref)));
},
title: "查看专辑",
icon: CupertinoIcons.music_albums,
Expand Down
13 changes: 2 additions & 11 deletions lib/comp/play_page_comp/quality_time.dart
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import 'dart:io';

import 'package:app_rhyme/src/rust/api/mirror.dart';
import 'package:app_rhyme/types/music.dart';
import 'package:app_rhyme/util/helper.dart';
import 'package:app_rhyme/util/audio_controller.dart';
import 'package:app_rhyme/util/time_parse.dart';
Expand Down Expand Up @@ -49,16 +48,8 @@ class QualityTimeState extends State<QualityTime> {
context: context,
items: qualitySelectPullDown(context, qualityOptions,
(selectQuality) async {
var playingMusic = globalAudioHandler.playingMusic.value;
if (playingMusic != null) {
var displayData = DisplayMusic(playingMusic.ref,
info_: playingMusic.info);
var newPlayMusic =
await display2PlayMusic(displayData, selectQuality);
if (newPlayMusic == null) return;
await globalAudioHandler
.replacePlayingMusic(newPlayMusic);
}
await globalAudioHandler
.replacePlayingMusic(selectQuality);
}),
position: details.globalPosition & Size.zero);
}
Expand Down
20 changes: 10 additions & 10 deletions lib/page/in_music_album.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import 'package:pull_down_button/pull_down_button.dart';
import 'package:toastification/toastification.dart';

class InMusicAlbumListPage extends StatefulWidget {
final DisplayMusic music;
final Music music;
const InMusicAlbumListPage({
super.key,
required this.music,
Expand All @@ -35,7 +35,7 @@ class InMusicAlbumListPage extends StatefulWidget {
class InMusicAlbumListPageState extends State<InMusicAlbumListPage> {
MusicList musicList = const MusicList(name: "Album", artPic: "", desc: "");
var allowEmptyTime = 3;
var pagingController = PagingController<int, DisplayMusic>(firstPageKey: 1);
var pagingController = PagingController<int, Music>(firstPageKey: 1);

@override
void initState() {
Expand Down Expand Up @@ -64,13 +64,13 @@ class InMusicAlbumListPageState extends State<InMusicAlbumListPage> {
musicList = musicList_;
});
}
var newMusics = newMusicsRefs.map((e) => DisplayMusic(e));
List<DisplayMusic> uniqueItems = [];
var newMusics = newMusicsRefs.map((e) => Music(e));
List<Music> uniqueItems = [];

if (pagingController.value.itemList != null) {
for (var newMusic in newMusics) {
bool exist = false;
for (DisplayMusic existItem in pagingController.value.itemList!) {
for (Music existItem in pagingController.value.itemList!) {
if (existItem.info.name == newMusic.info.name &&
existItem.info.artist.join(",") ==
newMusic.info.artist.join(",")) {
Expand Down Expand Up @@ -198,15 +198,15 @@ class InMusicAlbumListPageState extends State<InMusicAlbumListPage> {
music: displayMusic,
onClick: () {
globalAudioHandler.addMusicPlay(
displayMusic as DisplayMusic,
displayMusic as Music,
);
},
onPress: (details) async {
var position = details.globalPosition & Size.zero;
await showPullDownMenu(
context: context,
items: inMusicAlbumMusicCardPullDown(
context, displayMusic as DisplayMusic, position),
context, displayMusic as Music, position),
position: position);
},
),
Expand Down Expand Up @@ -253,7 +253,7 @@ Widget _buildButton(BuildContext context,
// 专辑界面的音乐卡片的长按触发操作
List<PullDownMenuEntry> inMusicAlbumMusicCardPullDown(
BuildContext context,
DisplayMusic music,
Music music,
Rect position,
) =>
[
Expand Down Expand Up @@ -349,7 +349,7 @@ List<PullDownMenuEntry> musicAlbumActionPullDown(
BuildContext context,
Future<void> Function() fetchAllMusic,
MusicList musiclist,
PagingController<int, DisplayMusic> pagingController,
PagingController<int, Music> pagingController,
Rect position,
) =>
[
Expand Down Expand Up @@ -448,7 +448,7 @@ List<PullDownMenuEntry> musicAlbumActionPullDown(
if (pagingController.itemList != null) {
return pagingController.itemList!;
}
}(), // 这里传递Future<List<DisplayMusic>>
}(), // 这里传递Future<List<Music>>
position),
position: position);
}
Expand Down
Loading

0 comments on commit 41083b5

Please sign in to comment.