Home > Mobile >  Qt the slider do players progress bar
Qt the slider do players progress bar

Time:05-13

Why video playback progress bar will be stuck after several times not to drag, thread is not stuck, just where is the progress bar stop, simply press the other controls the progress bar to return to normal
Void Video_Player: : run ()
{
Mat frame;
ThreadFlag=true;
while(! Stop_Play)
{
If (pos!=1)
{
The capture - & gt; Set (1, pos);
Pos=1;
}

if (! Is_Pase)
{
Bool ret=the capture - & gt; Read (frame);

If (frame. The empty ())
{
continue;
}

Long I=the capture - & gt; Get (1);
Show_img (frame, video_label);
QMetaObject: : invokeMethod (the slider, "setValue", Qt: : QueuedConnection, Q_ARG (int, I));
QMetaObject: : invokeMethod (label_pos, setText, Qt: : QueuedConnection, Q_ARG (QString, QString: : number (I)));
Sleep (speed);
}
}
ThreadFlag=false;
}
This is a frame of a progress bar with video player frame mobile code
Void Video_Player: : show_img (Mat image, QLabel * label)
{
//on the label shows opencv image
CV: : cvtColor (image, image, CV_BGR2RGB);
QImage image1=QImage (static_cast & lt; Uchar * & gt; (image data), image cols, image. Rows, QImage: : Format_RGB888);
QPixmap pixmap=QPixmap: : fromImage (image1);
Int with=label - & gt; Width ();
Int height=label - & gt; Height ();
QPixmap fitpixmap=pixmap. Scaled (with height, Qt: : IgnoreAspectRatio, Qt: : SmoothTransformation);
Video_label - & gt; The clear ();
Video_label - & gt; The update ();
The label - & gt; SetPixmap (fitpixmap);
}
This is a MAT the code shown on the label

CodePudding user response:

Open a secondary thread in real time to refresh the progress bar, hope to adopt, can focus on direct messages I don't understand,
  •  Tags:  
  • Qt
  • Related