I. Introduction to the environment

Operating system: Win10 64-bit

QT version: QT5.12.6

** compiler: ** MinGW 32

Player bottom interface: MDK-SDK library

Complete engineering source download address (download to compile run) : download.csdn.net/download/xi…

Ii. Introduction of player functions

1. Supports incoming video playback on the cli

2. Support image rotation playback

3. You can view media information

4. GPU accelerated decoding is supported

5. Support fast forward and fast rewind

6. Support preview screen (place the mouse on the progress bar to view the screen thumbnail)

7. Support single frame playback, that is, click to switch the screen frame by frame

8. Support picture taking and screenshot

9. Reset to the video home page

10. Support volume adjustment

11. Support dragging files to the window to play

12. By default, the video will not play automatically. Automatically displayed in the first frame, the video stays in the last frame.

13. Supports playing audio files. Can display audio file cover.

14. Double click to zoom in. Full-screen playback

15. Right-click the mouse or space bar to switch between pause and play

16. Place the mouse on the progress bar to realize the screen preview

17. Scroll bar supports click to jump or drag.

18. Support volume adjustment, dragging or clicking.

19. Supports mute switching.

20. Add a playlist. Select the check box in the lower right corner to enable the playlist. In the playlist, the right mouse button can add and delete playlist files.

21. Save the playlist when you exit, and automatically load the playlist when you open the software next time. The next time you start the software, if the playlist file path exists, the first file is automatically selected to play.

Iii. Operation effect of player

Normal playback interface:

Play MP3 files, you can get cover album open:

You can drag files directly into the player window to play:

The check box in the lower right corner opens the playlist:

In the playlist, click the right mouse button to add play files, delete files:

Double click the left mouse button to play the screen in full screen, double click again to restore the interface:

You can preview the video by placing the mouse on the scroll bar:

Click the double speed button in the toolbar and select Double speed play:

Click the Rotate button in the toolbar to rotate the image:

Click the “Take photo” button in the toolbar to save the current video frame to the same directory as the video player:

The mouse wheel can scroll forward or backward to play the picture in a single frame:

Click the next and previous buttons on the toolbar to switch the currently playing video according to the playlist:

Click the reset button to replay:

Click the speaker of the toolbar to switch the mute state, drag or click the slider to adjust the volume:

Support fast forward, fast rewind:

Click the button to load the video:

Iv. Introduction to MDK-SDK

Github homepage: github.com/wang-bin/md…

Features

  • Simple and powerful API set
  • Cross platform: Windows, UWP, Linux, macOS, Android, iOS, Raspberry Pi
  • Hardware accelerated decoding and 0-copy GPU rendering for all platforms
  • OpenGL, D3D11, Vulkan and Metal rendering w/ or w/o user provided context
  • Integrated with any gui toolkits or apps via OpenGL, D3D11, Vulkan and Metal (OBS, Qt, SDL, glfw, SFML etc.) easily
  • Seamless/Gapless media and bitrate switch for any media
  • HDR rendering in GPU
  • Optimized Continuous seeking. As fast as mpv, but much lower cpu, memory and gpu load. Suitable for timeline preview
  • Smart FFmpeg Runtime. See github.com/wang-bin/md…

Mdk-sdk API usage: **** github.com/wang-bin/md…

* * MDK – SDK SDK package (CSDN) – as the current version is the latest: * * download.csdn.net/download/xi…

Examples of mdK-SDK use (GitHub): github.com/wang-bin/md…

Five, the project source code

Complete engineering source download address (download to compile run) : download.csdn.net/download/xi…

UI main window logic code:

#include "widget.h"
#include "ui_widget.h"

Widget* Widget::pThis = nullptr;

Widget::Widget(QString filename,QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);
    pThis=this;

    setWindowFlags(Qt::FramelessWindowHint);

    setAcceptDrops(true);

    setFocusPolicy(Qt::StrongFocus);

    // Set the window title name
    this->setWindowTitle("Video player");

    // Get the status of the title bar
    win_flag=windowFlags(a);// Load the stylesheet
    SetStyle(":/resource/QMDK_VideoPlayer.qss");

    / / QMDK initialization
    QMDK_InitConfig(a);//UI interface related initialization
    UI_InitConfig(a);// If the video file passed in by the constructor is loaded directly
    if(! filename.isEmpty())
    {
        load_video_file(0,filename);
    }

    isPressedWidget=false;

    // Set the focus
    ui->AV_player->setFocus(a);// The window is displayed in the center of the screen
    QDesktopWidget *desktop = QApplication::desktop(a);move((desktop->width() -this->width/ ())2,(desktop->height() -this->height/ ())2);

    // Load the configuration
    LoadConfig(a);// Set the entries selected by default
    if(ui->listWidget_videoData->count(a) >0)
    {
        ui->listWidget_videoData->setCurrentRow(0);

        // Load the video file
        QTimer::singleShot(200.this.SLOT(load_updateCaption()));
    }
}


Widget::~Widget()
{
    delete ui;
}


void Widget::load_updateCaption(a)
{
    QString text=ui->listWidget_videoData->item(0) - >text(a);qDebug() < <"Load video file :"<<text;
    load_video_file(false,text);
}

/* Project: QtAV_VideoPlayer Date: 2021-03-25 author: DS xiaolong environment: Win10 QT5.12.6 MinGW32 function: load stylesheet */
void Widget::SetStyle(const QString &qssFile)
{
    QFile file(qssFile);
    if (file.open(QFile::ReadOnly))
    {
        QByteArray qss=file.readAll(a); qApp->setStyleSheet(qss);
        file.close();
    }
}


