Skip to content

Commit

Permalink
Fix storage,macos release
Browse files Browse the repository at this point in the history
  • Loading branch information
HeHang0 committed Mar 23, 2024
1 parent cae2cb8 commit 6048e94
Show file tree
Hide file tree
Showing 27 changed files with 193 additions and 74 deletions.
6 changes: 6 additions & 0 deletions mobile/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ PODS:
- flutter_inappwebview_ios/Core (0.0.1):
- Flutter
- OrderedSet (~> 5.0)
- flutter_volume_controller (0.0.1):
- Flutter
- just_audio (0.0.1):
- Flutter
- OrderedSet (5.0.0)
Expand Down Expand Up @@ -75,6 +77,7 @@ DEPENDENCIES:
- file_picker (from `.symlinks/plugins/file_picker/ios`)
- Flutter (from `Flutter`)
- flutter_inappwebview_ios (from `.symlinks/plugins/flutter_inappwebview_ios/ios`)
- flutter_volume_controller (from `.symlinks/plugins/flutter_volume_controller/ios`)
- just_audio (from `.symlinks/plugins/just_audio/ios`)
- path_provider_foundation (from `.symlinks/plugins/path_provider_foundation/darwin`)
- permission_handler_apple (from `.symlinks/plugins/permission_handler_apple/ios`)
Expand Down Expand Up @@ -103,6 +106,8 @@ EXTERNAL SOURCES:
:path: Flutter
flutter_inappwebview_ios:
:path: ".symlinks/plugins/flutter_inappwebview_ios/ios"
flutter_volume_controller:
:path: ".symlinks/plugins/flutter_volume_controller/ios"
just_audio:
:path: ".symlinks/plugins/just_audio/ios"
path_provider_foundation:
Expand All @@ -125,6 +130,7 @@ SPEC CHECKSUMS:
file_picker: 15fd9539e4eb735dc54bae8c0534a7a9511a03de
Flutter: e0871f40cf51350855a761d2e70bf5af5b9b5de7
flutter_inappwebview_ios: 97215cf7d4677db55df76782dbd2930c5e1c1ea0
flutter_volume_controller: e4d5832f08008180f76e30faf671ffd5a425e529
just_audio: baa7252489dbcf47a4c7cc9ca663e9661c99aafa
OrderedSet: aaeb196f7fef5a9edf55d89760da9176ad40b93c
path_provider_foundation: 3784922295ac71e43754bd15e0653ccfd36a147c
Expand Down
18 changes: 18 additions & 0 deletions mobile/ios/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
331C808B294A63AB00263BE5 /* RunnerTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 331C807B294A618700263BE5 /* RunnerTests.swift */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
47EEE4822BADA9AA0008BBF8 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 47EEE4802BADA9AA0008BBF8 /* InfoPlist.strings */; };
74858FAF1ED2DC5600515810 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 74858FAE1ED2DC5600515810 /* AppDelegate.swift */; };
76787DA4A10A6B79195385B6 /* Pods_RunnerTests.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8E39293DAE4FA2293CCC1453 /* Pods_RunnerTests.framework */; };
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
Expand Down Expand Up @@ -48,6 +49,8 @@
331C807B294A618700263BE5 /* RunnerTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RunnerTests.swift; sourceTree = "<group>"; };
331C8081294A63A400263BE5 /* RunnerTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
47EEE4812BADA9AA0008BBF8 /* en */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = en; path = en.lproj/InfoPlist.strings; sourceTree = "<group>"; };
47EEE4832BADA9CE0008BBF8 /* zh-Hans */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = "zh-Hans"; path = "zh-Hans.lproj/InfoPlist.strings"; sourceTree = "<group>"; };
74858FAD1ED2DC5600515810 /* Runner-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "Runner-Bridging-Header.h"; sourceTree = "<group>"; };
74858FAE1ED2DC5600515810 /* AppDelegate.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = "<group>"; };
7AFA3C8E1D35360C0083082E /* Release.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; name = Release.xcconfig; path = Flutter/Release.xcconfig; sourceTree = "<group>"; };
Expand Down Expand Up @@ -118,6 +121,7 @@
97C146E51CF9000F007C117D = {
isa = PBXGroup;
children = (
47EEE4802BADA9AA0008BBF8 /* InfoPlist.strings */,
9740EEB11CF90186004384FC /* Flutter */,
97C146F01CF9000F007C117D /* Runner */,
97C146EF1CF9000F007C117D /* Products */,
Expand Down Expand Up @@ -236,6 +240,7 @@
knownRegions = (
en,
Base,
"zh-Hans",
);
mainGroup = 97C146E51CF9000F007C117D;
productRefGroup = 97C146EF1CF9000F007C117D /* Products */;
Expand Down Expand Up @@ -264,6 +269,7 @@
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
47EEE4822BADA9AA0008BBF8 /* InfoPlist.strings in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -410,6 +416,15 @@
/* End PBXTargetDependency section */

