Skip to content

Commit

Permalink
[Fix] fix github action 'BUILD'. Fix Can't pause.
Browse files Browse the repository at this point in the history
  • Loading branch information
canxin121 committed May 1, 2024
1 parent e144523 commit 7b761ea
Show file tree
Hide file tree
Showing 14 changed files with 195 additions and 762 deletions.
101 changes: 57 additions & 44 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,16 @@ jobs:
zip -r -y Payload.zip Payload/Runner.app
mv Payload.zip AppRhyme.ipa
- name: Flutter build macos
run: flutter build macos --release --verbose

- name: Upload IPA
uses: actions/upload-artifact@v4
with:
name: AppRhyme.ipa
path: AppRhyme.ipa
compression-level: 9

- name: Flutter build macos
run: flutter build macos --release --verbose

- name: Upload Macos app
uses: actions/upload-artifact@v4
with:
Expand All @@ -55,44 +55,36 @@ jobs:
run: tree build/macos/Build/Products/

- name: Package Executable
run: zip -r "build/app/AppRhyme-macos-release-unknown.zip" "build/macos/Build/Products/Release/AppRhyme.app"
run:
mkdir -p build/app/
zip -r "build/app/AppRhyme-macos-release-unknown.zip" "build/macos/Build/Products/Release/AppRhyme.app"

build_on_linux:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: 17

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3

- uses: subosito/flutter-action@v2
with:
channel: "beta"

- name: Install Flutter Dependency
run: flutter pub get

- name: Install Rust
uses: dtolnay/rust-toolchain@stable


- name: Install Linux dependency
run: |
sudo apt-get update -y
sudo apt install libwebkit2gtk-4.1-dev
sudo apt-get install -y ninja-build libgtk-3-dev
sudo apt-get install libasound2-dev
- name: Flutter build linux
run: flutter build linux --release --verbose

- name: Flutter build apk
run: flutter build apk --release --split-per-abi --verbose

- name: Package Executable
run: 7z a -r "../../../../../build/app/AppRhyme-linux-release-amd64.zip" *
working-directory: build/linux/x64/release/bundle
Expand All @@ -103,33 +95,6 @@ jobs:
name: AppRhyme-linux-release-amd64
path: build/app/AppRhyme-linux-release-amd64.zip

- name: Upload APK1
uses: actions/upload-artifact@v4
with:
name: AppRhyme-arm64-v8a-release.apk
path: build/app/outputs/apk/release/app-arm64-v8a-release.apk
compression-level: 9

- name: Upload APK2
uses: actions/upload-artifact@v4
with:
name: AppRhyme-armeabi-v7a-release.apk
path: build/app/outputs/apk/release/app-armeabi-v7a-release.apk
compression-level: 9

- name: Upload APK3
uses: actions/upload-artifact@v4
with:
name: AppRhyme-x86_64-release.apk
path: build/app/outputs/apk/release/app-x86_64-release.apk
compression-level: 9

- name: Rename APKs
run: |
mv build/app/outputs/apk/release/app-arm64-v8a-release.apk build/app/outputs/apk/release/AppRhyme-arm64-v8a-release.apk
mv build/app/outputs/apk/release/app-armeabi-v7a-release.apk build/app/outputs/apk/release/AppRhyme-armeabi-v7a-release.apk
mv build/app/outputs/apk/release/app-x86_64-release.apk build/app/outputs/apk/release/AppRhyme-x86_64-release.apk
build_on_windows:
runs-on: windows-latest
steps:
Expand All @@ -139,12 +104,30 @@ jobs:
with:
channel: "beta"

- name: Setup Java
uses: actions/setup-java@v4
with:
distribution: "temurin"
java-version: 17

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3

- name: Install Flutter Dependency
run: flutter pub get

- name: Install Rust
uses: dtolnay/rust-toolchain@stable

- name: Install Cargo-Ndk
run: cargo install cargo-ndk --version 2.11.0 --force

- name: Install android ndk
uses: nttld/setup-ndk@v1
id: install-ndk
with:
ndk-version: r22b

- name: Flutter build windows
run: flutter build windows --release --verbose

Expand All @@ -157,3 +140,33 @@ jobs:
with:
name: AppRhyme-release-amd64
path: build/app/AppRhyme-release-amd64.zip

- name: Flutter build apk
run: flutter build apk --release --split-per-abi --verbose

- name: Upload APK1
uses: actions/upload-artifact@v4
with:
name: AppRhyme-arm64-v8a-release.apk
path: build/app/outputs/apk/release/app-arm64-v8a-release.apk
compression-level: 9

- name: Upload APK2
uses: actions/upload-artifact@v4
with:
name: AppRhyme-armeabi-v7a-release.apk
path: build/app/outputs/apk/release/app-armeabi-v7a-release.apk
compression-level: 9

- name: Upload APK3
uses: actions/upload-artifact@v4
with:
name: AppRhyme-x86_64-release.apk
path: build/app/outputs/apk/release/app-x86_64-release.apk
compression-level: 9