/* Project: QtAV_VideoPlayer Date: 2021-03-25 author: DS small Long ge environment: Win10 QT5.12.6 MinGW32 function: UI interface initialization */
void Widget::UI_InitConfig(a)
{
    // Set the volume slider range
    ui->horizontalSlider_AudioValue->setMaximum(100);
    ui->horizontalSlider_AudioValue->setMinimum(0);

    // Set the playback speed
    ui->MediaSpeedBtn->setCheckable(true);
    m_TimeSpeedGrp = new QActionGroup(this);
    QStringList strSpeedItems;
    strSpeedItems << tr("X 0.5") < <tr("X 0.75") < <tr("X 1.0") < <tr("X 1.25") < <tr("X 1.5");
    float speeds[] = { 0.5.0.75.1.0.1.25.1.5};

    for (int i = 0; i < strSpeedItems.size(a); i++) { QAction *pSpeedItem = m_SpeedMenu.addAction(strSpeedItems.at(i));
        pSpeedItem->setData(QVariant::fromValue(speeds[i]));
        pSpeedItem->setCheckable(true);
        m_TimeSpeedGrp->addAction(pSpeedItem);
        if (i == 2)
        {
            pSpeedItem->setChecked(true); }}connect(m_TimeSpeedGrp, SIGNAL(triggered(QAction *)), this.SLOT(slot_onSetTimeSpeed(QAction *)));


    An event filter is an object that receives all events sent to this object
    ui->horizontalSlider_PlayPosition->installEventFilter(this);
    ui->horizontalSlider_AudioValue->installEventFilter(this);

    // The status information is initialized
    MediaInfo.state=MEDIA_NOLOAD;

    // Tooltip
    ui->toolButton_load->setToolTip(tr("Load the video, or you can drag the video directly into the window."));

    ui->MediaPrevBtn->setToolTip(tr("Retreat quickly"));
    ui->MediaPlayBtn->setToolTip(tr("Fast forward"));
    ui->MediaPauseBtn->setToolTip(tr("Pause/continue"));
    ui->MediaSpeedBtn->setToolTip(tr("Double speed selection"));
    ui->MediaResetBtn->setToolTip(tr("Reset"));
    ui->MediaSnapshotBtn->setToolTip(tr("Take a picture (save in PNG in the program run directory)"));
    ui->VolumeBtn->setToolTip(tr("Mute Switch"));
    ui->checkBox_video_list->setToolTip(tr("Show video list"));
    ui->toolButton_pgup->setToolTip(tr("Play the last media."));
    ui->toolButton_pgDn->setToolTip(tr("Let's go to the next media."));
    ui->MediaRotateBtn->setToolTip(tr("Rotate image"));
    ui->toolButton_about->setToolTip(tr("About"));

    // Not displayed by default
    ui->listWidget_videoData->setVisible(false);

    // Play progress bar slider initialization
    connect(ui->horizontalSlider_PlayPosition, SIGNAL(onLeave()), SLOT(onTimeSliderLeave()));
    connect(ui->horizontalSlider_PlayPosition, SIGNAL(onHover(int.int)), SLOT(onTimeSliderHover(int.int)));
    connect(ui->horizontalSlider_PlayPosition, SIGNAL(sliderMoved(int)), SLOT(seek(int)));
    connect(ui->horizontalSlider_PlayPosition, SIGNAL(sliderPressed()), SLOT(seek()));

    this->setMouseTracking(true);

    /* Initializes the video list from the right menu */
    Grp_In_ListWidget = new QActionGroup(this);
    QAction *action_DeleteSelect_In_ListWidget = menu_In_ListWidget.addAction(tr("Delete selected"));
    QAction *action_ClearAll_In_ListWidget = menu_In_ListWidget.addAction(tr("Delete all"));
    QAction *action_AddFile_In_ListWidget = menu_In_ListWidget.addAction(tr("Add file"));
    action_DeleteSelect_In_ListWidget->setData(MENU_DEL_SELECT); // Delete selected
    action_ClearAll_In_ListWidget->setData(MENU_DEL_ALL); // Delete all
    action_AddFile_In_ListWidget->setData(MENU_ADD_FILE); // Add a file
    Grp_In_ListWidget->addAction(action_DeleteSelect_In_ListWidget); // Add to group
    Grp_In_ListWidget->addAction(action_ClearAll_In_ListWidget); // Add to group
    Grp_In_ListWidget->addAction(action_AddFile_In_ListWidget); // Add to group
    connect(Grp_In_ListWidget, SIGNAL(triggered(QAction *)), this.SLOT(slot_onListWidgetMenu(QAction *)));

   /* Set the contextMenuPolicy property of QListWidget, otherwise the right menu cannot be displayed */
    ui->listWidget_videoData->setProperty("contextMenuPolicy", Qt::CustomContextMenu);

    /* Bind the right button to display the menu: after the right button is clicked, the slot function is executed. The slot function is responsible for popup the right button menu */
    connect(ui->listWidget_videoData, SIGNAL(customContextMenuRequested(const QPoint &)),
        this.SLOT(onCustomContextMenuRequested(const QPoint &)));


    timer = new QTimer(this);
    connect(timer, SIGNAL(timeout()), this.SLOT(timeout_update()));


    // Image rotation direction
    m_RotateGrp = new QActionGroup(this);
    QStringList strDegrees;
    strDegrees << tr("0 ~") < <tr("90~") < <tr("180~") < <tr("270~");
    int Degrees[] = {0.90.180.270 };
    for (int i = 0; i < strDegrees.size(a); i++) { QAction *pItem = m_RotateMenu.addAction(strDegrees.at(i));
        pItem->setData(QVariant::fromValue(Degrees[i]));
        pItem->setCheckable(true);
        m_RotateGrp->addAction(pItem);
    }
    connect(m_RotateGrp, SIGNAL(triggered(QAction *)), this.SLOT(slot_onMediaRotate(QAction *)));
}


Win10 QT5.12.6 MinGW32 function: event handler function */
void Widget::onCustomContextMenuRequested(const QPoint &pos)
{
    qDebug() < <"Pop up right-click menu";
    QAction *pSelect = menu_In_ListWidget.exec(QCursor::pos());
    if (pSelect == nullptr)
        return;
}


/* Project: QtAV_VideoPlayer Date: 2021-03-25 author: DS xiaolong environment: Win10 QT5.12.6 MinGW32 function: QMDK initialization configuration */

