-
Notifications
You must be signed in to change notification settings - Fork 0
Atualiza funções do player ios #5
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
Conversation
Summary of ChangesHello @jdavifranco, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed! Este pull request realiza uma atualização fundamental nas funções do player iOS, substituindo a implementação existente baseada em Highlights
🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console. Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here. You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension. Footnotes
|
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.
Code Review
Este PR faz uma refatoração importante, migrando do MPMusicPlayerController para o AVPlayer, o que é uma ótima melhoria para flexibilidade e controle. A implementação está, em geral, muito boa.
Identifiquei alguns pontos que precisam de atenção:
- Há uma possível inconsistência de tipo na referência ao
AudioplayersDarwinPlugin. - A lógica nas funções
stopereleasecontém uma condição de corrida e pode ser simplificada para evitar complexidade e bugs.
Forneci sugestões de código para corrigir esses problemas. Fora isso, o código está bem estruturado e as mudanças são positivas.
|
|
||
| init( | ||
| reference: SwiftAudioplayersDarwinPlugin, | ||
| reference: AudioplayersDarwinPlugin, |
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.
O tipo do parâmetro reference no init (e da propriedade na linha 24) foi alterado de SwiftAudioplayersDarwinPlugin para AudioplayersDarwinPlugin. No entanto, a instância de WrappedMediaPlayer é criada em SwiftAudioplayersDarwinPlugin.swift passando self, que é do tipo SwiftAudioplayersDarwinPlugin.
Isso pode causar um erro de compilação se SwiftAudioplayersDarwinPlugin não for uma subclasse de AudioplayersDarwinPlugin. Parece que o tipo correto deveria ser mantido como SwiftAudioplayersDarwinPlugin para garantir a compatibilidade.
| reference: AudioplayersDarwinPlugin, | |
| reference: SwiftAudioplayersDarwinPlugin, |
| func stop(completer: Completer? = nil) { | ||
| pause() | ||
| seek(time: Float(0), completer: completer) | ||
| seek(time: toCMTime(millis: 0), completer: completer) | ||
| if releaseMode == ReleaseMode.release { | ||
| release(completer: completer) | ||
| } | ||
| } | ||
|
|
||
| func release(completer: Completer? = nil) { | ||
| stop { | ||
| self.id = nil | ||
| completer?() | ||
| if self.isPlaying { | ||
| // Avoid loop of stop and release | ||
| stop { | ||
| self.reset() | ||
| completer?() | ||
| } | ||
| return | ||
| } | ||
| self.reset() | ||
| completer?() | ||
| } |
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.
A lógica atual nas funções stop e release apresenta alguns problemas:
- Condição de Corrida: Em
stop(), as funçõesseek()erelease()são chamadas de forma concorrente, masseek()é assíncrona. Isso pode levar a um comportamento imprevisível. - Callback Duplicado: Ambas as funções
seek()erelease()podem chamar ocompleter, o que resultaria na execução duplicada do callback. - Dependência Circular: A função
release()chamastop(), que por sua vez pode chamarrelease(), criando uma dependência circular que torna o código mais complexo e propenso a erros.
Sugiro refatorar ambas as funções para um fluxo mais claro e robusto, corrigindo esses problemas.
func stop(completer: Completer? = nil) {
pause()
if releaseMode == .release {
release(completer: completer)
} else {
seek(time: toCMTime(millis: 0), completer: completer)
}
}
func release(completer: Completer? = nil) {
if isPlaying {
pause()
}
// É preciso buscar o início antes de resetar, pois o reset remove o item atual do player.
seek(time: toCMTime(millis: 0)) {
self.reset()
completer?()
}
}da964f7 to
038c5f2
Compare
Description
WrappedMediaPlayer.swiftcom as mudanças na lib original.Como testar?
Issues relacionadas:
https://github.com/StudioSol/CifraClubMobile/pull/5865