- name: Rename APKs
run: |
mv build/app/outputs/apk/release/app-arm64-v8a-release.apk build/app/outputs/apk/release/AppRhyme-arm64-v8a-release.apk
mv build/app/outputs/apk/release/app-armeabi-v7a-release.apk build/app/outputs/apk/release/AppRhyme-armeabi-v7a-release.apk
mv build/app/outputs/apk/release/app-x86_64-release.apk build/app/outputs/apk/release/AppRhyme-x86_64-release.apk
3 changes: 2 additions & 1 deletion android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ if (flutterVersionName == null) {
android {
namespace "canxin.app.rhyme"
compileSdk flutter.compileSdkVersion
ndkVersion "25.2.9519653"
ndkVersion "22.1.7171670"
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
Expand All @@ -48,6 +48,7 @@ android {
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
multiDexEnabled true
}

buildTypes {
Expand Down
2 changes: 1 addition & 1 deletion android/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<application
android:label="AppRhyme"
android:name="${applicationName}"
android:name="androidx.multidex.MultiDexApplication"
android:usesCleartextTraffic="true"
android:icon="@mipmap/ic_launcher">
<activity
Expand Down

This file was deleted.

6 changes: 1 addition & 5 deletions lib/comp/play_page_comp/control_button.dart
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,7 @@ class ControlButtonState extends State<ControlButton> {
child: Icon(CupertinoIcons.pause_solid,
color: CupertinoColors.white, size: widget.buttonSize),
onPressed: () {
globalAudioServiceHandler.pause().then((value) {
log("成功暂停");
}).catchError((e) {
log("播放失败:$e");
});
globalAudioServiceHandler.pause();
},
));
} else {
Expand Down
25 changes: 12 additions & 13 deletions lib/util/audio_controller.dart
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ Future<void> initGlobalAudioServiceHandler() async {
config: const AudioServiceConfig(
androidNotificationChannelId: 'com.ryanheise.myapp.channel.audio',
androidNotificationChannelName: 'Audio playback',
androidNotificationOngoing: true,
androidNotificationOngoing: false,
),
);
}

// 应该实现所有的播放和控制,但是完全不关心ui如何
class AudioServiceHandler extends BaseAudioHandler with SeekHandler {
class AudioServiceHandler extends BaseAudioHandler
with SeekHandler, QueueHandler {
final AudioPlayer player = AudioPlayer();
final PlayMusicQueue musicQueue = PlayMusicQueue();
int playingMusicIndex = 0;
Expand All @@ -47,9 +48,11 @@ class AudioServiceHandler extends BaseAudioHandler with SeekHandler {
String toPlaySource = music.playInfo.file;
var tag = music.item;
// 设置播放资源
await player.setAudioSource(AudioSource.uri(Uri.parse(toPlaySource)));
await player
.setAudioSource(AudioSource.uri(Uri.parse(toPlaySource), tag: tag));
// 设置系统显示
// 这里的mediaItem是AudioService内部的

mediaItem.add(tag);
// 开始播放
await play();
Expand Down Expand Up @@ -122,20 +125,16 @@ class AudioServiceHandler extends BaseAudioHandler with SeekHandler {
@override
Future<void> play() async {
await player.play();
Future.delayed(const Duration(microseconds: 500)).then((value) {
if (!player.playing) {
play();
}
});
// Future.delayed(const Duration(milliseconds: 500)).then((value) {
// if (!player.playing) {
// play();
// }
// });
}

@override
Future<void> pause() async {
try {
await player.pause();
} catch (e) {
print(e.toString());
}
await player.pause();
}

@override
Expand Down
6 changes: 3 additions & 3 deletions macos/Runner.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,7 @@
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = canxin.app.rhyme.RunnerTests;
PRODUCT_BUNDLE_IDENTIFIER = com.canxin.AppRhyme.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/AppRhyme.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/AppRhyme";
Expand All @@ -399,7 +399,7 @@
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = canxin.app.rhyme.RunnerTests;
PRODUCT_BUNDLE_IDENTIFIER = com.canxin.AppRhyme.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/AppRhyme.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/AppRhyme";
Expand All @@ -413,7 +413,7 @@
CURRENT_PROJECT_VERSION = 1;
GENERATE_INFOPLIST_FILE = YES;
MARKETING_VERSION = 1.0;
PRODUCT_BUNDLE_IDENTIFIER = canxin.app.rhyme.RunnerTests;
PRODUCT_BUNDLE_IDENTIFIER = com.canxin.AppRhyme.RunnerTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
TEST_HOST = "$(BUILT_PRODUCTS_DIR)/AppRhyme.app/$(BUNDLE_EXECUTABLE_FOLDER_PATH)/AppRhyme";
Expand Down
2 changes: 1 addition & 1 deletion macos/Runner/Configs/AppInfo.xcconfig
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
PRODUCT_NAME = AppRhyme

// The application's bundle identifier
PRODUCT_BUNDLE_IDENTIFIER = canxin.app.rhyme
PRODUCT_BUNDLE_IDENTIFIER = com.canxin.AppRhyme

// The copyright displayed in application information
PRODUCT_COPYRIGHT = Copyright ©️ 2024 Canxin121. All rights reserved.
Loading

0 comments on commit 7b761ea

Please sign in to comment.