diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0d802b5..7cc1222 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -106,9 +106,7 @@ jobs: - name: Build # Unreleased v1 is used to be able to use uploadWorkflowArtifacts and mobile: - # uses: tauri-apps/tauri-action@a1b01e690374452a209dd44f6de089dda9003d3d - # v1 bugfix by Fabian to fix multiple releases being created: - uses: tauri-apps/tauri-action@ed2469ebf97aca60a033d455c4f2c28c65375fa3 + uses: tauri-apps/tauri-action@850c373b94f35e16e4de61cbb9f6e4876af8c0b4 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: diff --git a/CHANGELOG.md b/CHANGELOG.md index 7eb798b..d7ca93b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## Next +- Android: Add track streaming search links for Spotify and YouTube Music + ## 0.21.0 - 2026 Map 6 - Add a basic Android app. It only lets you browse a Ferrum Library.json file. No playback or syncing yet. diff --git a/Cargo.lock b/Cargo.lock index 884bf0e..cf64431 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1136,7 +1136,7 @@ dependencies = [ [[package]] name = "ferrum_mobile" -version = "0.0.0" +version = "0.0.1" dependencies = [ "android_logger", "anyhow", diff --git a/mobile/src-tauri/Cargo.toml b/mobile/src-tauri/Cargo.toml index 8f20f46..e79e9b0 100644 --- a/mobile/src-tauri/Cargo.toml +++ b/mobile/src-tauri/Cargo.toml @@ -1,7 +1,9 @@ [package] name = "ferrum_mobile" +publish = false edition = "2024" default-run = "ferrum_mobile" +version = "0.0.1" # overridden in ci build # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html diff --git a/mobile/src-tauri/capabilities/default.json b/mobile/src-tauri/capabilities/default.json index 7c71354..014011a 100644 --- a/mobile/src-tauri/capabilities/default.json +++ b/mobile/src-tauri/capabilities/default.json @@ -15,6 +15,10 @@ "store:default", "safe-area-insets-css:default", "android-fs:default", - "os:default" + "os:default", + { + "identifier": "opener:allow-open-url", + "allow": [{ "url": "*" }] + } ] } diff --git a/mobile/src-tauri/src/lib.rs b/mobile/src-tauri/src/lib.rs index 886e84b..19c900b 100644 --- a/mobile/src-tauri/src/lib.rs +++ b/mobile/src-tauri/src/lib.rs @@ -21,7 +21,6 @@ fn error_popup(app_handle: tauri::AppHandle, msg: String) { .show(|_| {}); } -// you shoud use async fn #[tauri::command] #[specta::specta] async fn open_file_persistent_android(app: tauri::AppHandle) -> Result, String> { diff --git a/mobile/src/routes/+page.svelte b/mobile/src/routes/+page.svelte index a5e6ed5..376d781 100644 --- a/mobile/src/routes/+page.svelte +++ b/mobile/src/routes/+page.svelte @@ -6,19 +6,36 @@ import Library from './Library.svelte' import { Store } from '@tauri-apps/plugin-store' import { platform } from '@tauri-apps/plugin-os' - import '@saurl/tauri-plugin-safe-area-insets-css-api' + + const platform_value = platform() + if (platform_value === 'android' || platform_value === 'ios') { + await import('@saurl/tauri-plugin-safe-area-insets-css-api') + } + + type StreamingService = 'spotify' | 'youtube-music' let loading = $state(false) let error = $state('') + let streaming_service = $state('spotify') const store = await Store.load('settings.json') let library = $state(null) const saved_library_path = await store.get('library_path') + const saved_streaming_service = await store.get('streaming_service') + if (saved_streaming_service === 'spotify' || saved_streaming_service === 'youtube-music') { + streaming_service = saved_streaming_service + } if (typeof saved_library_path === 'string') { load_library(saved_library_path) } + async function set_streaming_service(service: StreamingService) { + streaming_service = service + await store.set('streaming_service', service) + await store.save() + } + async function open_library() { let path: string | null = null if (platform() === 'android') { @@ -81,8 +98,28 @@ {/snippet} +
+
+ + +
+
+ {#if library} - + {:else}
+ streaming_service: streaming_service_type }>() let error = $state('') let search_query = $state('') @@ -179,6 +182,18 @@ const s = Math.floor(seconds) return `${Math.floor(s / 60)}:${String(s % 60).padStart(2, '0')}` } + + function open_track(track: Track) { + const artist = track.artist?.trim() || 'Unknown Artist' + const title = track.name.trim() + const query = `${artist} - ${title}` + const encoded_query = encodeURIComponent(query) + if (streaming_service === 'youtube-music') { + openUrl(`vnd.youtube.music://search?q=${encoded_query}`) + } else if (streaming_service === 'spotify') { + openUrl(`open.spotify.com/search/${encoded_query}`) + } + }
0}
    {#each filtered_tracks as track} -
  • -
    -

    - {track.name} -

    -

    - {track.artist ?? 'Unknown Artist'} - {#if track.albumName} - · {track.albumName} - {/if} -

    -
    - {#if track.genre} - {track.genre} +
  • +
-
- {format_duration(track.duration)} - {#if track.playCount} - {track.playCount} plays - {/if} - {#if track.liked} - ♥ - {/if} -
+ {/each}