Author Topic: Get Pause/Play State?  (Read 3981 times)

0 Members and 1 Guest are viewing this topic.

Daniel

  • Jr. Member
  • **
  • Posts: 25
  • Karma: 2
    • View Profile
Get Pause/Play State?
« on: January 30, 2020, 11:22:00 AM »
I looked through the iTunes command options so I am sure it doesn't exist but is there any way to check whether or not music is currently being played?

I want to create a command where if music is currently being played it asks for confirmation but if music is paused or not playing at all then it will just execute it without confirmation.

When I am listening to music I'll be singing along and it thinks I'm telling it commands to change songs and stuff. I thought I would be able to use something like iTunes.GetSongTitle but it returns info even if the song is paused. I'm thinking that maybe I could tell VC to look through the history and see if an iTunes.Play Event has occurred without an iTunes.Stop Event. Can anyone think of a way I can do this? I guess I could have Groups enabled and disabled based on these events... hmmm

Daniel

  • Jr. Member
  • **
  • Posts: 25
  • Karma: 2
    • View Profile
Re: Get Pause/Play State?
« Reply #1 on: January 30, 2020, 11:54:18 AM »
What does Sound.GetStreamInfo even do? How do I view the info?

I did
Sound.GetStreamInfo
OSD.ShowText {LastResult} and {LastInfo}
and it doesn't return any information.

edit:

Is Group.GetEnabled bugged? It seems that group names are case sensitive but Group.GetEnabled forces lowercase. So when I do something like:
Group.GetEnabled Testing
it returns no results because it searches for "testing" and that group doesn't exist because the T is supposed to be capital. If I rename the group to all lowercase it works.
« Last Edit: January 30, 2020, 12:31:13 PM by Daniel »

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Get Pause/Play State?
« Reply #2 on: February 05, 2020, 12:29:06 PM »
I looked through the iTunes command options so I am sure it doesn't exist but is there any way to check whether or not music is currently being played?

I want to create a command where if music is currently being played it asks for confirmation but if music is paused or not playing at all then it will just execute it without confirmation.

When I am listening to music I'll be singing along and it thinks I'm telling it commands to change songs and stuff. I thought I would be able to use something like iTunes.GetSongTitle but it returns info even if the song is paused. I'm thinking that maybe I could tell VC to look through the history and see if an iTunes.Play Event has occurred without an iTunes.Stop Event. Can anyone think of a way I can do this? I guess I could have Groups enabled and disabled based on these events... hmmm

There is no such action because the iTunes SDK does not provide any method to check if a track is playing as far as I can tell.

Your best bet will be to use events.  You could use the events to turn groups on and off.  That would be easiest.  You could also use the events to set a variable and then check that variable when necessary.

It sounds like your issue of the speech recognition picking up your voice when you don't want it to is one that will always find new ways to cause problems so I would look first at ways of preventing or reducing that.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Get Pause/Play State?
« Reply #3 on: February 05, 2020, 12:40:54 PM »
What does Sound.GetStreamInfo even do? How do I view the info?

I did
Sound.GetStreamInfo
OSD.ShowText {LastResult} and {LastInfo}
and it doesn't return any information.


I don't have iTunes installed and have not worked on this plugin for a long time but I suspect that getstreaminfo only works if there is stream info available, such as if you are playing music from an internet radio station or other URL based stream.

jitterjames

  • Administrator
  • Hero Member
  • *****
  • Posts: 7714
  • Karma: 116
    • View Profile
    • VoxCommando
Re: Get Pause/Play State?
« Reply #4 on: February 05, 2020, 12:42:04 PM »

Is Group.GetEnabled bugged? It seems that group names are case sensitive but Group.GetEnabled forces lowercase. So when I do something like:
Group.GetEnabled Testing
it returns no results because it searches for "testing" and that group doesn't exist because the T is supposed to be capital. If I rename the group to all lowercase it works.

Yes.  It looks like this is a bug.  Thanks for bringing it to my attention.  I think this is one of those actions that almost noone ever uses so the bug went unnoticed.

Daniel

  • Jr. Member
  • **
  • Posts: 25
  • Karma: 2
    • View Profile
Re: Get Pause/Play State?
« Reply #5 on: February 07, 2020, 03:47:40 AM »

Your best bet will be to use events.  You could use the events to turn groups on and off.  That would be easiest.  You could also use the events to set a variable and then check that variable when necessary.


Yeah, this is what I ended up going with. I used a combination of iTunes.Play, Focused.iTunes, etc. events to enable groups.