#include "MYPlay.h"
#include <QDebug>
#include <QSettings>
#include <QFileInfo>
#include <QPointer>
#include "MYDemuxThread.h"
#include "MYVideoOutput.h"
#include "MYSubTitle.h"
static QScopedPointer<MYDemuxThread> dt;
static QScopedPointer<MYSubTitle> st;
MYPlay::MYPlay()
{
dt.reset(new MYDemuxThread);
st.reset(new MYSubTitle);
dt->Start();
startTimer(40);
setBackGround(NULL);
setVideoPath(NULL);
setSubTitlePath(NULL);
}
MYPlay::~MYPlay()
{
qDebug()<<"close";
if(m_mOpenSuccess)
{
QSettings *settingIni = new QSettings("setting.ini",QSettings::IniFormat);
qDebug()<<m_strTheVideoPath;
settingIni->setValue("Progress/" + m_strTheVideoPath,dt->pts);
delete settingIni;
}
dt->Close();
}
void MYPlay::testFunc()
{
setDemoNum(demoNum() + 1);
}
//打开线程,传输文件路径
void MYPlay::urlPass(QString url)
{
MYVideoOutput* video =qobject_cast<MYVideoOutput*>(source());
qDebug() << (video == nullptr) <<endl;
m_strTheVideoPath = url;
if(video != nullptr)
{
QFileInfo fileInfo(url);
QString subTitleP = url.left(url.length() - fileInfo.suffix().length());
QSettings *settingIni = new QSettings("setting.ini",QSettings::IniFormat);
QString saveProgress = settingIni->value("Progress/" + url).toString();
qDebug()<<saveProgress;
delete settingIni;
//qDebug()<<subTitleP;
fileInfo = QFileInfo(subTitleP+"srt"); //打开视频时自动查找视频所在文件夹有对应名称的无字幕文件,有则打开
if(fileInfo.exists())
{
st->Open(fileInfo.absoluteFilePath());
}
else
qDebug()<<"there is no srt file";
//if(fileInfo.exists())
//st->Open(fileInfo);
if(!dt->Open(url.toLocal8Bit(),video))
return;
if(saveProgress != "")
dt->Seek(saveProgress.toDouble() / (double)dt->totalMs);
}
qDebug() << url;
setIsPlay(!dt->isPause);
setOpenSuccess(dt->getOpenSuccess());
}
//播放进度条
void MYPlay::posFind(double value)
{
double pos = ((double)(int)(((double)dt->pts / (double)dt->totalMs) * 1000)) / 1000;
double newValue = ((double)(int)(value * 1000)) / 1000;
qDebug() << "pos value = " << pos;
dt->Seek(newValue);
}
void MYPlay::timerEvent(QTimerEvent *e)
{
//if (isSliderPress)return;
setTestNum(m_mTestNum + 1);
long long total = dt->totalMs;
//qDebug()<<dt->pts;
int currentTime = (int)dt->pts;
//qDebug()<<st->isOpen();
if(st->isOpen())
{
if(!(st->nodeStartTime() <= currentTime && st->nodeEndTime() >= currentTime) || (st->nodeEndTime() == st->nodeStartTime())) //如果已经读取到现在的节点则没必要在read,或者处于刚开始时需要执行read
if(st->Read(currentTime))
setSubTitleText(st->text());
else
setSubTitleText("");
}
if (total > 0)
{
double pos = ((double)(int)(((double)dt->pts / (double)total) * 1000)) / 1000; //保留三位小数,后面置0,方便比较
setPosNum(pos);
}
}
//播放暂停
void MYPlay::playOrPause()
{
bool isPause = !dt->isPause;
setIsPlay(!isPause);
dt->SetPause(isPause);
}
//快进
void MYPlay::goOn()
{
double pos = ((double)(int)(((double)dt->pts / (double)dt->totalMs) * 1000)) / 1000 + 0.02; //依照需求调整快进的程度
dt->Seek(pos);
}
//快退
void MYPlay::goBack()
{
double pos = ((double)(int)(((double)dt->pts / (double)dt->totalMs) * 1000)) / 1000 - 0.02; //依照需求调整快退的程度
dt->Seek(pos);
}
//改变并储存背景
void MYPlay::changeBackground(QString url)
{
setBackGround(url);
}
//改变视频选择路径
void MYPlay::changeVideoPath(QString url)
{
setVideoPath(url);
}
//改变字幕选择路径
void MYPlay::changeSubTitlePath(QString url)
{
setSubTitlePath(url);
}
//改变音量
void MYPlay::setVolume(double newVolume)
{
dt->SetVolume(((double)(int)(newVolume*100))/100);
}
//停止
void MYPlay::setStop()
{
if(m_mOpenSuccess)
{
dt->Close();
dt.reset(new MYDemuxThread);
dt->Start();
if(st->isOpen())
{
st.reset(new MYSubTitle);
setSubTitleText("");
}
setOpenSuccess(false);
}
}
//加载字幕
void MYPlay::loadSubTitle(QString url)
{
if(m_mOpenSuccess)
{
st.reset(new MYSubTitle);
st->Open(url);
}
}
// demoNum
int MYPlay::demoNum() const
{
return m_mDemoNum;
}
void MYPlay::setDemoNum(int newValue)
{
if (m_mDemoNum != newValue)
{
m_mDemoNum = newValue;
emit demoNumChanged(m_mDemoNum);
}
}
int MYPlay::testNum() const
{
return m_mTestNum;
}
void MYPlay::setTestNum(int newValue)
{
if (m_mTestNum != newValue)
{
m_mTestNum = newValue;
emit testNumChanged(m_mTestNum);
}
}
double MYPlay::posNum() const
{
return m_mPosNum;
}
void MYPlay::setPosNum(double newValue)
{
if (m_mPosNum != newValue)
{
m_mPosNum = newValue;
emit posNumChanged(m_mPosNum);
}
}
bool MYPlay::isPlay() const
{
return m_mIsPlaying;
}
void MYPlay::setIsPlay(bool isPlaying)
{
if(m_mIsPlaying != isPlaying)
{
m_mIsPlaying = isPlaying;
emit isPlayingChanged(m_mIsPlaying);
}
}
bool MYPlay::openSuccess() const
{
return m_mOpenSuccess;
}
void MYPlay::setOpenSuccess(bool openSuccess)
{
if(m_mOpenSuccess != openSuccess)
{
m_mOpenSuccess = openSuccess;
emit openSuccessChanged(m_mOpenSuccess);
}
}
QObject* MYPlay::source() const
{
return m_mSource;
}
void MYPlay::setSource(QObject *source)
{
if(m_mSource != source)
{
m_mSource = source;
emit sourceChanged(m_mSource);
}
}
//背景图片路径
QString MYPlay::backGround() const
{
return m_strBackgroundPath;
}
void MYPlay::setBackGround(QString url)
{
QSettings *settingIni = new QSettings("setting.ini",QSettings::IniFormat);
QString backGroundpath = settingIni->value("Path/Background").toString();
if(url == NULL)
{
if(backGroundpath == NULL)
{
delete settingIni;
return;
}
else
{
m_strBackgroundPath = backGroundpath;
QFileInfo fileInfo(backGroundpath);
m_strBackGroundChoosePath = fileInfo.path();
qDebug()<<m_strBackGroundChoosePath<<endl;
delete settingIni;
emit backGroundChanged(m_strBackgroundPath);
emit backGroundChooseChanged(m_strBackGroundChoosePath);
return;
}
}
if(m_strBackgroundPath != url)
{
settingIni->setValue("Path/Background",url);
m_strBackgroundPath = url;
QFileInfo fileInfo(url);
//qDebug()<<fileInfo.suffix();
m_strBackGroundChoosePath = fileInfo.path();
emit backGroundChanged(m_strBackgroundPath);
emit backGroundChooseChanged(m_strBackGroundChoosePath);
}
delete settingIni;
}
//选择背景路径
QString MYPlay::backGroundChoose() const
{
return m_strBackGroundChoosePath;
}
//选择视频路径
QString MYPlay::videoPath() const
{
return m_strVideoPath;
}
void MYPlay::setVideoPath(QString url)
{
QSettings *settingIni = new QSettings("setting.ini",QSettings::IniFormat);
QString videoPath = settingIni->value("Path/VideoChoose").toString();
if(url == NULL)
{
if(videoPath == NULL)
{
delete settingIni;
return;
}
else
{
没有合适的资源?快使用搜索试试~ 我知道了~
基于QT和VisualStudio的慕影音乐播放器(源代码)-计算机专业精品毕业设计和课程设计
共211个文件
h:131个
png:13个
cpp:13个
需积分: 5 1 下载量 4 浏览量
2024-05-18
13:15:45
上传
评论
收藏 16.19MB 7Z 举报
温馨提示
0基础可以根据进行项目部署的计算机专业精品毕业设计和课程设计——基于QT和VisualStudio的慕影音乐播放器(源代码),该QT项目是在VS2019的环境下进行开发的,需要的一些特定环境资源可以私聊本作者。
资源推荐
资源详情
资源评论
收起资源包目录
基于QT和VisualStudio的慕影音乐播放器(源代码)-计算机专业精品毕业设计和课程设计 (211个子文件)
libavcodec.dll.a 674KB
libavdevice.dll.a 453KB
libavutil.dll.a 335KB
libavformat.dll.a 134KB
libavfilter.dll.a 45KB
libswscale.dll.a 22KB
libswresample.dll.a 15KB
libpostproc.dll.a 7KB
UpdateTS.bat 40B
UpdateQM.bat 37B
GenerateVCProj.bat 27B
MYPlay.cpp 9KB
MainApp.cpp 8KB
MYDemux.cpp 6KB
MYDemuxThread.cpp 5KB
MYSubTitle.cpp 4KB
MYVideoOutput.cpp 4KB
MYAudioThread.cpp 3KB
MYAudioPlay.cpp 3KB
MYDecode.cpp 3KB
MYVideoThread.cpp 3KB
MYResample.cpp 2KB
MYDecodeThread.cpp 1KB
main.cpp 425B
avutil-56.def 13KB
avcodec-58.def 6KB
avformat-58.def 4KB
avfilter-7.def 2KB
swscale-5.def 791B
avdevice-58.def 563B
swresample-3.def 497B
postproc-55.def 234B
avcodec-58.dll 42.61MB
avformat-58.dll 9.93MB
avfilter-7.dll 7.88MB
avdevice-58.dll 2.61MB
avutil-56.dll 932KB
swscale-5.dll 540KB
swresample-3.dll 419KB
postproc-55.dll 132KB
ffmpeg.exe 313KB
ffprobe.exe 171KB
ffplay.exe 150KB
MYPlayer.vcxproj.filters 8KB
avcodec.h 218KB
avformat.h 119KB
avfilter.h 42KB
opt.h 36KB
pixfmt.h 34KB
avio.h 33KB
frame.h 32KB
mem.h 24KB
hwcontext.h 23KB
swresample.h 22KB
intreadwrite.h 19KB
avdevice.h 18KB
common.h 17KB
pixdesc.h 16KB
avstring.h 15KB
hdr_dynamic_metadata.h 13KB
log.h 13KB
swscale.h 12KB
imgutils.h 12KB
buffer.h 11KB
samplefmt.h 10KB
avutil.h 10KB
channel_layout.h 10KB
hash.h 9KB
dict.h 8KB
spherical.h 8KB
mathematics.h 8KB
bprint.h 8KB
parseutils.h 8KB
encryption_info.h 7KB
buffersrc.h 7KB
buffersink.h 6KB
eval.h 6KB
hwcontext_d3d11va.h 6KB
xvmc.h 6KB
audio_fifo.h 6KB
fifo.h 6KB
rational.h 6KB
vdpau.h 6KB
cpu.h 6KB
error.h 5KB
tree.h 5KB
stereo3d.h 5KB
timecode.h 5KB
version.h 5KB
attributes.h 5KB
hwcontext_drm.h 5KB
version.h 5KB
hwcontext_vulkan.h 5KB
MYPlay.h 4KB
version.h 4KB
dirac.h 4KB
videotoolbox.h 4KB
mastering_display_metadata.h 4KB
threadmessage.h 4KB
hwcontext_vaapi.h 4KB
共 211 条
- 1
- 2
- 3
资源评论
UtopiaYouth
- 粉丝: 250
- 资源: 112
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功