瀏覽代碼

V2.1.5 新增支持输入网络地址播放

huihui 4 年之前
父節點
當前提交
414ca54547

+ 6 - 3
VideoPlayer.pro

@@ -15,7 +15,7 @@ MOC_DIR = obj/Moc
 OBJECTS_DIR = obj/Obj
 
 
-#将输出文件直接放到源码目录下的bin目录下,将dll都放在了次目录中,用以解决运行后找不到dll的问
+#锟斤拷锟斤拷锟斤拷锟侥硷拷直锟接放碉拷源锟斤拷目录锟铰碉拷bin目录锟铰o拷锟斤拷dll锟斤拷锟斤拷锟斤拷锟剿达拷目录锟叫o拷锟斤拷锟皆斤拷锟斤拷锟斤拷锟叫猴拷锟揭诧拷锟斤拷dll锟斤拷锟斤拷
 #DESTDIR=$$PWD/bin/
 contains(QT_ARCH, i386) {
     message("32-bit")
@@ -29,12 +29,13 @@ QMAKE_CXXFLAGS += -std=c++11
 TARGET = VideoPlayer
 TEMPLATE = app
 
-#包含视频播放器的代码
+#锟斤拷锟斤拷锟斤拷频锟斤拷锟斤拷锟斤拷锟侥达拷锟斤拷
 include(module/VideoPlayer/VideoPlayer.pri)
-#包含可拖动窗体的代码
+#锟斤拷锟斤拷锟斤拷锟较讹拷锟斤拷锟斤拷锟侥达拷锟斤拷
 include(module/DragAbleWidget/DragAbleWidget.pri)
 
 SOURCES += \
+    src/Widget/SetVideoUrlDialog.cpp \
     src/main.cpp \
     src/AppConfig.cpp \
     src/Base/FunctionTransfer.cpp \
@@ -46,12 +47,14 @@ HEADERS  += \
     src/AppConfig.h \
     src/Base/FunctionTransfer.h \
     src/MainWindow.h \
+    src/Widget/SetVideoUrlDialog.h \
     src/Widget/ShowVideoWidget.h \
     src/Widget/VideoSlider.h
 
 
 FORMS    += \
     src/MainWindow.ui \
+    src/Widget/SetVideoUrlDialog.ui \
     src/Widget/ShowVideoWidget.ui
 
 RESOURCES += \

二進制
bin32/VideoPlayer.exe


+ 23 - 21
module/VideoPlayer/src/VideoPlayer/Audio/VideoPlayer_AudioThread.cpp

@@ -1,6 +1,6 @@
-/**
- * メカコ」サヤ
- * QQネコ121376426
+�ソ/**
+ * 蜿カ豬キ霎�
+ * QQ鄒、121376426
  * http://blog.yundiantech.com/
  */
 
@@ -10,6 +10,8 @@
 
 #include <stdio.h>
 
+#include <QDebug>
+
 void VideoPlayer::sdlAudioCallBackFunc(void *userdata, Uint8 *stream, int len)
 {
     VideoPlayer *player = (VideoPlayer*)userdata;
@@ -20,23 +22,23 @@ void VideoPlayer::sdlAudioCallBack(Uint8 *stream, int len)
 {
     int len1, audio_data_size;
 
-    /*   lenハヌモノSDLエォネ�トSDLサコウ衂�トエ�。」ャネ郢鋠篋�コウ衾エツ奣ャホメテヌセヘメサヨアヘ��鋧萍�セン */
+    /*   len譏ッ逕アSDL莨�蜈・逧ТDL郛灘�蛹コ逧�、ァ蟆擾シ悟ヲよ棡霑吩クェ郛灘�譛ェ貊。�梧�莉ャ蟆ア荳€逶エ蠕€驥悟。ォ蜈�焚謐ョ */
     while (len > 0)
     {
-        /*  audio_buf_index コヘ audio_buf_size ア�セホメテヌラヤシコモテタエキナヨテス篦��エオトハ�センオトサコウ衂�ャ*/
-        /*   ユ簟ゥハ�センエ�copyオスSDLサコウ衂�ャ オアaudio_buf_index >= audio_buf_sizeオトハアコ�簧カラナホメ*/
-        /*   テヌオトサコウ衾ェソユ」ャテサモミハ�センソノケゥcopy」ャユ簗アコ�靨ェオ�テaudio_decode_frameタエス篦���
-         /*   カ犒ト韃ハ�セン */
+        /*  audio_buf_index 蜥� audio_buf_size 譬�、コ謌台サャ閾ェ蟾ア逕ィ譚・謾セ鄂ョ隗」遐∝�譚・逧�焚謐ョ逧�シ灘�蛹コ��*/
+        /*   霑吩コ帶焚謐ョ蠕�opy蛻ーSDL郛灘�蛹コ�� 蠖殿udio_buf_index >= audio_buf_size逧�慮蛟呎э蜻ウ逹€謌�*/
+        /*   莉ャ逧�シ灘�荳コ遨コ�梧イ。譛画焚謐ョ蜿ッ萓嫩opy�瑚ソ呎慮蛟咎怙隕∬ー�畑audio_decode_frame譚・隗」遐∝�譖エ
+         /*   螟夂噪譯「謨ー謐ョ */
         if (audio_buf_index >= audio_buf_size)
         {
             audio_data_size = decodeAudioFrame();
 
-            /* audio_data_size < 0 ア�セテサトワス篦���セン」ャホメテヌトャネマイ・キナセイメ� */
+            /* audio_data_size < 0 譬�、コ豐。閭ス隗」遐∝�謨ー謐ョ�梧�莉ャ鮟倩ョ、謦ュ謾セ髱咎浹 */
             if (audio_data_size <= 0)
             {
                 /* silence */
                 audio_buf_size = 1024;
-                /* ヌ蠱罐ャセイメ� */
+                /* 貂�峺�碁撕髻ウ */
                 memset(audio_buf, 0, audio_buf_size);
             }
             else
@@ -45,7 +47,7 @@ void VideoPlayer::sdlAudioCallBack(Uint8 *stream, int len)
             }
             audio_buf_index = 0;
         }
-        /*  イ鯀エstreamソノモテソユシ茱ャセ�ィメサエホcopyカ猖ルハ�セン」ャハ」マツオトマツエホシフミ�opy */
+        /*  譟・逵虐tream蜿ッ逕ィ遨コ髣エ�悟�螳壻ク€谺。copy螟壼ー第焚謐ョ�悟黄荳狗噪荳区ャ。扈ァ扈ュcopy */
         len1 = audio_buf_size - audio_buf_index;
 
         if (len1 > len)
@@ -55,7 +57,7 @@ void VideoPlayer::sdlAudioCallBack(Uint8 *stream, int len)
 
         if (audio_buf == NULL) return;
 
-        if (mIsMute || mIsNeedPause) //セイメ� サ�゚ ハヌヤレヤンヘ」オトハアコ��ェチヒ
+        if (mIsMute || mIsNeedPause) //髱咎浹 謌冶€� 譏ッ蝨ィ證ょ●逧�慮蛟呵キウ霓ャ莠�
         {
             memset(audio_buf + audio_buf_index, 0, len1);
         }
@@ -89,11 +91,11 @@ int VideoPlayer::decodeAudioFrame(bool isBlock)
         if (mIsQuit)
         {
             mIsAudioThreadFinished = true;
-            clearAudioQuene(); //ヌ蠢ユカモチミ
+            clearAudioQuene(); //貂�ゥコ髦溷�
             break;
         }
 
-        if (mIsPause == true) //ナミカマヤンヘ」
+        if (mIsPause == true) //蛻、譁ュ證ょ●
         {
             break;
         }
@@ -115,7 +117,7 @@ int VideoPlayer::decodeAudioFrame(bool isBlock)
 
         AVPacket packet = mAudioPacktList.front();
         mAudioPacktList.pop_front();
-
+qDebug()<<__FUNCTION__<<mAudioPacktList.size();
         mConditon_Audio->Unlock();
 
         AVPacket *pkt = &packet;
@@ -126,7 +128,7 @@ int VideoPlayer::decodeAudioFrame(bool isBlock)
             audio_clock = av_q2d(mAudioStream->time_base) * pkt->pts;
         }
 
-        //ハユオスユ篋��セン ヒオテ�ユクユヨエミミケ�フ�ェ マヨヤレミ靨ェームス篦��トハ�セン ヌ蟲�メサマツ
+        //謾カ蛻ー霑吩クェ謨ー謐ョ 隸エ譏主�蛻壽鴬陦瑚ソ�キウ霓ャ 邇ー蝨ィ髴€隕∵滑隗」遐∝勣逧�焚謐ョ 貂�勁荳€荳�
         if(strcmp((char*)pkt->data,FLUSH_DATA) == 0)
         {
             avcodec_flush_buffers(mAudioStream->codec);
@@ -136,7 +138,7 @@ int VideoPlayer::decodeAudioFrame(bool isBlock)
 
         if (seek_flag_audio)
         {
-            //キ「ノ愠ヒフ�ェ ヤ���ケリシ�。オストソオトハアシ莊トユ箴クヨ。
+            //蜿醍函莠�キウ霓ャ 蛻呵キウ霑��髞ョ蟶ァ蛻ー逶ョ逧�慮髣エ逧�ソ吝�蟶ァ
            if (audio_clock < seek_time)
            {
                continue;
@@ -147,11 +149,11 @@ int VideoPlayer::decodeAudioFrame(bool isBlock)
            }
         }
 
-        //ス篦�VPacket->AVFrame
+        //隗」遐、VPacket->AVFrame
         int got_frame = 0;
         int size = avcodec_decode_audio4(aCodecCtx, aFrame, &got_frame, &packet);
 
-//ア」エ贍リイノム�ョヌーオトメサク��タオトハ�センキスキィ
+//菫晏ュ倬㍾驥��キ荵句燕逧�ク€荳ェ螢ー驕鍋噪謨ー謐ョ譁ケ豕�
 //size_t unpadded_linesize = aFrame->nb_samples * av_get_bytes_per_sample((AVSampleFormat) aFrame->format);
 //static FILE * fp = fopen("out.pcm", "wb");
 //fwrite(aFrame->extended_data[0], 1, unpadded_linesize, fp);
@@ -160,8 +162,8 @@ int VideoPlayer::decodeAudioFrame(bool isBlock)
 
         if (got_frame)
         {
-            /// ffmpegス篦�ョコ�テオスオトメ�オハ�センイサハヌSDLマ�ェオト」ャ
-            /// メ�ヒユ簑�靨ェヨリイノム�ノ44100 ヒォノ�タ AV_SAMPLE_FMT_S16
+            /// ffmpeg隗」遐∽ケ句錘蠕怜芦逧�浹鬚第焚謐ョ荳肴弍SDL諠ウ隕∫噪��
+            /// 蝗�豁、霑咎㈹髴€隕�㍾驥��キ謌�44100 蜿悟」ー驕� AV_SAMPLE_FMT_S16
             if (aFrame_ReSample == NULL)
             {
                 aFrame_ReSample = av_frame_alloc();

+ 5 - 1
module/VideoPlayer/src/VideoPlayer/VideoPlayer.cpp

@@ -249,7 +249,11 @@ void VideoPlayer::readVideoFile()
     //Allocate an AVFormatContext.
     pFormatCtx = avformat_alloc_context();
 
-    if (avformat_open_input(&pFormatCtx, file_path, nullptr, nullptr) != 0)
+    AVDictionary* opts = NULL;
+    av_dict_set(&opts, "rtsp_transport", "tcp", 0); //设置tcp or udp,默认一般优先tcp再尝试udp
+    av_dict_set(&opts, "stimeout", "60000000", 0);//设置超时3秒
+
+    if (avformat_open_input(&pFormatCtx, file_path, nullptr, &opts) != 0)
     {
         fprintf(stderr, "can't open the file. \n");
         doOpenVideoFileFailed();

+ 31 - 31
src/AppConfig.cpp

@@ -1,4 +1,4 @@
-#include "AppConfig.h"
+锘�#include "AppConfig.h"
 
 #include <QProcess>
 #include <QDesktopWidget>
@@ -43,15 +43,15 @@ void Sleep(long mSeconds)
 
 QString AppConfig::APPID = "{a1db97ad-b8ed-11e9-a297-0235d2b38928}";
 int AppConfig::VERSION = 1;
-QString AppConfig::VERSION_NAME = "2.1.4";
+QString AppConfig::VERSION_NAME = "2.1.5";
 
 MainWindow *AppConfig::gMainWindow = NULL;
 QRect AppConfig::gMainWindowRect;
 
 QRect AppConfig::gScreenRect;
 
-bool AppConfig::gVideoKeepAspectRatio = true; //按比例显示
-bool AppConfig::gVideoHardDecoder = false; //硬解解码
+bool AppConfig::gVideoKeepAspectRatio = true; //鎸夋瘮渚嬫樉绀�
+bool AppConfig::gVideoHardDecoder = false; //纭�В瑙g爜
 QString AppConfig::gVideoFilePath;
 
 QString AppConfig::AppDataPath_Main;
@@ -78,9 +78,9 @@ void AppConfig::InitAllDataPath()
 {
 
 #if defined(WIN32)
-    ///windows数据存储在C盘的数据目录下
+    ///windows鏁版嵁瀛樺偍鍦–鐩樼殑鏁版嵁鐩�綍涓�
     QFileInfo fileInfo(QCoreApplication::applicationFilePath());
-    QString exeFileName = fileInfo.baseName(); //当前程序名字
+    QString exeFileName = fileInfo.baseName(); //褰撳墠绋嬪簭鍚嶅瓧
 
     QString dataPath = QStandardPaths::writableLocation(QStandardPaths::AppDataLocation);
     if (dataPath.right(exeFileName.length()) == exeFileName)
@@ -94,7 +94,7 @@ void AppConfig::InitAllDataPath()
     }
 
 #else
-    ///Linux则放在程序所在目录下的data目录下
+    ///Linux鍒欐斁鍦ㄧ▼搴忔墍鍦ㄧ洰褰曚笅鐨刣ata鐩�綍涓�
     QFileInfo fileInfo(QCoreApplication::applicationFilePath());
 
     QString dataPath = fileInfo.absoluteDir().path();
@@ -280,7 +280,7 @@ void AppConfig::saveConfigInfoToFile()
 //        QJsonObject object;
 //        object.insert("config", dataObject);
 
-        //最外层是大括号所以是object
+        //鏈€澶栧眰鏄�ぇ鎷�彿鎵€浠ユ槸object
         json.setObject(dataObject);
 
         QString jsonStr = json.toJson(QJsonDocument::Compact);
@@ -313,9 +313,9 @@ void AppConfig::InitLogFile()
             qint64 t1 = fileInfo.created().toMSecsSinceEpoch();
             qint64 t2 = QDateTime::currentMSecsSinceEpoch();
 
-            qint64 t = (t2 - t1) / 1000; //文件创建到现在的时间(单位:秒)
+            qint64 t = (t2 - t1) / 1000; //鏂囦欢鍒涘缓鍒扮幇鍦ㄧ殑鏃堕棿锛堝崟浣嶏細绉掞級
 
-            if (t >= (24*3600*3)) //删除3天前的日志文件
+            if (t >= (24*3600*3)) //鍒犻櫎3澶╁墠鐨勬棩蹇楁枃浠�
 //            if (t >= (60*20))
             {
                 QFile::remove(fileInfo.absoluteFilePath());
@@ -378,19 +378,19 @@ QString AppConfig::getSizeInfo(qint64 size)
     int pee = 1024;
 
     char ch[10]={0};
-    if (size > (pee*pee*pee)) //大于1G
+    if (size > (pee*pee*pee)) //澶т簬1G
     {
         sprintf(ch,"%dGB",(int)(size*1.0/pee/pee/pee+0.5));
     }
-    else if (size > (pee*pee)) //大于1M
+    else if (size > (pee*pee)) //澶т簬1M
     {
         sprintf(ch,"%dMB",size/pee/pee);
     }
-    else if (size > pee) //大于1K
+    else if (size > pee) //澶т簬1K
     {
         sprintf(ch,"%dKB",size/pee);
     }
-    else //小于1KB
+    else //灏忎簬1KB
     {
         sprintf(ch,"%dB",size);
     }
@@ -438,12 +438,12 @@ QImage AppConfig::ImagetoGray( QImage image)
     return ret;
 }
 
-//拷贝文件夹:
+//鎷疯礉鏂囦欢澶癸細
 bool AppConfig::copyDirectoryFiles(const QString &fromDir, const QString &toDir, bool coverFileIfExist)
 {
     QDir sourceDir(fromDir);
     QDir targetDir(toDir);
-    if(!targetDir.exists()){    /**< 如果目标目录不存在,则进行创建 */
+    if(!targetDir.exists()){    /**< 濡傛灉鐩�爣鐩�綍涓嶅瓨鍦�紝鍒欒繘琛屽垱寤� */
         if(!targetDir.mkdir(targetDir.absolutePath()))
             return false;
     }
@@ -453,18 +453,18 @@ bool AppConfig::copyDirectoryFiles(const QString &fromDir, const QString &toDir,
         if(fileInfo.fileName() == "." || fileInfo.fileName() == "..")
             continue;
 
-        if(fileInfo.isDir()){    /**< 当为目录时,递归的进行copy */
+        if(fileInfo.isDir()){    /**< 褰撲负鐩�綍鏃讹紝閫掑綊鐨勮繘琛宑opy */
             if(!copyDirectoryFiles(fileInfo.filePath(),
                 targetDir.filePath(fileInfo.fileName()),
                 coverFileIfExist))
                 return false;
         }
-        else{            /**< 当允许覆盖操作时,将旧文件进行删除操作 */
+        else{            /**< 褰撳厑璁歌�鐩栨搷浣滄椂锛屽皢鏃ф枃浠惰繘琛屽垹闄ゆ搷浣� */
             if(coverFileIfExist && targetDir.exists(fileInfo.fileName())){
                 targetDir.remove(fileInfo.fileName());
             }
 
-            /// 进行文件copy
+            /// 杩涜�鏂囦欢copy
             if(!QFile::copy(fileInfo.filePath(),
                 targetDir.filePath(fileInfo.fileName()))){
                     return false;
@@ -493,18 +493,18 @@ bool AppConfig::removeDirectory(QString dirName)
     if(fileInfo.isDir()){
       tmpdir = dirName + ("/") + fileInfo.fileName();
       removeDirectory(tmpdir);
-      dir.rmdir(fileInfo.fileName()); /**< 移除子目录 */
+      dir.rmdir(fileInfo.fileName()); /**< 绉婚櫎瀛愮洰褰� */
     }
     else if(fileInfo.isFile()){
       QFile tmpFile(fileInfo.fileName());
-      dir.remove(tmpFile.fileName()); /**< 删除临时文件 */
+      dir.remove(tmpFile.fileName()); /**< 鍒犻櫎涓存椂鏂囦欢 */
     }
     else{
       ;
     }
   }
 
-  dir.cdUp();            /**< 返回上级目录,因为只有返回上级目录,才可以删除这个目录 */
+  dir.cdUp();            /**< 杩斿洖涓婄骇鐩�綍锛屽洜涓哄彧鏈夎繑鍥炰笂绾х洰褰曪紝鎵嶅彲浠ュ垹闄よ繖涓�洰褰� */
   if(dir.exists(dirName)){
     if(!dir.rmdir(dirName))
       return false;
@@ -521,7 +521,7 @@ bool AppConfig::removeDirectory(QString dirName)
         SHELLEXECUTEINFO sei;
         TCHAR szModule [MAX_PATH],szComspec[MAX_PATH],szParams [MAX_PATH];
 
-        // 获得文件名.
+        // 鑾峰緱鏂囦欢鍚�.
         if((GetModuleFileName(0,szModule,MAX_PATH)!=0) &&
             (GetShortPathName(szModule,szModule,MAX_PATH)!=0) &&
             (GetEnvironmentVariable(L"COMSPEC",szComspec,MAX_PATH)!=0))
@@ -530,7 +530,7 @@ bool AppConfig::removeDirectory(QString dirName)
             QString dirPath = QCoreApplication::applicationFilePath();
             dirPath.replace("/","\\");
             dirPath = "\"" + dirPath + "\"";
-            // 设置命令参数.
+            // 璁剧疆鍛戒护鍙傛暟.
             lstrcpy(szParams, L"/c ");
             lstrcat(szParams, (WCHAR*)dirPath.utf16());
             lstrcat(szParams, L" > nul");
@@ -539,7 +539,7 @@ bool AppConfig::removeDirectory(QString dirName)
     //        lstrcat(szParams, szModule);
     //        lstrcat(szParams, L" > nul");
 
-            // 设置结构成员.
+            // 璁剧疆缁撴瀯鎴愬憳.
             sei.cbSize = sizeof(sei);
             sei.hwnd = 0;
             sei.lpVerb = L"Open";
@@ -549,15 +549,15 @@ bool AppConfig::removeDirectory(QString dirName)
             sei.nShow = SW_HIDE;
             sei.fMask = SEE_MASK_NOCLOSEPROCESS;
 
-            // 执行shell命令.
+            // 鎵ц�shell鍛戒护.
             if(ShellExecuteEx(&sei))
             {
-                // 设置命令行进程的执行级别为空闲执行,使本程序有足够的时间从内存中退出.
+                // 璁剧疆鍛戒护琛岃繘绋嬬殑鎵ц�绾у埆涓虹┖闂叉墽琛�,浣挎湰绋嬪簭鏈夎冻澶熺殑鏃堕棿浠庡唴瀛樹腑閫€鍑�.
                 SetPriorityClass(sei.hProcess,IDLE_PRIORITY_CLASS);
                 SetPriorityClass(GetCurrentProcess(),REALTIME_PRIORITY_CLASS);
                 SetThreadPriority(GetCurrentThread(),THREAD_PRIORITY_TIME_CRITICAL);
 
-               // 通知Windows资源浏览器,本程序文件已经被删除.
+               // 閫氱煡Windows璧勬簮娴忚�鍣�,鏈�▼搴忔枃浠跺凡缁忚�鍒犻櫎.
                 SHChangeNotify(SHCNE_DELETE,SHCNF_PATH,(WCHAR*)dirPath.utf16(),0);
                 return TRUE;
             }
@@ -579,8 +579,8 @@ bool AppConfig::removeDirectory(QString dirName)
             QString filePath = QString("%1/%2").arg(dirPath).arg(Appconfig::AppExeName);
             QString runAppCmd = QString("open -a \""+filePath+"\" \n");
 
-            fileOut<<QString("ping -c 4 -t 2 baidu.com \n"); //延时2秒
-            fileOut<<runAppCmd; //启动程序
+            fileOut<<QString("ping -c 4 -t 2 baidu.com \n"); //寤舵椂2绉�
+            fileOut<<runAppCmd; //鍚�姩绋嬪簭
 
             file.close();
         }
@@ -590,7 +590,7 @@ bool AppConfig::removeDirectory(QString dirName)
         p.start("bash");
         p.waitForStarted();
         p.write(QString("chmod a+x \""+bashFilePath+"\" \n").toUtf8());
-        p.write(QString("\""+bashFilePath+"\" &\n").toUtf8()); //后台运行
+        p.write(QString("\""+bashFilePath+"\" &\n").toUtf8()); //鍚庡彴杩愯�
 //        p.write(QString("open -a \""+bashFilePath+"\" \n").toUtf8());
         p.closeWriteChannel();
         p.waitForFinished();

+ 21 - 21
src/AppConfig.h

@@ -1,4 +1,4 @@
-#ifndef APPCONFIG_H
+锘�#ifndef APPCONFIG_H
 #define APPCONFIG_H
 
 #include <QFile>
@@ -23,52 +23,52 @@ public:
     static int VERSION;
     static QString VERSION_NAME;
 
-    /// 本地全局变量
-    static QString AppDataPath_Main; //程序数据主目录
-    static QString AppDataPath_Data; //程序数据的data目录
-    static QString AppDataPath_Tmp; //临时目录(程序退出时会清空此目录)
-    static QString AppDataPath_TmpFile; //程序运行时 创建次文件,退出时删除此文件,用来判断程序是否正常退出
-    static QString AppFilePath_Log; //日志目录
-    static QString AppFilePath_LogFile; //日志文件
-    static QString AppFilePath_EtcFile; //配置信息
+    /// 鏈�湴鍏ㄥ眬鍙橀噺
+    static QString AppDataPath_Main; //绋嬪簭鏁版嵁涓荤洰褰�
+    static QString AppDataPath_Data; //绋嬪簭鏁版嵁鐨刣ata鐩�綍
+    static QString AppDataPath_Tmp; //涓存椂鐩�綍(绋嬪簭閫€鍑烘椂浼氭竻绌烘�鐩�綍)
+    static QString AppDataPath_TmpFile; //绋嬪簭杩愯�鏃� 鍒涘缓娆℃枃浠讹紝閫€鍑烘椂鍒犻櫎姝ゆ枃浠讹紝鐢ㄦ潵鍒ゆ柇绋嬪簭鏄�惁姝e父閫€鍑�
+    static QString AppFilePath_Log; //鏃ュ織鐩�綍
+    static QString AppFilePath_LogFile; //鏃ュ織鏂囦欢
+    static QString AppFilePath_EtcFile; //閰嶇疆淇℃伅
 
     static MainWindow *gMainWindow;
-    static QRect gMainWindowRect; //主窗口的位置 - 用于标记在非全屏模式下的弹窗大小
+    static QRect gMainWindowRect; //涓荤獥鍙g殑浣嶇疆 - 鐢ㄤ簬鏍囪�鍦ㄩ潪鍏ㄥ睆妯″紡涓嬬殑寮圭獥澶у皬
     static QRect gScreenRect;
 
-    static bool gVideoKeepAspectRatio; //视频按比例播放
-    static bool gVideoHardDecoder; //硬解解码
-    static QString gVideoFilePath; //打开视频文件的默认位置
+    static bool gVideoKeepAspectRatio; //瑙嗛�鎸夋瘮渚嬫挱鏀�
+    static bool gVideoHardDecoder; //纭�В瑙g爜
+    static QString gVideoFilePath; //鎵撳紑瑙嗛�鏂囦欢鐨勯粯璁や綅缃�
 
 
     static void MakeDir(QString dirName);
-    static void InitAllDataPath(); //初始化所有数据保存的路径
+    static void InitAllDataPath(); //鍒濆�鍖栨墍鏈夋暟鎹�繚瀛樼殑璺�緞
 
     static QString bufferToString(QByteArray sendbuf);
     static QByteArray StringToBuffer(QString);
     static QString getFileMd5(QString filePath,qint64 size=-1);
 
-    ///配置文件
+    ///閰嶇疆鏂囦欢
     static void loadConfigInfoFromFile();
     static void saveConfigInfoToFile();
 
-    ///写日志
+    ///鍐欐棩蹇�
     static void WriteLog(QString str);
     static void InitLogFile();
     static QString getSizeInfo(qint64 size);
 
-    static QImage ImagetoGray( QImage image); //生成灰度图
+    static QImage ImagetoGray( QImage image); //鐢熸垚鐏板害鍥�
 
-    ///拷贝文件夹
+    ///鎷疯礉鏂囦欢澶�
     static bool copyDirectoryFiles(const QString &fromDir, const QString &toDir, bool coverFileIfExist);
 
-    ///删除目录
+    ///鍒犻櫎鐩�綍
     static bool removeDirectory(QString dirName);
 
-    ///重启软件
+    ///閲嶅惎杞�欢
     static bool restartSelf();
 
-    ///休眠函数(毫秒)
+    ///浼戠湢鍑芥暟(姣��)
     static void mSleep(int mSecond);
 };
 

+ 25 - 17
src/MainWindow.cpp

@@ -19,6 +19,8 @@
 #include "AppConfig.h"
 #include "Base/FunctionTransfer.h"
 
+#include "Widget/SetVideoUrlDialog.h"
+
 Q_DECLARE_METATYPE(VideoPlayerState)
 
 MainWindow::MainWindow(QWidget *parent) :
@@ -49,7 +51,9 @@ MainWindow::MainWindow(QWidget *parent) :
     connect(ui->horizontalSlider_volume, SIGNAL(valueChanged(int)), this, SLOT(slotSliderMoved(int)));
 
     ui->page_video->setMouseTracking(true);
-    ui->page_video->installEventFilter(this);
+    ui->widget_videoPlayer->setMouseTracking(true);
+//    ui->page_video->installEventFilter(this);
+    ui->widget_videoPlayer->installEventFilter(this);
     ui->widget_container->installEventFilter(this);
 
     mPlayer = new VideoPlayer();
@@ -61,7 +65,7 @@ MainWindow::MainWindow(QWidget *parent) :
 
     mTimer_CheckControlWidget = new QTimer; //用于控制控制界面的出现和隐藏
     connect(mTimer_CheckControlWidget, &QTimer::timeout, this, &MainWindow::slotTimerTimeOut);
-    mTimer_CheckControlWidget->setInterval(1500);
+    mTimer_CheckControlWidget->setInterval(2500);
 
     mAnimation_ControlWidget  = new QPropertyAnimation(ui->widget_controller, "geometry");
 
@@ -77,6 +81,8 @@ MainWindow::MainWindow(QWidget *parent) :
 
 MainWindow::~MainWindow()
 {
+qDebug()<<__FUNCTION__;
+
     AppConfig::saveConfigInfoToFile();
     AppConfig::removeDirectory(AppConfig::AppDataPath_Tmp);
 
@@ -192,22 +198,24 @@ void MainWindow::slotBtnClick(bool isChecked)
     }
     else if (QObject::sender() == ui->pushButton_open || QObject::sender() == ui->toolButton_open)
     {
-        QString s = QFileDialog::getOpenFileName(
-                   this, QStringLiteral("选择要播放的文件"),
-                    AppConfig::gVideoFilePath,//初始目录
-                    QStringLiteral("视频文件 (*.flv *.rmvb *.avi *.MP4 *.mkv);;")
-                    +QStringLiteral("音频文件 (*.mp3 *.wma *.wav);;")
-                    +QStringLiteral("所有文件 (*.*)"));
-        if (!s.isEmpty())
+        SetVideoUrlDialog dialog;
+
+        dialog.setVideoUrl(AppConfig::gVideoFilePath);
+
+        if (dialog.exec() == QDialog::Accepted)
         {
-//            s.replace("/","\\");
+            QString s = dialog.getVideoUrl();
 
-            mPlayer->stop(true); //如果在播放则先停止
-            mPlayer->startPlay(s.toStdString());
+            if (!s.isEmpty())
+            {
+                mPlayer->stop(true); //如果在播放则先停止
+                mPlayer->startPlay(s.toStdString());
 
-            AppConfig::gVideoFilePath = s;
-            AppConfig::saveConfigInfoToFile();
+                AppConfig::gVideoFilePath = s;
+                AppConfig::saveConfigInfoToFile();
+            }
         }
+
     }
     else if (QObject::sender() == ui->pushButton_volume)
     {
@@ -351,9 +359,9 @@ bool MainWindow::eventFilter(QObject *target, QEvent *event)
             ui->widget_controller->resize(w, ui->widget_controller->height());
         }
     }
-    else if(target == ui->page_video)
+    else if(target == ui->page_video || target == ui->widget_videoPlayer)
     {
-        if(event->type() == QEvent::MouseMove)
+        if(event->type() == QEvent::MouseMove || event->type() == QEvent::MouseButtonPress)
         {
             if (!mTimer_CheckControlWidget->isActive())
             {
@@ -365,7 +373,7 @@ bool MainWindow::eventFilter(QObject *target, QEvent *event)
         }
         else if(event->type() == QEvent::Enter)
         {
-            ui->widget_controller->show();
+            showOutControlWidget();
         }
         else if(event->type() == QEvent::Leave)
         {

+ 1 - 1
src/MainWindow.ui

@@ -48,7 +48,7 @@
        </rect>
       </property>
       <property name="currentIndex">
-       <number>0</number>
+       <number>2</number>
       </property>
       <widget class="QWidget" name="page_open">
        <layout class="QVBoxLayout" name="verticalLayout_6">

+ 49 - 0
src/Widget/SetVideoUrlDialog.cpp

@@ -0,0 +1,49 @@
+#include "SetVideoUrlDialog.h"
+#include "ui_SetVideoUrlDialog.h"
+
+#include <QFileDialog>
+
+#include "AppConfig.h"
+
+SetVideoUrlDialog::SetVideoUrlDialog(QWidget *parent) :
+    QDialog(parent),
+    ui(new Ui::SetVideoUrlDialog)
+{
+    ui->setupUi(this);
+
+    connect(ui->pushButton_selectFile,   &QPushButton::clicked, this, &SetVideoUrlDialog::slotBtnClick);
+
+}
+
+SetVideoUrlDialog::~SetVideoUrlDialog()
+{
+    delete ui;
+}
+
+void SetVideoUrlDialog::setVideoUrl(const QString &url)
+{
+    ui->lineEdit_fileUrl->setText(url);
+}
+
+QString SetVideoUrlDialog::getVideoUrl()
+{
+    QString url = ui->lineEdit_fileUrl->text();
+    return url;
+}
+
+void SetVideoUrlDialog::slotBtnClick(bool isChecked)
+{
+    if (QObject::sender() == ui->pushButton_selectFile)
+    {
+        QString s = QFileDialog::getOpenFileName(
+                   this, QStringLiteral("选择要播放的文件"),
+                    AppConfig::gVideoFilePath,//初始目录
+                    QStringLiteral("视频文件 (*.flv *.rmvb *.avi *.MP4 *.mkv);;")
+                    +QStringLiteral("音频文件 (*.mp3 *.wma *.wav);;")
+                    +QStringLiteral("所有文件 (*.*)"));
+        if (!s.isEmpty())
+        {
+            ui->lineEdit_fileUrl->setText(s);
+        }
+    }
+}

+ 29 - 0
src/Widget/SetVideoUrlDialog.h

@@ -0,0 +1,29 @@
+#ifndef SetVideoUrlDialog_H
+#define SetVideoUrlDialog_H
+
+#include <QDialog>
+
+namespace Ui {
+class SetVideoUrlDialog;
+}
+
+class SetVideoUrlDialog : public QDialog
+{
+    Q_OBJECT
+
+public:
+    explicit SetVideoUrlDialog(QWidget *parent = 0);
+    ~SetVideoUrlDialog();
+
+    void setVideoUrl(const QString &url);
+    QString getVideoUrl();
+
+private:
+    Ui::SetVideoUrlDialog *ui;
+
+private slots:
+    void slotBtnClick(bool isChecked);
+
+};
+
+#endif // SetVideoUrlDialog_H

+ 227 - 0
src/Widget/SetVideoUrlDialog.ui

@@ -0,0 +1,227 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<ui version="4.0">
+ <class>SetVideoUrlDialog</class>
+ <widget class="QDialog" name="SetVideoUrlDialog">
+  <property name="geometry">
+   <rect>
+    <x>0</x>
+    <y>0</y>
+    <width>831</width>
+    <height>133</height>
+   </rect>
+  </property>
+  <property name="windowTitle">
+   <string>设置http地址</string>
+  </property>
+  <layout class="QVBoxLayout" name="verticalLayout">
+   <property name="spacing">
+    <number>0</number>
+   </property>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_3">
+     <property name="bottomMargin">
+      <number>0</number>
+     </property>
+     <item>
+      <widget class="QLabel" name="label_2">
+       <property name="text">
+        <string>选择视频文件(支持直接输入网络地址)</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <spacer name="verticalSpacer_7">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeType">
+      <enum>QSizePolicy::Fixed</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>20</width>
+       <height>12</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_9">
+     <property name="bottomMargin">
+      <number>0</number>
+     </property>
+     <item>
+      <widget class="QLabel" name="label_8">
+       <property name="text">
+        <string>视频地址:</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QLineEdit" name="lineEdit_fileUrl">
+       <property name="minimumSize">
+        <size>
+         <width>0</width>
+         <height>32</height>
+        </size>
+       </property>
+       <property name="text">
+        <string>rtmp://202.69.69.180:443/webcast/bshdlive-pc</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <widget class="QPushButton" name="pushButton_selectFile">
+       <property name="minimumSize">
+        <size>
+         <width>0</width>
+         <height>28</height>
+        </size>
+       </property>
+       <property name="cursor">
+        <cursorShape>PointingHandCursor</cursorShape>
+       </property>
+       <property name="text">
+        <string>选择本地文件</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <spacer name="verticalSpacer_4">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeType">
+      <enum>QSizePolicy::Fixed</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>20</width>
+       <height>12</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+   <item>
+    <layout class="QHBoxLayout" name="horizontalLayout_2">
+     <item>
+      <spacer name="horizontalSpacer">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>40</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QPushButton" name="pushButton">
+       <property name="minimumSize">
+        <size>
+         <width>0</width>
+         <height>28</height>
+        </size>
+       </property>
+       <property name="cursor">
+        <cursorShape>PointingHandCursor</cursorShape>
+       </property>
+       <property name="text">
+        <string>确定</string>
+       </property>
+      </widget>
+     </item>
+     <item>
+      <spacer name="horizontalSpacer_2">
+       <property name="orientation">
+        <enum>Qt::Horizontal</enum>
+       </property>
+       <property name="sizeType">
+        <enum>QSizePolicy::Fixed</enum>
+       </property>
+       <property name="sizeHint" stdset="0">
+        <size>
+         <width>32</width>
+         <height>20</height>
+        </size>
+       </property>
+      </spacer>
+     </item>
+     <item>
+      <widget class="QPushButton" name="pushButton_2">
+       <property name="minimumSize">
+        <size>
+         <width>0</width>
+         <height>28</height>
+        </size>
+       </property>
+       <property name="cursor">
+        <cursorShape>PointingHandCursor</cursorShape>
+       </property>
+       <property name="text">
+        <string>取消</string>
+       </property>
+      </widget>
+     </item>
+    </layout>
+   </item>
+   <item>
+    <spacer name="verticalSpacer_2">
+     <property name="orientation">
+      <enum>Qt::Vertical</enum>
+     </property>
+     <property name="sizeType">
+      <enum>QSizePolicy::Fixed</enum>
+     </property>
+     <property name="sizeHint" stdset="0">
+      <size>
+       <width>20</width>
+       <height>6</height>
+      </size>
+     </property>
+    </spacer>
+   </item>
+  </layout>
+ </widget>
+ <resources/>
+ <connections>
+  <connection>
+   <sender>pushButton</sender>
+   <signal>clicked()</signal>
+   <receiver>SetVideoUrlDialog</receiver>
+   <slot>accept()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>573</x>
+     <y>93</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>470</x>
+     <y>76</y>
+    </hint>
+   </hints>
+  </connection>
+  <connection>
+   <sender>pushButton_2</sender>
+   <signal>clicked()</signal>
+   <receiver>SetVideoUrlDialog</receiver>
+   <slot>reject()</slot>
+   <hints>
+    <hint type="sourcelabel">
+     <x>706</x>
+     <y>92</y>
+    </hint>
+    <hint type="destinationlabel">
+     <x>653</x>
+     <y>87</y>
+    </hint>
+   </hints>
+  </connection>
+ </connections>
+</ui>