void Widget::QMDK_InitConfig(a)
{
    //SetGlobalOption("MDK_KEY", "10453B8F2140865027CEDD6FDF846D940CA738BE72FE5EE1397DF61714CAAA2A185B72EEC1F781FD5E1FA9BB0AB739E35CCC793F0EBC3FD0182D61E E56E59E08EFBAC47021408D50D8312290207B926B0CA730D91E982991551C8FD75973CAF6B1C4573E7CBF9467F3BAF34F8D9F0A8AE239503BFB1B7B0 2E4EB0F2121E5D408");

    // Associate the double-click event
    connect(ui->AV_player, &QMDKWidget::ss_VideoWidgetEvent, this,&Widget::slot_VideoWidgetEvent);

    m_preview=new QMDKWidget(ui->AV_player);

    m_preview->setVisible(false);
}


/* project: QtAV_VideoPlayer Date: 2021-03-25 author: DS small Dragon ge environment: Win10 QT5.12.6 MinGW32 function: QString file_path This parameter can be passed in the file name because the window supports dragging and dropping files in. Return value: true successful false Failed */
bool Widget::load_video_file(bool flag,QString file_path)
{
    if(flag==false)
    {
        QString filename=file_path;
        if(filename.isEmpty())
        {
             filename=QFileDialog::getOpenFileName(this."Select video to play"."D:/".tr("*.mp4 *.wmv *.*"));
        }
        strncpy(video_name,filename.toUtf8().data(),sizeof(video_name));
    }

    // Check whether the file exists
    if(QFileInfo::exists(video_name)==false)
    {
        return false;
    }
    else
    {
        MediaInfo.state=MEDIA_LOAD;
        MediaInfo.mediaName=video_name;
    }

    // Set the media file to play
    ui->AV_player->stop(a); ui->AV_player->setMedia(video_name);
    ui->AV_player->play(a);// Preview window
    m_preview->stop(a); m_preview->setMedia(video_name);
    m_preview->prepreForPreview(a); m_preview->setMute(true);
    QThread::msleep(100);

    // Set the total time
    ui->label_Total_Time->setText(QTime(0.0.0.0).addMSecs(int(ui->AV_player->duration())).toString(QString::fromLatin1("HH:mm:ss:zzz")));

    // Set the progress bar slider range
    ui->horizontalSlider_PlayPosition->setMinimum(0);
    ui->horizontalSlider_PlayPosition->setMaximum(ui->AV_player->duration());

    // Set the progress bar to 0 each time a new file is loaded
    ui->horizontalSlider_PlayPosition->setValue(0);

    qDebug() < <"Stop the original video";
    ui->AV_player->pause(a);// Set the name of the current playing video
    QFileInfo info(video_name);
    ui->label_FileName->setText(QString("% 1").arg(info.fileName()));

    // Set button state -- pause state
    ui->MediaPauseBtn->setChecked(true);

    return true;
}


/* project: QtAV_VideoPlayer Date: 2021-03-25 author: DS small Rongge environment: Win10 QT5.12.6 MinGW32 function: load video file */
void Widget::on_toolButton_load_clicked(a)
{
    qDebug() < <"Loading video file status :"<<load_video_file(0."");
}


/* project: QtAV_VideoPlayer date: 2021-03-25 作者: DS small ringer environment: win10 QT5.12.6 MinGW32 function: pause play */
void Widget::on_MediaPauseBtn_clicked(a)
{
    bool bPause=ui->MediaPauseBtn->isChecked(a);if(bPause == true)
    {
        ui->AV_player->pause(a); timer->stop(a); }else
    {
        ui->AV_player->play(a); timer->start();
    }
}


/* project: QtAV_VideoPlayer Date: 2021-03-25 author: DS small Long ge environment: win10 QT5.12.6 MinGW32 function: restart play */
void Widget::on_MediaResetBtn_clicked(a)
{
    // Accentuate new start playback
    load_video_file(true."");
}

/* project: QtAV_VideoPlayer Date: 2021-03-25 author: DS small Rongge environment: Win10 QT5.12.6 MinGW32 function: quick retire play */
void Widget::on_MediaPrevBtn_clicked(a)
{
    ui->AV_player->seek(ui->AV_player->position(a)- 10000.);
}

