简体   繁体   中英

Seek to a position before playing video

I want to seek to a position before playing a video :

player= new VlcMediaPlayer(instance);
player->setPosition(pos);
player->setTime(time);
player->play();

but it does not work and instead I used this code:

player= new VlcMediaPlayer(instance);
player->play();
player->setPosition(pos);
player->setTime(time);

it now works but first plays the video (and shows some frames of the begining of the file) , is there any way to seek to a position before playing?

I don't know what VlcMediaPlayer is but seeking in libvlc is done with libvlc_media_player_set_time call. And as you can see in the documentation it requires to be called on the video being played . So you have to call play before you can call seek . But you can pause right after the play and then seek . That should do the job.

The link to the libvlc forum containing the similar question.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM