frondeus / fvtt-syrin-control

Syrinscape Online Control plugin for FoundryVTT
MIT License
13 stars 4 forks source link

0.4.0-beta2: refreshing a scene (F5) stops the mood #72

Open Majea opened 1 year ago

Majea commented 1 year ago

Describe the bug

In Syrinscape control 0.4.0-beta2, when you refresh a page where a scene plays a syrinscape mood is being played, the mood stops playing.

To Reproduce

  1. Open a scene that is configured with a syrinscape playlist.
  2. => the syrinscape mood starts
  3. refresh the page (F5 or cmd-R).
  4. => the syrinscape mood stops.

Expected behavior

The syrinscape mood keeps playing.

Logs

Foundry VTT | Rendering GmScreenApplication
utils.ts:28 SyrinControl | Subscribe | next mood:  undefined
trace @ utils.ts:28
(anonymous) @ main.ts:106
(anonymous) @ stores.ts:322
subscribe @ index.mjs:50
subscribe @ stores.ts:314
(anonymous) @ main.ts:105
await in (anonymous) (async)
#call @ foundry.js:724
callAll @ foundry.js:681
setupGame @ foundry.js:7952
await in setupGame (async)
_initializeGameView @ foundry.js:8999
_initializeView @ foundry.js:8975
initialize @ foundry.js:7825
await in initialize (async)
🎁call_wrapped @ libWrapper-wrapper.js:507
🎁libWrapperInit @ libWrapper-api.js:805
await in 🎁libWrapperInit (async)
🎁Game.prototype.initialize#0 @ libWrapper-wrapper.js:187
window.addEventListener.once @ foundry.js:79693
sequencer-database.js:68 Sequencer | Database | Entries for "autoanimations" registered
Majea commented 1 year ago

Actually, I wonder if it's not linked to another usability issue. Let's say I have Mood X setup on Scenes A and B. I activate A and mood X starts. If I change to Scene B, X still plays. All good. But then I decide to start mood Y (eg. a battle version of X). When I switch back to Scene A, it's still Y playing although I would expect X to start.

to summarise: Scene A: Mood X Scene B: Mood X

user activities:

  1. activate A => play X
  2. activate B => play X
  3. play Y using macro => play Y
  4. activate A => still play Y even though I would expect X.
frondeus commented 1 year ago

That one was intended behaviour.

During module initialization the SyrinControl does not know if there is already playing mood or not, or if already playing mood has been initiated by the module before refresh. Therefore always it "grabs the control" over Syrinscape by clearing its state.

Now, technically I could just make an API request to Syrinscape during initialization "Hey, what is currently playing?". But even tho I get the response "Mood XYZ is currently playing" I lack the context - Was it because a token is in Ambient Sound field of effect, or perhaps GM clicked "Play mood" manually?

That sounds silly but current design is based on the idea, that Ambient Sounds have higher priority over the Playlist moods. Otherwise I'm not sure how I can proceed. But that means, I need to know if currently playing mood is Ambient or not. And that information is currently lost during F5.

So that gives us another solution - what if I simply store in local storage current state and preserve it during the F5? That could work, right?

Well, yes - but only if we assume that between one session (before F5) and a new one (after F5), you didn't change the mood by using other control panels, for example, native syrinscape app.

That however, could be a good compromise. Persist storage, then fetch new state from API - if the state is equal what was playing the last time - do nothing, just use saved state, otherwise assume its not Ambient Sound but playlist, and show new currently playing mood on sidebar.

frondeus commented 1 year ago

For now, I will remove the bug label and make it an enhancement since it was designed to stop the mood.