Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<LangVersion>latest</LangVersion>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<VersionPrefix>2.0.1</VersionPrefix>
<VersionPrefix>2.0.2</VersionPrefix>
<VersionSuffix></VersionSuffix>
<VersionSuffix Condition="'$(RepriseBuildNumber)' != '' and '$(VersionSuffix)' != ''">$(VersionSuffix).$(RepriseBuildNumber)</VersionSuffix>
<InformationalVersion Condition="'$(RepriseBuildNumber)' != '' and '$(VersionSuffix)' == ''">$(VersionPrefix)+$(RepriseBuildNumber)</InformationalVersion>
Expand Down
3 changes: 2 additions & 1 deletion src/Reprise.Core/MediaSessionSnapshot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,8 @@ public sealed record MediaSessionSnapshot(
TimeSpan? Position,
double? Volume,
Uri? ArtworkUri,
DateTimeOffset ObservedAt)
DateTimeOffset ObservedAt,
string? CollectionEvidence = null)
{
/// <summary>
/// Fraction of the track that has already played, as a progress-bar value.
Expand Down
8 changes: 7 additions & 1 deletion src/Reprise.Desktop/NowPlayingViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,15 @@ public NowPlayingViewModel(
IArtworkLoader? artworkLoader = null,
TimeProvider? timeProvider = null,
ILyricsService? lyricsService = null,
Func<DesktopPreferences>? preferences = null)
Func<DesktopPreferences>? preferences = null,
RecordShopConnection? recordShop = null)
{
_mediaSessionService = mediaSessionService;
_artworkLoader = artworkLoader ?? new ArtworkLoader();
_timeProvider = timeProvider ?? TimeProvider.System;
_lyricsService = lyricsService;
_preferences = preferences ?? DefaultPreferences;
RecordShop = recordShop;
}

/// <summary>
Expand All @@ -173,6 +175,9 @@ public NowPlayingViewModel(
/// </summary>
public IReadOnlyList<MediaSessionSnapshot> Sessions => _sessions;

/// <summary>Optional, explicitly connected public listening collector.</summary>
public RecordShopConnection? RecordShop { get; }

/// <summary>
/// The session currently on display, or null when nothing is playing.
/// </summary>
Expand Down Expand Up @@ -427,6 +432,7 @@ public async Task RefreshAsync()
: session).ToList();
_sessions = sessions;
Apply(SelectActive(sessions, started));
RecordShop?.Observe(sessions, ActiveSession, ArtworkData);
SetPollError(null);
}
catch (OperationCanceledException) when (_lifetime.IsCancellationRequested)
Expand Down
275 changes: 275 additions & 0 deletions src/Reprise.Desktop/RecordShopConnection.cs

Large diffs are not rendered by default.

5 changes: 4 additions & 1 deletion src/Reprise.Desktop/RepriseApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,13 @@ public override void OnFrameworkInitializationCompleted()
? new AutomaticApplicationUpdater(platformUpdater, preferences) : null;
updater?.Start();
desktop.Exit += (_, _) => updater?.Dispose();
var recordShop = new RecordShopConnection();
desktop.Exit += (_, _) => recordShop.Dispose();
var viewModel = new NowPlayingViewModel(
service,
lyricsService: new LyricsService(),
preferences: () => preferences.Current);
preferences: () => preferences.Current,
recordShop: recordShop);
viewModel.LastPlayedPlayerChanged += (_, kind) => Dispatcher.UIThread.Post(() =>
preferences.Update(p => p with { LastPlayedPlayer = kind.ToString() }));
var window = new NowPlayingWindow(viewModel, preferences);
Expand Down
45 changes: 43 additions & 2 deletions src/Reprise.Desktop/SettingsWindow.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ public sealed class SettingsWindow : Window
private StackPanel? _priorityList;
private TextBlock? _autostartError;
private ToggleSwitch? _autostartToggle;
private TextBlock? _recordShopStatus;
private Button? _recordShopConnect;
private Button? _recordShopDisconnect;

/// <summary>
/// Whether the application is shutting down and the window may close.
Expand Down Expand Up @@ -119,7 +122,7 @@ public SettingsWindow(
_sessionTimer = new DispatcherTimer(
TimeSpan.FromMilliseconds(500),
DispatcherPriority.Background,
(_, _) => RefreshSessions());
(_, _) => { RefreshSessions(); RefreshRecordShop(); });

_preferences.Changed += (_, _) => RefreshAll();
Opened += (_, _) =>
Expand Down Expand Up @@ -335,7 +338,45 @@ private Control BuildGeneralTab()
"로그인하면 Reprise를 자동으로 실행합니다.",
autostartRow,
_autostartError);
return SettingsForm.Page(playback, lyricsSection, priority, startup);
return _viewModel.RecordShop is null
? SettingsForm.Page(playback, lyricsSection, priority, startup)
: SettingsForm.Page(playback, lyricsSection, priority, startup, BuildRecordShopSection());
}

