Skip to content
Snippets Groups Projects
Commit e55a0510 authored by Andrey Kleshchev's avatar Andrey Kleshchev
Browse files

SL-16510 VLC time slider sometimes does not work

parent 3d96d00b
No related branches found
No related tags found
No related merge requests found
......@@ -1527,6 +1527,7 @@ void LLPluginClassMedia::seek(float time)
LLPluginMessage message(LLPLUGIN_MESSAGE_CLASS_MEDIA_TIME, "seek");
message.setValueReal("time", time);
mCurrentTime = time; // assume that it worked and we will receive an update later
sendMessage(message);
}
......
......@@ -93,8 +93,8 @@ class MediaPluginLibVLC :
bool mIsLooping;
float mCurTime;
float mDuration;
F64 mCurTime;
F64 mDuration;
EStatus mVlcStatus;
};
......@@ -606,11 +606,27 @@ void MediaPluginLibVLC::receiveMessage(const char* message_string)
}
else if (message_name == "seek")
{
if (mDuration > 0)
{
F64 normalized_offset = message_in.getValueReal("time") / mDuration;
libvlc_media_player_set_position(mLibVLCMediaPlayer, normalized_offset);
}
if (mLibVLCMediaPlayer)
{
libvlc_time_t time = 1000.0 * message_in.getValueReal("time");
libvlc_media_player_set_time(mLibVLCMediaPlayer, time);
time = libvlc_media_player_get_time(mLibVLCMediaPlayer);
if (time < 0)
{
// -1 if there is no media
mCurTime = 0;
}
else
{
mCurTime = (F64)time / 1000.0;
}
if (!libvlc_media_player_is_playing(mLibVLCMediaPlayer))
{
// if paused, won't trigger update, update now
setDirty(0, 0, mWidth, mHeight);
}
}
}
else if (message_name == "set_loop")
{
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment