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

Pzhlkj6612 new slider and better player #49

Merged
merged 14 commits into from
Jan 18, 2020

Conversation

BensonLaur
Copy link
Member

No description provided.

pzhlkj6612 and others added 14 commits January 7, 2020 19:03
It seems that the responding speed of the audio playing has been improved.
It seems that `read_header()` in av_format.h is the source of the noise.
branch name: remove_useless_initialization_of_SDL_subsystem
The "PlayThread's logic" are the functions `audio_decode_frame()` and `packet_queue_get()`.

1. `audio_clock` will store the position in millisecond and `qint64` type.
2. the 1e8 times attempts is NOT ok.
3. `packet_queue_get()` should return `-1` if something goes wrong.
1. New `BesSlider`
    1.1. Click is on the handle
        1.1.1. The relative position between the mouse and the center of handle (`click_pos_offset`) is calculated and stored when the handle is dragged. So the handle will move relative to the mouse and keep a certain offset (`click_pos_offset`) instead of placing its center under the mouse. This is a Netease Music style.
    1.2. Click is NOT on the handle
        1.2.1. Use `BesSliderStyle` to change the positioning method from 'stepping' to 'directness'.
        1.2.2. The new positioning method makes the click-and-drag operation can be performed correctly, because `QSlider::sliderPressed`, `QSlider::sliderMoved` and `QSlider::sliderReleased` signals will be emitted correctly when the click is not on the handle.
    1.3. "Where is my mouse ?"
        1.3.1. Use `subControlRect` to determine the range of handle and whether the mouse is over the handle.
        1.3.2. Remove old logic related to the above, including `enterEvent(QEvent*)` and `leaveEvent(QEvent*)` functions.
        1.3.3. Set `setMouseTracking(true)`. As long as `enableMouseEvt` is equal to `true`, whether or not the mouse is pressed, when the mouse hovers over the handle, its cursor style will be `Qt::PointingHandCursor`, otherwise it will be `Qt::ArrowCursor` (set by `unsetCursor()`).

2. `BottomWidget` and `MusicPlayer`
    2.1. About the refined logic
        2.1.1. Even if only the handle of `sliderSong` is clicked, the seeking operation will be performed. `audioOriginalPos` is dead. This is a Netease Music style.
        2.1.2. Existing logic restricts clicks to be performed on `sliderSong` only when `enableMouseEvt` is equal to `true`, so the redundant judgments have been removed.
    2.2. The position of the audio is playing
        2.2.1. `AdjustingPos` will be set `true` when `sliderSong` is pushed down.
        2.2.2. `MusicPlayer` will tell `BottomWidget` and `AdjustingPos` will be set `false` when the seeking operation is finished (`PlayThread::seekFinished()` and `MusicPlayer::seekFinished()`).
        2.2.3. So, It's guaranteed that the current position will only be refreshed by `MusicPlayer` if no mouse action is applied to `sliderSong`.
1. `BottomWidget` will reset `AdjustingPos` to `false` and ready for next seeking operation.
2. End the player by setting `AGSStatus` to `AGS_FINISH`.
1. Any interval of the timer is unreasonable. Higher values send too many indentical positions, while lower values make the positions inaccurate.
2. Now when the `PlayThread::audio_decode_frame()` function is called, `PlayThread` will notify `MusicPlayer` to send the position.
3. `PlayThread::positionChanged()` signal does not contain the value of the current position.
4. When `MusicPlayer` receives the signal `PlayThread::positionChanged()`, the `MusicPlayer::sendPosChangedSignal()` function will be called.
5. The `MusicPlayer::positionChanged(qint64)` signal contains the position which obtained from `playThread->getCurrentTime()`.
6. The pause-and-play operation of the timer in function `MusicPlayer::seek(quint64)` is useless and misleading.
1. If the player is paused, this call is useless.
1. Implement the keeping pause after seeking.
2. When the player is paused, the new position should be sent on time after a seeking which is performed by the program.
1. The function `av_seek_frame()` will get error with `AVSEEK_FLAG_ANY` method, especially when somebody wants to seek to the end of the audio.
2. So, the player will try seeking again with `AVSEEK_FLAG_BACKWARD` method.
@BensonLaur BensonLaur merged commit 1de9513 into master Jan 18, 2020
@BensonLaur BensonLaur deleted the pzhlkj6612-new_slider_and_better_player branch February 15, 2020 09:14
@pzhlkj6612
Copy link
Member

Related PR: #47

@pzhlkj6612 pzhlkj6612 added this to the Next Release milestone Feb 24, 2020
@pzhlkj6612 pzhlkj6612 added the _Refactor the player 整个播放逻辑需要重做。 label Feb 24, 2020
@BensonLaur BensonLaur mentioned this pull request Feb 29, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
_Refactor the player 整个播放逻辑需要重做。
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants