Jump to content
C4 Forums | Control4

How to cycle through sessions?


SpencerT

Recommended Posts

I apologize for the silly question as I'm sure this is pretty easy.  I'm trying to program a pico button to "cycle through" existing media sessions.  The intention is each button press would move me to the next session but it stops after the first active session and subsequent presses don't do anything.  Any suggestions on what I'm missing?

Thanks,

Spencer

image.png.7290263ffe1b63ccf27f1fbafb42b1c9.png

 

 

 

Link to comment
Share on other sites


Your code is doing what it is coded to do but not what you want it to do.

In this case, I would probably create a variable called SessionIndex and simply have the button push increase this by 1. 

I would then do the majority of the coding on when SessionIndex changes. Here I would have:

   If SessionIndex >= 7 set SessionIndex = 0

   If SesseionIndex = 0 turn Room Off

   If SessionIndex = 6 and GreatRoom is in a session join GreatRoom session else add 1 to Session Index

   If SessionIndex = 5 and FrontPatio is in a session join FrontPatio session else add 1 to SessionIndex

Etc.

The order (working backwards from 6 is deliberate to stop unintended consequences of adding 1 to SessionIndex before C4 goes through all if the relevant lines of code.  Careful use of else’s could get the same result and remove the need to work backwards from 6 to 1.

I haven’t tried this code so you would need to test the code.

Personally, I would complicate this further (with a 2 second timer) to allow multiple button clicks in close succession without multiple session changes (but only 1 change).

Link to comment
Share on other sites

15 minutes ago, c4toys said:

I do something similar and "Else" select room control preset cycler

Is "in a session" one of the room variables? This is a cool idea, but I don't see where to program against to identify whether the room is in a session.  Is this using a particular driver?

Link to comment
Share on other sites

3 hours ago, DLite said:

Is "in a session" one of the room variables? This is a cool idea, but I don't see where to program against to identify whether the room is in a session.  Is this using a particular driver?

"In a session" is under "digital media" on the right side. 

Link to comment
Share on other sites

There is also a really neat driver (Keypad Audio Control) from Domosapiens (on DriverCentral) that sits on top of the Room Control driver and allows a lot of music control.  It allows joining of sessions such as this and toggling through options.  I can’t recall (off the top of my head) if it would allow this many sessions to be joined as options. @pbirwould know.

Link to comment
Share on other sites

The Keypad Audio Control driver allows you to 'capture' audio from another room.  Up to three rooms may be designated for capture and the driver will capture the first room with its audio turned On.  This is actually the opposite of adding sessions using a T3/T4 screen (pull vs. push).

Link to comment
Share on other sites

Well... Almost.  So this seems to work well as long as I'm streaming music directly from the controller.  Easily jumps between sessions with each button press.  

But..  If I have sessions playing with other music (for anything other than pandora we use a NAD CI-580 Bluesound player for 4 more streams). 

Everything is plumbed into my matrix, sessions in the app shows TV audio, streaming sources off of the bluesound, just the same as pandora or qobuz on the controller.

Is it a correct assumption that the digital media / session variables only apply to devices in a session with audio streaming directly from the controller?  Not ALL of the actual sessions running?

 

 

Link to comment
Share on other sites

3 hours ago, SpencerT said:

Well... Almost.  So this seems to work well as long as I'm streaming music directly from the controller.  Easily jumps between sessions with each button press.  

But..  If I have sessions playing with other music (for anything other than pandora we use a NAD CI-580 Bluesound player for 4 more streams). 

Everything is plumbed into my matrix, sessions in the app shows TV audio, streaming sources off of the bluesound, just the same as pandora or qobuz on the controller.

Is it a correct assumption that the digital media / session variables only apply to devices in a session with audio streaming directly from the controller?  Not ALL of the actual sessions running?

 

 

Hate to be the DB that quotes myself. Just trying to document this.

What I found...

Programming against the digital media / if in a session variables - only works for streams coming off the controller (at least in my environment).  However, if I detect the session some other way (like room / power state).. I can use the digital media / add rooms to session action. 

I'm sure I didn't discover water on mars, just thought it was super weird behavior and wanted to document it in this post.  Actually found a post from 2017 specifying that not all A/V devices are considered digital media.  Based on my testing, I would surmise that not all sessions are considered 'digital media / sessions' from a conditionals  standpoint.  But - all digital media sessions can be joined with the command regardless of "how" they were started.  ????????

Link to comment
Share on other sites

11 minutes ago, c4toys said:

Dont join session. use room control driver to add rooms to the source room.

I'm starting to play with that, dealer added it to a few rooms for me to play around with.

Weird thing is digital media /  join session works for everything.  Detect session doesn't work through digital media (unless it's a c4 stream).

Link to comment
Share on other sites

1 hour ago, c4toys said:

Dont join session. use room control driver to add rooms to the source room.

Sorry - I assumed you knew that Digital Media was limited to “Digital Media within the C4 environment”.  The Room Control driver saves lots of extra code in this regard.  And the Domosapiens driver on top of the Room Control Driver makes things even simpler.

Link to comment
Share on other sites

9 hours ago, SpencerT said:

@South Africa C4 user - Thank you so much.  Was able to get this to work with variables.  Cycles through each active session with each click.  Exactly what I was looking for.  Took me a while to get it to work.  Thank you!

 

image.png.01ad137859d28a9afcc48031cb851758.png

Please note that your “else’s” in the above code are doing absolutely nothing… for an “else” to work, you need to indent the code that applies to the “else”.  This is done by dragging the relevant code onto the else…

Link to comment
Share on other sites

Just now, South Africa C4 user said:

Please note that your “else’s” in the above code are doing absolutely nothing… for an “else” to work, you need to indent the code that applies to the “else”.  This is done by dragging the relevant code onto the else…

I suspect the reason you added all the additional “+1” to your code was because it was not doing what you expected which was a consequence of the “else” not being used…

Link to comment
Share on other sites

9 hours ago, South Africa C4 user said:

I suspect the reason you added all the additional “+1” to your code was because it was not doing what you expected which was a consequence of the “else” not being used…

Lol, It's because I did not fully understand and dumped all of this under the pico button.  Fwiw, this worked great with 2 sessions playing. It was seemingly random with sessions playing across all of these rooms. I also see what you meant about starting the variables from highest to lowest. I got that fixed, but re-reading your first post I see that I should have the pico button send a +1 and put the programming under the variable which will make this much cleaner (and it will actually work like I want it to).  I'll redo it and post it up.

Link to comment
Share on other sites

This thread is quite old. Please consider starting a new thread rather than reviving this one.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.