/* project: QtAV_VideoPlayer Date: 2021-03-25 author: DS small Dragon ge environment: Win10 QT5.12.6 MinGW32 function: fast forward play */
void Widget::on_MediaPlayBtn_clicked(a)
{
    ui->AV_player->seek(ui->AV_player->position() +10000);
}


/* project: QtAV_VideoPlayer Date: 2021-03-25 author: DS xiaolong Environment: Win10 QT5.12.6 MinGW32 function: volume Settings */
void Widget::on_VolumeBtn_clicked(a)
{
    bool checked=ui->VolumeBtn->isChecked(a);/ / mute
    ui->AV_player->setMute(checked);
}


/* project: QtAV_VideoPlayer Date: 2021-03-25 author: DS xiaolong Environment: Win10 QT5.12.6 MinGW32 function: volume Settings */
void Widget::on_horizontalSlider_AudioValue_valueChanged(int value)
{
    ui->AV_player->setVolume(float(value/10.0));
}


/* project: QtAV_VideoPlayer date: 2021-03-25 作者: DS small ringer environment: win10 QT5.12.6 MinGW32 function: play speed set menu select */
void Widget::slot_onSetTimeSpeed(QAction *action)
{
    action->setChecked(true);
    ui->MediaSpeedBtn->setToolTip(action->text());
    ui->MediaSpeedBtn->setText(action->text());

    // Set speed normal speed is 1.0
     ui->AV_player->setPlaybackRate(float(action->data().toFloat()));
}


/* project: QtAV_VideoPlayer date: 2021-03-25 作者: DS small ringer environment: win10 QT5.12.6 MinGW32 function: click the speed set button */
void Widget::on_MediaSpeedBtn_clicked(a)
{
    QPoint ptWgt = ui->MediaSpeedBtn->mapToGlobal(QPoint(0.0));
    ptWgt -= QPoint(10.180);
    QAction *pSelect = m_SpeedMenu.exec(ptWgt);
    if (pSelect == nullptr)
        return;
}


/* project: QtAV_VideoPlayer date: 2021-03-25 作者: DS small dragon ge environment: win10 QT5.12.6 MinGW32 function: display menu */
void Widget::slot_onListWidgetMenu(QAction *action)
{
    if (action == nullptr)
        return;
    // Get the serial number pressed
    MENU_ITEM item = MENU_ITEM(action->data().toInt());

    // Delete selected
    if (item == MENU_DEL_SELECT)
    {
        /* Get the currently selected Item*/
        QList<QListWidgetItem*> items = ui->listWidget_videoData->selectedItems(a);if (items.count(a) >0)
        {
            foreach(QListWidgetItem* var, items)
            {
                ui->listWidget_videoData->removeItemWidget(var);
                items.removeOne(var);
                deletevar; }}qDebug() < <"Delete selected";
    }
    // Delete all
    else if(item == MENU_DEL_ALL)
    {
        int counter = ui->listWidget_videoData->count(a); QListWidgetItem *item;for(int index = 0; index <counter; index++) { item = ui->listWidget_videoData->takeItem(0);
            delete item;
        }
        qDebug() < <"Delete all";
    }
    // Add a file
    else if(item == MENU_ADD_FILE)
    {
        QStringList filenamelist=QFileDialog::getOpenFileNames(this."Select files to add"."D:/".tr("*. *"));
        if(filenamelist.count(a) >0) ui->listWidget_videoData->addItems(filenamelist); // Add to the list
        qDebug() < <"Add file"; }}/* project: QtAV_VideoPlayer Date: 2021-03-24 author: DS small Long ge environment: Win10 QT5.12.6 MinGW32 function: click the screenshot button */
void Widget::on_MediaSnapshotBtn_clicked(a)
{
    ui->AV_player->snapshot(a); }void Widget:: onTimeSliderHover(int pos, int value)
{
    QPoint gpos=mapToGlobal(ui->horizontalSlider_PlayPosition->pos() + QPoint(pos, ui->AV_player->height(a) /5 *5));

   // qDebug()<<"onTimeSliderHover(int pos, int value) value"<<value;
    QToolTip::showText(gpos, QTime(0.0.0).addMSecs(value).toString(QString::fromLatin1("HH:mm:ss")));
    m_preview->seek(value);
    int w=ui->AV_player->width(a) /5;
    int h=ui->AV_player->height(a) /5;
    m_preview->resize(w,h);

    QPoint p;
    p.setY(ui->AV_player->height(a) /6 *5- 30);
    p.setX(pos);
    m_preview->move(p);
    m_preview->show(a); }void Widget::onTimeSliderLeave(a)
{
    if (m_preview && m_preview->isVisible())
        m_preview->hide(a); }void Widget::seek(int value)
{
// if(! ui->AV_player->isPaused())
/ / {
// ui->AV_player->pause();
/ /}

    ui->AV_player->seek(value);
    m_preview->seek(value);
    m_preview->resize(ui->AV_player->width(a) /5,ui->AV_player->height(a) /5);
    m_preview->show(a); ui->label_current_Time->setText(QTime(0.0.0.0).addMSecs(int(value)).toString(QString::fromLatin1("HH:mm:ss:zzz")));
}


void Widget::seek(a)
{
    qDebug() < <"seek()";
    seek(ui->horizontalSlider_PlayPosition->value());
}


void Widget::dragEnterEvent(QDragEnterEvent *e)
{
    if (e->mimeData() - >hasUrls())
    {
        e->acceptProposedAction();
    }
}

void Widget::dropEvent(QDropEvent *e)
{
    foreach (const QUrl &url, e->mimeData() - >urls())
    {
        QString fileName = url.toLocalFile(a);qDebug() < <"Name of file dragged in :" << fileName;
        // Load the video file
        load_video_file(false,fileName); }}Win10 QT5.12.6 MinGW32 function: double-click the list to play video */
void Widget::on_listWidget_videoData_itemDoubleClicked(QListWidgetItem *item)
{
    // Load the video file
    load_video_file(false,item->text());
}


Win10 QT5.12.6 MinGW32 function: display video list */
void Widget::on_checkBox_video_list_clicked(bool checked)
{
    if(checked)
    {
        / / show
        ui->listWidget_videoData->setVisible(true);
    }
    else
    {
        / / no show
        ui->listWidget_videoData->setVisible(false); }}/* project: QtAV_VideoPlayer Date: 2021-03-25 author: DS small Dragon ge environment: Win10 QT5.12.6 MinGW32 function: video event processing */
void Widget::slot_VideoWidgetEvent(int type)
{
    //type =1 Double-click and press
    //type =2 Press the left mouse button
    Type =3 Mouse wheel forward
    //type =4
    int pos=0;
    switch (type) {
    case 1: // Double-click the eventwidget_state=! widget_state;if(widget_state) / / full screen
        {
            showFullScreen(a); ui->listWidget_videoData->setVisible(false);
            ui->widget_tools->setVisible(false);
            ui->frame_time_bar->setVisible(false);
            ui->widget_tite->setVisible(false);

        }
        else // Restore incomplete screen
        {
           // setWindowFlags(win_flag);
          showNormal(a);if(ui->checkBox_video_list->isChecked())ui->listWidget_videoData->setVisible(true);
           ui->widget_tools->setVisible(true);
           ui->frame_time_bar->setVisible(true);
           ui->widget_tite->setVisible(true);
        }
        break;
    case 2:
        if(ui->AV_player->isPaused())
        {
            ui->AV_player->play(a); timer->start(a);// Set button state -- play state
             ui->MediaPauseBtn->setChecked(false);
        }
        else
        {
            ui->AV_player->pause(a); timer->stop(a);// Set button state -- pause state
            ui->MediaPauseBtn->setChecked(true);
        }
        break;
    case 3:  // Mouse wheel forward
        pos=ui->horizontalSlider_PlayPosition->value(a); pos+=100;
        ui->horizontalSlider_PlayPosition->setValue(pos);
        ui->AV_player->seek(pos);
        ui->label_current_Time->setText(QTime(0.0.0.0).addMSecs(int(pos)).toString(QString::fromLatin1("HH:mm:ss:zzz")));
        break;
    case 4: // Mouse wheel backward
        pos=ui->horizontalSlider_PlayPosition->value(a); pos-=100;
        ui->horizontalSlider_PlayPosition->setValue(pos);
        ui->AV_player->seek(pos);
        ui->label_current_Time->setText(QTime(0.0.0.0).addMSecs(int(pos)).toString(QString::fromLatin1("HH:mm:ss:zzz")));
        break; }}/* project: QtAV_VideoPlayer date: 2021-03-25 作者: DS小 long ge environment: win10 QT5.12.6 MinGW32 function: close window */
