File tree Expand file tree Collapse file tree 1 file changed +11
-2
lines changed
src/modules/tt-windows-utils Expand file tree Collapse file tree 1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,12 @@ typedef Windows::Media::MediaPlaybackType MediaPlaybackType;
1919Napi::String getPlaybackStatus (const Napi::CallbackInfo &info) {
2020 std::string statusStr = " closed" ;
2121
22- GSMTCSM manager = GSMTCSM::RequestAsync ().get ();
22+ auto session_async = GSMTCSM::RequestAsync ();
23+ if (session_async.wait_for (std::chrono::seconds{ 1 }) != winrt::Windows::Foundation::AsyncStatus::Completed) {
24+ return Napi::String::New (info.Env (), statusStr);
25+ }
26+
27+ GSMTCSM manager = session_async.get ();
2328 GlobalSystemMediaTransportControlsSession session =
2429 manager.GetCurrentSession ();
2530
@@ -51,7 +56,11 @@ Napi::String getPlaybackStatus(const Napi::CallbackInfo &info) {
5156
5257Napi::Object getPlaybackInfo (const Napi::CallbackInfo &info) {
5358 Napi::Object obj = Napi::Object::New (info.Env ());
54- GSMTCSM manager = GSMTCSM::RequestAsync ().get ();
59+ auto session_async = GSMTCSM::RequestAsync ();
60+ if (session_async.wait_for (std::chrono::seconds{ 1 }) != winrt::Windows::Foundation::AsyncStatus::Completed) {
61+ return obj;
62+ }
63+ GSMTCSM manager = session_async.get ();
5564 GlobalSystemMediaTransportControlsSession session =
5665 manager.GetCurrentSession ();
5766
You can’t perform that action at this time.
0 commit comments