-
-
Notifications
You must be signed in to change notification settings - Fork 139
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
(only when youtube-style miniplayer disabled)
- Loading branch information
Showing
11 changed files
with
322 additions
and
177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
lib/controller/lyrics_search_utils/lrc_search_details.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
class LRCSearchDetails { | ||
final String title, artist, album; | ||
final int durationSeconds; | ||
|
||
const LRCSearchDetails({ | ||
required this.title, | ||
required this.artist, | ||
required this.album, | ||
required this.durationSeconds, | ||
}); | ||
} |
46 changes: 46 additions & 0 deletions
46
lib/controller/lyrics_search_utils/lrc_search_utils_base.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import 'dart:io'; | ||
|
||
import 'package:flutter/foundation.dart'; | ||
|
||
import 'package:namida/class/track.dart'; | ||
import 'package:namida/controller/lyrics_search_utils/lrc_search_details.dart'; | ||
import 'package:namida/controller/lyrics_search_utils/lrc_search_utils_selectable.dart'; | ||
import 'package:namida/controller/lyrics_search_utils/lrc_search_utils_youtubeid.dart'; | ||
import 'package:namida/youtube/class/youtube_id.dart'; | ||
import 'package:namida/youtube/controller/youtube_controller.dart'; | ||
|
||
abstract class LrcSearchUtils { | ||
const LrcSearchUtils(); | ||
|
||
static LrcSearchUtils? fromPlayable(Playable item) { | ||
if (item is Selectable) { | ||
final tr = item.track; | ||
return LrcSearchUtilsSelectable(tr.toTrackExt(), tr); | ||
} else if (item is YoutubeID) { | ||
final videoInfo = YoutubeController.inst.getVideoInfo(item.id, checkFromStorage: true); | ||
return LrcSearchUtilsYoutubeID(item, videoInfo?.name); | ||
} | ||
return null; | ||
} | ||
|
||
String get initialSearchTextHint; | ||
String? get pickFileInitialDirectory; | ||
String get embeddedLyrics; | ||
File get cachedTxtFile; | ||
File get cachedLRCFile; | ||
List<File> get deviceLRCFiles; | ||
|
||
Future<void> saveLyricsToCache(String formatted, bool isSynced) async { | ||
final fc = isSynced ? cachedLRCFile : cachedTxtFile; | ||
await fc.create(); | ||
await fc.writeAsString(formatted); | ||
} | ||
|
||
@mustCallSuper | ||
bool hasLyrics() { | ||
return cachedLRCFile.existsSync() || deviceLRCFiles.any((element) => element.existsSync()) || cachedTxtFile.existsSync(); | ||
} | ||
|
||
List<LRCSearchDetails> searchDetailsQueries(); | ||
List<String> searchQueriesGoogle(); | ||
} |
Oops, something went wrong.