python-firetv icon indicating copy to clipboard operation
python-firetv copied to clipboard

Incorrect states

Open marcpabst opened this issue 9 years ago • 17 comments

When a video is running (also when paused vie pause or the home key) the API alsways shows "play" which is obviously not correct. Running v. 1.0.2 and latest FireTV-OS.

marcpabst avatar Sep 07 '16 12:09 marcpabst

Video in an app, or in the standard Fire TV gui?

happyleavesaoc avatar Sep 07 '16 15:09 happyleavesaoc

Standard GUI. You method of using wake locks seems to fail, although I don't fully understand why. I'm trying to fix it by checking if audio is played via adb instead of using wake locks.

marcpabst avatar Sep 07 '16 15:09 marcpabst

I found a solution. If you run cat /proc/asound/card*/pcm*/sub*/status | grep "state" in adb, when audio is played, the last line will always contain "RUNNING". This seems to be pretty reliable.

marcpabst avatar Sep 07 '16 16:09 marcpabst

Just checking, if there is a way to resolve this? I only get two states, "play" or "off".

kdvlr avatar Oct 08 '16 18:10 kdvlr

I took a look at this. I get the correct states without any changes. My stick is on Fire OS 5.2.1.1. Are you guys running a different version?

I tried implementing @mxtra's solution anyway, but my version does not produce the same output.

happyleavesaoc avatar Oct 14 '16 01:10 happyleavesaoc

I am using it with a fire tv box. That might explain why.

Let me verify with a stick. Meanwhile can you share a version with @mxtra's suggestion , so I can verify if that works wth the fire tv box ?

On Oct 13, 2016, at 8:53 PM, happyleavesaoc [email protected] wrote:

I took a look at this. I get the correct states without any changes. My stick is on Fire OS 5.2.1.1. Are you guys running a different version?

I tried implementing @mxtra's solution anyway, but my version does not produce the same output.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

kdvlr avatar Oct 14 '16 02:10 kdvlr

Sure, clone the repo and checkout branch fix-states. Run from the checked out directory like python -m firetv -d 192.168.2.55:5555

happyleavesaoc avatar Oct 14 '16 02:10 happyleavesaoc

I tried with a fire TV stick and the states were completely off. My stick has problems staying on a network, so could not spend too much time on it.

On my FireTV box, I tried the fix-states branch. This time, it changes between standby, play and pause. While playing a media, if I pause the video, it works correctly and recognizes. However, if i go back or press the Home button from a video, the status still remains on Play and does not go to Idle or Standby .

Any hints on what I should try next ?

kdvlr avatar Oct 15 '16 05:10 kdvlr

does someone work on this?

juliangeiges avatar Oct 16 '16 22:10 juliangeiges

I am trying to see if I can do something. I am not a python or a android/adb expert, so it takes some time.

Here's what I found, looking for the audio process to be running is not reliable because other than a video playing these are the times that the audio is active.

  1. If Navigation sounds are turned on, just navigating changes the state to Play.
  2. If you use Alexa, then that turns on the audio process as well causing the state to change to play.

Looks like we still need to identify a foolproof way of identifying if the fire tv is actually playing a media or not.

kdvlr avatar Oct 17 '16 03:10 kdvlr

I know its been a while, but I still get incorrect states. Any updates on this issue?

States which are not working for me are "Pause" and "Disconnected". If I play media and press pause, using the remote or in HA, status remains "play". "Disconnected" is not working at all. If I unplug my Fire TV Stick, it shows the last state.

Running on Fire TV Stick, Fire OS 5.2.6.0 and Home Assistant 0.57.2.

fabianbrunke avatar Nov 10 '17 18:11 fabianbrunke

Hi,

Thanks for the awesome work here!

I just ported the library to typescript/JavaScript and came across the same state problem with my FireTV gen 3. python-firetv always reported "play" when not in idle/standby (e.g. netflix app in foreground but playback paused).

I found a possible fix by parsing the output of dumpsys media_session which includes all active audio streams as well as an active and state=PlaybackState{...} property. It actually provides more detailed information as the PlaybackState includes values for Playing, Paused, Stop, Buffering, Connecting, ... (https://developer.android.com/reference/android/media/session/PlaybackState.html). Maybe this helps.

Cheers Patrick

ppacher avatar Mar 01 '18 19:03 ppacher

I looked into using that at some point, but unfortunately not all apps leverage that API, so the detection with it would still be spotty. Nevertheless, I think that would be an enhancement to the current situation, so I would gladly see support for using it as the primary source for playback state!

rytilahti avatar Mar 01 '18 23:03 rytilahti

I don't think there's a universal solution for this, I think state detection might need to be app-specific. I merged in some initial work in https://github.com/happyleavesaoc/python-firetv/pull/80. Feel free to contribute state detection for different apps or to improve on the existing state detection.

JeffLIrion avatar Feb 25 '19 15:02 JeffLIrion

Hi, after update to homeassistant 0.89 .. before the only thing that worked was play, pause and stop. Now it's ok source, forward, reverse, standby ... but it say always paused during viewing .. It change from "standby" .. to "paused" during viewing (Netflix, Amazon Video and all other app .. also listening music) but it don't change in "playing". Before update it switched also in Netflix menu .. for me was ok.

zUpm4n avatar Mar 10 '19 22:03 zUpm4n

I also only see paused.

derekgdicamillo avatar Mar 15 '19 23:03 derekgdicamillo

@zUpm4n @derekgdicamillo I guess you read this issue and the advices: https://github.com/home-assistant/home-assistant/issues/23346

pattyland avatar May 29 '19 01:05 pattyland