-
-
Notifications
You must be signed in to change notification settings - Fork 54
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
client: refactor PlyrPlayer for better typechecking #1229
Conversation
WalkthroughThe updates involve enhancing the media player interface to support both synchronous and asynchronous control of media playback, reflecting modern browser capabilities. Additionally, the Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1229 +/- ##
================================================
- Coverage 62.1432% 61.6513% -0.4920%
================================================
Files 117 117
Lines 8445 9471 +1026
Branches 1156 1156
================================================
+ Hits 5248 5839 +591
- Misses 3197 3632 +435 ☔ View full report in Codecov by Sentry. |
Passing run #827 ↗︎Details:
Review all test suite changes for PR #1229 ↗︎ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 0
Configuration used: CodeRabbit UI
Files selected for processing (2)
- client/src/components/players/OmniPlayer.vue (2 hunks)
- client/src/components/players/PlyrPlayer.vue (6 hunks)
Additional comments: 7
client/src/components/players/PlyrPlayer.vue (5)
- 14-14: The import of
MediaPlayerWithCaptions
andMediaPlayerWithPlaybackRate
from./OmniPlayer.vue
is a new addition that aligns with the refactoring of thePlyrPlayer
component to use these interfaces.- 44-139: The player methods have been successfully refactored into the
playerImpl
object, which now encapsulates these methods. This change should centralize the player's functionality and improve maintainability. However, ensure that all references to these methods throughout the codebase have been updated to useplayerImpl
.Verification successful
The review comment's concern about ensuring that all references to player methods throughout the codebase have been updated to use
playerImpl
is addressed by the design ofOmniPlayer.vue
. The component is intended to work with any implementation of theMediaPlayer
interface, and the calls toplayer.value.methodName()
are appropriate as long as theplayer
instance conforms to this interface. There is no evidence from the provided context thatplayer.value
specifically refers to an instance ofPlyrPlayer.vue
that would necessitate accessing methods throughplayerImpl
. Therefore, the review comment does not apply to the references inOmniPlayer.vue
.* 122-138: The methods `getAvailablePlaybackRates`, `getPlaybackRate`, and `setPlaybackRate` have been removed from the `PlyrPlayer` component. This could be a simplification or a relocation of these functionalities. If these methods are essential, ensure they have been moved to an appropriate location or that their removal has been accounted for in the application's functionality.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for any direct references to the old player methods that should now be accessed through playerImpl. rg --type ts 'play\(\)|pause\(\)|setVolume\(|getPosition\(\)|setPosition\(|isCaptionsSupported\(\)|setCaptionsEnabled\(|isCaptionsEnabled\(\)|getCaptionsTracks\(\)|setCaptionsTrack\('Length of output: 652
Script:
#!/bin/bash # Search for any direct references to the old player methods within Vue component files in the client directory. rg --type ts --glob '*.vue' 'play\(\)|pause\(\)|setVolume\(|getPosition\(\)|setPosition\(|isCaptionsSupported\(\)|setCaptionsEnabled\(|isCaptionsEnabled\(\)|getCaptionsTracks\(\)|setCaptionsTrack\(' client/src/componentsLength of output: 9903
Script:
#!/bin/bash # Check a sample of method references in OmniPlayer.vue to see if they are accessed through playerImpl or directly. rg --type ts --glob 'OmniPlayer.vue' 'play\(\)|pause\(\)|setVolume\(|getPosition\(\)|setPosition\(|isCaptionsSupported\(\)|setCaptionsEnabled\(|isCaptionsEnabled\(\)|getCaptionsTracks\(\)|setCaptionsTrack\(' client/src/components/playersLength of output: 3225
Script:
#!/bin/bash # Check the initialization of `player.value` in OmniPlayer.vue to determine what it refers to. rg --type ts 'player.value' client/src/components/players/OmniPlayer.vueLength of output: 1647
Script:
#!/bin/bash # Search for the assignment or creation of `player.value` in OmniPlayer.vue. rg --type ts 'player\s*=\s*' client/src/components/players/OmniPlayer.vueLength of output: 75
Script:
#!/bin/bash # Broaden the search to capture the context in which `player` is used within OmniPlayer.vue. # This includes looking for imports, props, emits, or component definitions related to `player`. rg --type ts 'player' client/src/components/players/OmniPlayer.vueLength of output: 2332
Verification successful
The methods
getAvailablePlaybackRates
,getPlaybackRate
, andsetPlaybackRate
have been removed from thePlyrPlayer
component, but the functionality related to playback rate appears to be managed elsewhere in the application. References to playback rate settings are found in server-side files (server/room.ts
) and in the API utilities (client/src/util/roomapi.ts
). The application maintains this functionality, albeit refactored or relocated from the originalPlyrPlayer
component.* 180-180: The `getCaptionsTracks` method is now being called from the `playerImpl` object. This is consistent with the refactoring and should work as long as the `playerImpl` object is correctly initialized and maintained.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify if the removed methods have been relocated or if their functionality is handled elsewhere. rg --type ts 'getAvailablePlaybackRates\(\)|getPlaybackRate\(\)|setPlaybackRate\('Length of output: 144
Script:
#!/bin/bash # Check for any references to the playback rate functionality that might indicate how it's being handled now. rg --type ts 'playbackRate|speed'Length of output: 470
Also applies to: 265-265
- 344-344: The spread operator is used to expose the methods of
playerImpl
on the component's instance. This is a clean way to expose these methods and should work well with the Vue composition API.client/src/components/players/OmniPlayer.vue (2)
- 139-150: The
MediaPlayer
interface has been updated to allow theplay
andpause
methods to return eithervoid
orPromise<void>
. This change accommodates different browser behaviors regarding promise support for these operations and is a good enhancement for compatibility.- 222-222: The
play
andpause
functions within thedefineComponent
have been updated to reflect the changes in theMediaPlayer
interface. They now correctly handle the possibility of returning aPromise<void>
. Ensure that the rest of the application correctly handles these methods' potential to return a promise.Also applies to: 228-228
Verification successful
The
play()
andpause()
methods inroomapi.ts
do not need to handle promises as the underlyingsend
method they call is synchronous, returningvoid
. The review comment's concern about handling the potential for these methods to return a promise does not apply to the implementation inroomapi.ts
.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Check for proper handling of play and pause methods that may return a promise. rg --type ts 'play\(\)|pause\(\)'Length of output: 502
Script:
#!/bin/bash # View the implementation of play() and pause() in roomapi.ts cat client/src/util/roomapi.ts | grep -A 10 'play()' cat client/src/util/roomapi.ts | grep -A 10 'pause()'Length of output: 491
Script:
#!/bin/bash # Check the implementation of the send method in the connection object within roomapi.ts cat client/src/util/roomapi.ts | grep -A 20 'connection ='Length of output: 453
Script:
#!/bin/bash # View more of the context around the connection object in roomapi.ts cat client/src/util/roomapi.ts | grep -B 5 -A 15 'this.connection ='Length of output: 449
Script:
#!/bin/bash # Find the file where OttRoomConnection is defined and view the implementation of the send method rg --type ts 'class OttRoomConnection' -l | xargs grep 'send('Length of output: 336
related to #1225