void Widget::on_toolButton_close_clicked(a)
{
    this->close(a); }/* Project: QtAV_VideoPlayer Date: 2021-03-25 author: DS small Dragon brother environment: Win10 QT5.12.6 MinGW32 function :mousePressEvent */
void  Widget::mousePressEvent(QMouseEvent *event)
{
    m_lastPos = event->globalPos(a); isPressedWidget =true; // The current mouse down is the QWidget and not any other control on the interface layout
}

/* project: QtAV_VideoPlayer Date: 2021-03-25 author: DS small Rongge environment: Win10 QT5.12.6 MinGW32 function :mouseMoveEvent */
void  Widget::mouseMoveEvent(QMouseEvent *event)
{
    if (isPressedWidget) {
        this->move(this->x() + (event->globalX() - m_lastPos.x()),
                   this->y() + (event->globalY() - m_lastPos.y()));
        m_lastPos = event->globalPos();
    }
}


/* project: QtAV_VideoPlayer date: 2021-03-25 作者: DS small dragon brother environment: win10 QT5.12.6 MinGW32 function :mouseReleaseEvent */
void  Widget::mouseReleaseEvent(QMouseEvent *event)
{
    m_lastPos = event->globalPos(a); isPressedWidget =false; // Set to false when the mouse is released
}


void Widget::keyPressEvent(QKeyEvent *event)
{
    switch(event->key())
    {
    case Qt::Key_Space:
        if(ui->AV_player->isPaused())
        {
             ui->AV_player->play(a); timer->start(a);// Set button state -- play state
             ui->MediaPauseBtn->setChecked(false);
        }
        else
        {
            ui->AV_player->pause(a); timer->stop(a);// Set button state -- pause state
            ui->MediaPauseBtn->setChecked(true);
        }
        break; }}// The timer timed out
void Widget::timeout_update(a)
{
    int64_t pos=ui->AV_player->position(a);// Set the time of the progress bar
    ui->horizontalSlider_PlayPosition->setValue(int(pos));
    ui->label_current_Time->setText(QTime(0.0.0.0).addMSecs(int(pos)).toString(QString::fromLatin1("HH:mm:ss:zzz")));
}


bool Widget::eventFilter(QObject *obj, QEvent *event)
{
    if(obj==ui->horizontalSlider_AudioValue)
    {
        if (event->type()==QEvent::MouseButtonPress)           // Determine the type
        {
            QMouseEvent *mouseEvent = static_cast<QMouseEvent *>(event);
            if (mouseEvent->button() == Qt::LeftButton)	// Determine the left key
            {
               int value = QStyle::sliderValueFromPosition(ui->horizontalSlider_AudioValue->minimum(), ui->horizontalSlider_AudioValue->maximum(), mouseEvent->pos().x(), ui->horizontalSlider_AudioValue->width());
               ui->horizontalSlider_AudioValue->setValue(value);

               // Set the volume
               ui->AV_player->setVolume(float(value/10.0)); }}}return QObject::eventFilter(obj,event);
}

// Play the previous media
void Widget::on_toolButton_pgup_clicked(a)
{
    if(ui->listWidget_videoData->count() < =0)return;
    int row=0;
    row=ui->listWidget_videoData->currentRow(a);// Currently selected row
     qDebug() < <"row:"<<row;
    if(row>0)
    {
        row--;
        ui->listWidget_videoData->setCurrentRow(row);
    }
    else
    {
        ui->listWidget_videoData->setCurrentRow(ui->listWidget_videoData->count(a)- 1);
    }

    // Load the video file
    load_video_file(false,ui->listWidget_videoData->currentItem() - >text());
}