/// <summary>Offers explicit browser consent before sending any playback metadata.</summary>
private Control BuildRecordShopSection()
{
var connection = _viewModel.RecordShop!;
_recordShopStatus = new TextBlock { Text = connection.Status, TextWrapping = TextWrapping.Wrap, Margin = new Thickness(14, 10), FontSize = PanelTypography.Subtitle };
_recordShopConnect = new Button { Content = "Google 계정 연결" };
_recordShopDisconnect = new Button { Content = "연결 해제" };
_recordShopConnect.Click += async (_, _) =>
{
var task = connection.ConnectAsync(uri => System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo(uri.AbsoluteUri) { UseShellExecute = true }));
RefreshRecordShop();
await task;
RefreshRecordShop();
};
_recordShopDisconnect.Click += async (_, _) =>
{
if (connection.IsConnecting) connection.CancelConnect();
else await connection.DisconnectAsync();
RefreshRecordShop();
};
var actions = new StackPanel { Orientation = Orientation.Horizontal, Spacing = 8, Children = { _recordShopConnect, _recordShopDisconnect } };
RefreshRecordShop();
return SettingsForm.Section("Reprise.mx", "연결 후 곡명·아티스트·앨범·재생 상태를 전송하며, 프로필과 청취 시간이 공개 차트에 표시됩니다.",
SettingsForm.Row("청취 기록 공유", actions), _recordShopStatus);
}

/// <summary>Reflects asynchronous pairing and revocation in the existing settings timer.</summary>
private void RefreshRecordShop()
{
if (_viewModel.RecordShop is not { } connection || _recordShopStatus is null) return;
_recordShopStatus.Text = connection.Status;
_recordShopConnect!.IsEnabled = !connection.IsConnected && !connection.IsConnecting;
_recordShopDisconnect!.IsEnabled = connection.IsConnected || connection.IsConnecting;
_recordShopDisconnect.Content = connection.IsConnecting ? "연결 취소" : "연결 해제";
}

/// <summary>
Expand Down
24 changes: 12 additions & 12 deletions src/Reprise.Platform.MacOS/Reprise.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -420,7 +420,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = Reprise/Reprise.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 5;
CURRENT_PROJECT_VERSION = 6;
DEVELOPMENT_TEAM = 85VUD9PZRQ;
ENABLE_APP_SANDBOX = YES;
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -442,7 +442,7 @@
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 2.0.1;
MARKETING_VERSION = 2.0.2;
PRODUCT_BUNDLE_IDENTIFIER = dev.junx.Reprise;
PRODUCT_NAME = "$(TARGET_NAME)";
REGISTER_APP_GROUPS = YES;
Expand All @@ -466,7 +466,7 @@
ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
CODE_SIGN_ENTITLEMENTS = Reprise/Reprise.entitlements;
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 5;
CURRENT_PROJECT_VERSION = 6;
DEVELOPMENT_TEAM = 85VUD9PZRQ;
ENABLE_APP_SANDBOX = YES;
ENABLE_HARDENED_RUNTIME = YES;
Expand All @@ -488,7 +488,7 @@
LD_RUNPATH_SEARCH_PATHS = "@executable_path/Frameworks";
"LD_RUNPATH_SEARCH_PATHS[sdk=macosx*]" = "@executable_path/../Frameworks";
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 2.0.1;
MARKETING_VERSION = 2.0.2;
PRODUCT_BUNDLE_IDENTIFIER = dev.junx.Reprise;
PRODUCT_NAME = "$(TARGET_NAME)";
REGISTER_APP_GROUPS = YES;
Expand All @@ -510,12 +510,12 @@
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 5;
CURRENT_PROJECT_VERSION = 6;
DEVELOPMENT_TEAM = 85VUD9PZRQ;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 26.5;
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 2.0.1;
MARKETING_VERSION = 2.0.2;
PRODUCT_BUNDLE_IDENTIFIER = dev.junx.RepriseTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
Expand All @@ -536,12 +536,12 @@
buildSettings = {
BUNDLE_LOADER = "$(TEST_HOST)";
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 5;
CURRENT_PROJECT_VERSION = 6;
DEVELOPMENT_TEAM = 85VUD9PZRQ;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 26.5;
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 2.0.1;
MARKETING_VERSION = 2.0.2;
PRODUCT_BUNDLE_IDENTIFIER = dev.junx.RepriseTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
Expand All @@ -561,12 +561,12 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 5;
CURRENT_PROJECT_VERSION = 6;
DEVELOPMENT_TEAM = 85VUD9PZRQ;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 26.5;
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 2.0.1;
MARKETING_VERSION = 2.0.2;
PRODUCT_BUNDLE_IDENTIFIER = dev.junx.RepriseUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
Expand All @@ -586,12 +586,12 @@
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_STYLE = Automatic;
CURRENT_PROJECT_VERSION = 5;
CURRENT_PROJECT_VERSION = 6;
DEVELOPMENT_TEAM = 85VUD9PZRQ;
GENERATE_INFOPLIST_FILE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 26.5;
MACOSX_DEPLOYMENT_TARGET = 14.0;
MARKETING_VERSION = 2.0.1;
MARKETING_VERSION = 2.0.2;
PRODUCT_BUNDLE_IDENTIFIER = dev.junx.RepriseUITests;
PRODUCT_NAME = "$(TARGET_NAME)";
SDKROOT = macosx;
Expand Down
1 change: 1 addition & 0 deletions src/Reprise.Platform.MacOS/Reprise/NowPlayingStore.swift
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,7 @@ final class NowPlayingStore {
currentSnapshots: snapshotsByPlayer
)
synchronizeLyricsWithActiveTrack(observedAt: Date())
RecordShopConnection.shared.observe(menuBarSnapshot)
if MediaPlayerKind.allCases.contains(where: { player in
Self.menuBarContentChanged(
from: previousSnapshots[player]
Expand Down
Loading
Loading