Add setPlayRate for UIVideoPlayer for windows only

This commit is contained in:
halx99 2022-04-28 12:14:08 +08:00
parent 15cf113e75
commit 4a35a8f8ae
4 changed files with 24 additions and 3 deletions

View File

@ -203,6 +203,8 @@ void VideoPlayer::setKeepAspectRatioEnabled(bool enable)
}
}
void VideoPlayer::setPlayRate(float fRate) {}
void VideoPlayer::play()
{
if (!_videoURL.empty())

View File

@ -339,6 +339,8 @@ void VideoPlayer::setStyle(StyleType style)
}
}
void VideoPlayer::setPlayRate(float fRate) {}
void VideoPlayer::draw(Renderer* renderer, const Mat4& transform, uint32_t flags)
{
cocos2d::ui::Widget::draw(renderer, transform, flags);
@ -359,9 +361,9 @@ void VideoPlayer::draw(Renderer* renderer, const Mat4& transform, uint32_t flags
auto uiTop = (frameSize.height / 2 - (rightTop.y - winSize.height / 2) * glView->getScaleY()) / scaleFactor;
[((UIVideoViewWrapperIos*)_videoContext) setFrame:
uiLeft:uiTop:(rightTop.x - leftBottom.x) * glView->getScaleX() /
scaleFactor:((rightTop.y - leftBottom.y) * glView->getScaleY() /
scaleFactor)];
uiLeft:uiTop:(rightTop.x - leftBottom.x) * glView->getScaleX() /
scaleFactor:((rightTop.y - leftBottom.y) * glView->getScaleY() /
scaleFactor)];
}
# if CC_VIDEOPLAYER_DEBUG_DRAW

View File

@ -521,6 +521,16 @@ void VideoPlayer::setKeepAspectRatioEnabled(bool enable)
}
}
void VideoPlayer::setPlayRate(float fRate)
{
if (!_videoURL.empty())
{
auto vplayer = reinterpret_cast<PrivateVideoDescriptor*>(_videoContext)->_vplayer;
if (vplayer)
vplayer->SetRate(fRate);
}
}
void VideoPlayer::play()
{
if (!_videoURL.empty())

View File

@ -135,6 +135,13 @@ public:
*/
virtual void setStyle(StyleType style);
/**
* Sets play rate, currently, only supported by windows
*
* @param fRate the rate for play, default 1.0
*/
virtual void setPlayRate(float fRate);
/**
* Starts playback.
*/