Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfixes and Unit Tests #69

Merged
merged 22 commits into from
Apr 8, 2023
Merged

Bugfixes and Unit Tests #69

merged 22 commits into from
Apr 8, 2023

Conversation

NeonDaniel
Copy link
Member

@NeonDaniel NeonDaniel commented Apr 5, 2023

Resolve error relating to #65
Adds unit tests for OCP class
Closes #22
Closes #66

Adds unit tests for OCP class
@codecov
Copy link

codecov bot commented Apr 5, 2023

Codecov Report

❗ No coverage uploaded for pull request base (dev@6b4d31d). Click here to learn what that means.
The diff coverage is n/a.

@@          Coverage Diff          @@
##             dev     #69   +/-   ##
=====================================
  Coverage       ?   0.00%           
=====================================
  Files          ?      13           
  Lines          ?    2633           
  Branches       ?       0           
=====================================
  Hits           ?       0           
  Misses         ?    2633           
  Partials       ?       0           

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

WIP OCPMediaPlayer tests
@NeonDaniel
Copy link
Member Author

NeonDaniel commented Apr 6, 2023

Closes #22

…hods

Raise an exception if trying to get a stream from nothing
Add init tests for registered events
Fixes #22 with unit tests for duck/unduck calling pause/resume
@NeonDaniel
Copy link
Member Author

NeonDaniel commented Apr 7, 2023

Closes #66

if self.state == PlayerState.PLAYING:
self.pause()
self._paused_on_duck = True
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should a DuckingState be introduced? could be useful if we want to signal it in the GUI/LED events etc

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure the state would need to be more than a boolean.. Either we were playing and are now ducked, or we don't care about the ducking state, right?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i meant as a generic property to be exposed via messagebus and MPRIS, thinking about 3rd party consumers of this info

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would make more sense to put that in the audio module since we could then also resolve the TODO of waiting for audio output to end. It also would make it available to installations/devices that don't implement OCP media playback.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure about that.... because OCP can be used standalone too, it is not a audio module property either, audio delegates playback to OCP so OCP should be the one reporting the end of playback

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

dont mean this as a PR blocker, it can be done some other time, it's quite unimportant and out of scope! want those fixes and unittests in ASAP :)

@NeonDaniel NeonDaniel requested a review from JarbasAl April 8, 2023 00:39
@NeonDaniel NeonDaniel marked this pull request as ready for review April 8, 2023 00:39
if state == MediaState.END_OF_MEDIA:
# playback ended, allow next track to change metadata again
self.reset()
# Don't do anything. Let OCP manage this object's state
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this was added because the stream extractors dont replace old media, so if you send a request to play a uri only it will keep the title etc from previous track

the reset seems to be doing too much, but it is needed

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would this request happen without going through OCP?

Copy link
Member

@JarbasAl JarbasAl Apr 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OCP playback requests may contain full metadata or partial, metadata is then extracted from the uri automatically to fill gaps

if a playback request is missing info (title, artist, duration....) NowPlaying will keep the old info when the next track comes up, the stream extractors will refuse to replace the NowPlaying data (except uri) since they are a fallback, they assume the skill provided more accurate metadata than they are extracting

end result, Track 1 title with Track 2 playing

Copy link
Member

@JarbasAl JarbasAl Apr 8, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

note that the extractors only work at playback start, they have no way to know if the data in NowPlaying is old or not

if the reset is moved out of here it then needs to be done elsewhere before any playback request, that has more possible code paths so it seemed easier/safer to do it in here via bus events

#31

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The call was moved here, is there another place I should add it? This handled all the paths I could find within OCP..

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i missed that change, guess that works!

please add a test for the specific scenario mentioned above if you haven't yet

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't look at the diff lately and didn't realize how buried it is in other changes.

Copy link
Member

@JarbasAl JarbasAl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

couple comments left with suggestions can be done later, this is looking great already!

@JarbasAl JarbasAl added the bug Something isn't working label Apr 8, 2023
@JarbasAl JarbasAl merged commit 73cd68a into dev Apr 8, 2023
@JarbasAl JarbasAl deleted the FIX_OCPBugfixesWithTests branch April 8, 2023 01:22
@github-actions github-actions bot mentioned this pull request Apr 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Continue playback on track end Paused Playback resumed on WW
2 participants