/* Begin PBXVariantGroup section */
47EEE4802BADA9AA0008BBF8 /* InfoPlist.strings */ = {
isa = PBXVariantGroup;
children = (
47EEE4812BADA9AA0008BBF8 /* en */,
47EEE4832BADA9CE0008BBF8 /* zh-Hans */,
);
name = InfoPlist.strings;
sourceTree = "<group>";
};
97C146FA1CF9000F007C117D /* Main.storyboard */ = {
isa = PBXVariantGroup;
children = (
Expand All @@ -433,6 +448,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
Expand Down Expand Up @@ -555,6 +571,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
Expand Down Expand Up @@ -610,6 +627,7 @@
isa = XCBuildConfiguration;
buildSettings = {
ALWAYS_SEARCH_USER_PATHS = NO;
CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES;
CLANG_ANALYZER_NONNULL = YES;
CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
CLANG_CXX_LIBRARY = "libc++";
Expand Down
20 changes: 10 additions & 10 deletions mobile/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@
<key>CFBundleDevelopmentRegion</key>
<string>$(DEVELOPMENT_LANGUAGE)</string>
<key>CFBundleDisplayName</key>
<string>Musiche</string>
<string>$(PRODUCT_NAME)</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>musiche</string>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
Expand Down Expand Up @@ -46,13 +46,13 @@
<key>UIApplicationSupportsIndirectInputEvents</key>
<true/>
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
</array>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
<key>UIBackgroundModes</key>
<array>
<string>audio</string>
</array>
</dict>
</plist>
9 changes: 9 additions & 0 deletions mobile/ios/en.lproj/InfoPlist.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
InfoPlist.strings
Runner

Created by 何航 on 2024/3/22.

*/
"CFBundleName" = "Musiche";
"CFBundleDisplayName" = "Musiche";
9 changes: 9 additions & 0 deletions mobile/ios/zh-Hans.lproj/InfoPlist.strings
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
/*
InfoPlist.strings
Runner

Created by 何航 on 2024/3/22.

*/
"CFBundleName" = "音乐和";
"CFBundleDisplayName" = "音乐和";
10 changes: 8 additions & 2 deletions mobile/lib/audio/audio_play.dart
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class AudioPlay extends BaseAudioHandler {
Stream<Duration?> get onDurationChanged => _audioPlayer.durationStream;
Stream<Duration> get onPositionChanged => _audioPlayer.positionStream;
bool get playing => _audioPlayer.playing;
bool get stopped => _audioPlayer.playerState.processingState == ProcessingState.completed || _audioPlayer.playerState.processingState == ProcessingState.idle;
bool get stopped => false;//_audioPlayer.playerState.processingState == ProcessingState.completed || _audioPlayer.playerState.processingState == ProcessingState.idle;
int get volume => _volume;
Future<Duration?> Function() get currentPosition => () => Future(() => _audioPlayer.position);
Future<Duration?> Function() get duration => () => Future(() => _audioPlayer.duration);
Expand Down Expand Up @@ -223,7 +223,13 @@ class AudioPlay extends BaseAudioHandler {
}
}
void playCurrent(){
_audioPlayer.play();
if((_audioPlayer.playerState.processingState == ProcessingState.completed ||
_audioPlayer.playerState.processingState == ProcessingState.idle) &&
_musicPlayRequest != null && _musicPlayRequest?.music != null){
playMusic(_musicPlayRequest?.music);
}else {
_audioPlayer.play();
}
}

void setPosition(int milliseconds) {
Expand Down
4 changes: 2 additions & 2 deletions mobile/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ import 'package:window_manager/window_manager.dart';

Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await windowManager.ensureInitialized();
await ServerManager.startServer();
if(Platform.isMacOS) {
MacOSChannel.open("http://127.0.0.1:${ServerManager.port}/index.html");
await windowManager.ensureInitialized();
MacOSChannel.open("http://127.0.0.1:${kDebugMode ? 5173 : ServerManager.port}");
MacOSChannel.listen();
}
runApp(const MyApp());
Expand Down
17 changes: 10 additions & 7 deletions mobile/lib/server/http_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import 'package:musiche/server/handler_interface.dart';
import 'package:musiche/server/proxy_request_data.dart';
import 'package:musiche/server/proxy_response_data.dart';
import 'package:musiche/utils/android_channel.dart';
import 'package:musiche/utils/webview_macos.dart';
import 'package:permission_handler/permission_handler.dart';
import 'package:shared_preferences/shared_preferences.dart';

Expand Down Expand Up @@ -90,7 +91,7 @@ class HttpHandler extends Handler implements IHandler {
Map<String, dynamic> result = <String, dynamic>{};
result["remote"] = true;
result["storage"] = true;
result["file"] = true;
result["file"] = !Platform.isIOS;
result["list"] = true;
result["client"] = false;
result["lyric"] = Platform.isAndroid;
Expand Down Expand Up @@ -179,7 +180,8 @@ class HttpHandler extends Handler implements IHandler {
result = sharedPreferences?.getString(key) ?? "";
break;
case "POST":
sharedPreferences?.setString(key, await _readBody(request));
String text = await _readBody(request);
sharedPreferences?.setString(key, text);
break;
case "DELETE":
sharedPreferences?.remove(key);
Expand Down Expand Up @@ -264,14 +266,10 @@ class HttpHandler extends Handler implements IHandler {
request.response.statusCode = HttpStatus.ok;
String themeString = request.uri.queryParameters["theme"] ?? "";
Brightness brightness = themeString == "1" ? Brightness.dark : Brightness.light;
if(Platform.isIOS) brightness = themeString == "1" ? Brightness.light : Brightness.dark;
if(Platform.isIOS || Platform.isMacOS) brightness = themeString == "1" ? Brightness.light : Brightness.dark;
if (kIsWeb) {
return;
}
if(Platform.isMacOS){

return;
}
var androidInfo = await OSVersion.androidInfo;
var sdkInt = androidInfo?.version.sdkInt ?? 0;
if(!Platform.isAndroid || (sdkInt >= 23 && sdkInt < 34)){
Expand All @@ -285,6 +283,11 @@ class HttpHandler extends Handler implements IHandler {
systemNavigationBarIconBrightness: brightness,
systemNavigationBarDividerColor: Colors.transparent,
));
final saved = (request.uri.queryParameters["saved"] ?? "0") == "1";
if(Platform.isMacOS && saved){
final auto = (request.uri.queryParameters["auto"] ?? "0") == "1";
MacOSChannel.theme(themeString != "1", auto);
}
}else {
if(Platform.isAndroid) AndroidChannel.setStatusBarTheme(themeString != "1");
}
Expand Down
9 changes: 7 additions & 2 deletions mobile/lib/server/server_manager.dart
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,21 @@ class ServerManager {
AudioPlay audioPlay = AudioPlay();
SharedPreferences? sharedPreferences;
try{
SharedPreferences.setPrefix("musiche");
sharedPreferences = await SharedPreferences.getInstance();
}catch(e){
Logger.e(_tag, "init shared preferences error", error: e);
}
HttpHandler httpHandler = HttpHandler(audioPlay, sharedPreferences);
_websocketHandler = WebSocketHandler(audioPlay);
_port = kDebugMode ? 54621 : await Network.findAvailablePort();
InternetAddress address = kDebugMode ? InternetAddress.anyIPv4 : InternetAddress.loopbackIPv4;
_server = await HttpServer.bind(address, _port, shared: Platform.isMacOS);
InternetAddress address = kDebugMode ? InternetAddress.anyIPv4 : InternetAddress('127.0.0.1');
Logger.i(_tag, "start server: $address:$_port");
try{
_server = await HttpServer.bind(address, _port, shared: Platform.isMacOS);
}catch(e){
Logger.e(_tag, "start server error", error: e);
}
_server?.forEach((HttpRequest request) {
Logger.d(_tag, "accept connection: ${request.uri.path}");
Network.processCors(request.response);
Expand Down
3 changes: 1 addition & 2 deletions mobile/lib/server/websocket_handler.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import 'package:flutter/services.dart';
import 'package:just_audio/just_audio.dart';
import 'package:musiche/audio/audio_play.dart';
import 'package:musiche/audio/music_item.dart';
import 'package:musiche/utils/webview_macos.dart';
import 'package:tray_manager/tray_manager.dart';
import 'package:window_manager/window_manager.dart';

Expand Down Expand Up @@ -169,7 +168,7 @@ class WebSocketHandler extends Handler with TrayListener, WindowListener impleme
}

_onPlayerStateChanged(PlayerState state) async {
_setNotifyContextMenu();
if(Platform.isMacOS) _setNotifyContextMenu();
await _sendStatus();
}

Expand Down
3 changes: 2 additions & 1 deletion mobile/lib/webview.dart
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ class _WebViewAppState extends State<WebViewApp> with WidgetsBindingObserver {
InAppWebViewSettings settings = InAppWebViewSettings(
isInspectable: kDebugMode,
mediaPlaybackRequiresUserGesture: false,
allowsPictureInPictureMediaPlayback:false,
allowsPictureInPictureMediaPlayback:true,
allowsInlineMediaPlayback: true,
transparentBackground: true,
allowBackgroundAudioPlaying: false,
disableContextMenu: true,
Expand Down
Loading

0 comments on commit 6048e94

Please sign in to comment.