// Play the next media
void Widget::on_toolButton_pgDn_clicked(a)
{
    if(ui->listWidget_videoData->count() < =0)return;
    int row=0;
    row=ui->listWidget_videoData->currentRow(a);// Currently selected row
    qDebug() < <"row:"<<row;
    if(row<ui->listWidget_videoData->count(a)- 1)
    {
        row++;
        ui->listWidget_videoData->setCurrentRow(row);
    }
    else
    {
         ui->listWidget_videoData->setCurrentRow(0);
    }

    // Load the video file
    load_video_file(false,ui->listWidget_videoData->currentItem() - >text());
}


void Widget::slot_onMediaRotate(QAction *action)
{
    action->setChecked(true);
    ui->MediaRotateBtn->setToolTip(action->text());
    ui->AV_player->setrotate(action->data().toInt());
}

void Widget::on_MediaRotateBtn_clicked(a)
{
    QPoint ptWgt = ui->MediaRotateBtn->mapToGlobal(QPoint(0.0));
    ptWgt -= QPoint(10.94);
    QAction *pSelect = m_RotateMenu.exec(ptWgt);
    if (pSelect == nullptr)
        return;
}


// Save the configuration file
void Widget::SaveConfig(a)
{
    /* Save data to a file for next loading */
    QString text;
    text=QCoreApplication::applicationDirPath() +"/"+ConfigFile;
    QFile filesrc(text);
    filesrc.open(QIODevice::WriteOnly);
    QDataStream out(&filesrc);

    for(int i=0; i<ui->listWidget_videoData->count(a); i++) { QListWidgetItem *item=ui->listWidget_videoData->item(i);
        out << item->text(a);// serialize write
    }
    filesrc.flush(a); filesrc.close(a); }// Load the configuration
void Widget::LoadConfig(a)
{
    // Read the configuration file
    QString text;
    QString data;
    text=QCoreApplication::applicationDirPath() +"/"+ConfigFile;

    // Check whether the file exists
    if(QFile::exists(text))
    {
        QFile filenew(text);
        filenew.open(QIODevice::ReadOnly);
        QDataStream in(&filenew); // Read serialized data from a file
        while(! in.atEnd())
        {
            in>>data;
             // If the file exists, you need to add it
             if(QFile::exists(data))
             {
                  ui->listWidget_videoData->addItem(data);
             }
        }
        filenew.close();
    }
}

void Widget::closeEvent(QCloseEvent *event)
{
    int ret = QMessageBox::question(this.tr("Important note"),
    tr("Do I need to close the window?"),
    QMessageBox::Yes | QMessageBox::No);

    if(ret==QMessageBox::Yes)
    {
        SaveConfig(a); event->accept(a);// Accept events
    }
    else
    {
        event->ignore(a);// Clear the event}}/* project: QMDK_VideoPlayer Date: 2021-04-16 author: DS dragonfly environment: Win10 QT5.12.6 MinGW32 function: about the tips */
void Widget::on_toolButton_about_clicked(a)
{
    QString text=
    "<html>"
    "<body>"
    < H1 >
      
Video player features
"

1. Development based on MDK-SDK interface.

"
"< p > this is MDK - SDK making address: < a href = \ \" https://github.com/wang-bin/mdk-sdk/\ "> https://github.com/wang-bin/mdk-sdk < / a > < / p >" "

2. Double-click the left mouse button to zoom in.

"
"

3. Right mouse button or space bar toggle pause and play.

"

4. Mouse over the progress bar can realize the screen preview.

"
"

5. Scroll bar supports click to jump or drag.

"
"

6. Support volume adjustment, dragging or clicking.

"
"

7. Support mute switching.

"
"

8. Support for adding playlists. Select the check box in the lower right corner to enable playlists.

"
"

9. Support to save the playlist upon exit, the next time you open the software automatically load the playlist.\n Next time you open the software, if the playlist file path exists, the first file will be automatically selected to play.

"

10. Every time the video is opened, it will be paused by default and will not play. Only the first screen will be displayed.

"

11. Support mouse wheel to scroll preview screen.

"
"</body>" "</html>"; QMessageBox::about(this."About",text); } Copy the code