0
点赞
收藏
分享

微信扫一扫

2.2 客户端开发-VLCTOOL开发

无聊到学习 2022-02-18 阅读 73
音视频c++

代码的开发

VLCTOOL开发总结

  1. 在有详细设计的情况下,开发难度会下降很多
  2. 有设计的情况下,编译上也会减少错误
  3. 必要的时候,可以细微的调整设计
include <string>
#include <vlc.h>
class VlcSize
{
public:
	int nWidth;
	int nHeight;
	VlcSize(int width = 0,int height = 0)
	{
		nWidth = width;
		nHeight = height;
	}
	VlcSize(const VlcSize& size)
	{
		nWidth = size.nWidth;
		nHeight = size.nHeight;
	}
	VlcSize& operator=(const VlcSize& size)
	{
		if (this != &size)
		{
			nWidth = size.nWidth;
			nHeight = size.nHeight;
		}
		return *this;
	}
};

class VLCTOOL
{
public:
	VLCTOOL();
	~VLCTOOL();
	//strUrl 请传入 utf-8的编码格式
	int SetMedia(const std::string& strUrl);
	int SetHwnd(HWND hWnd);
	int Play();
	int Pause();
	int Stop();
	float GetPostion();
	int SetPostion(float pos);
	int GetVolume();
	int SetVolume(int volume);
	VlcSize GetMediaInfo();//为了增加程序的可移植性 使用VlcSize
protected:
	libvlc_instance_t* m_instance;
	libvlc_media_t* m_media;
	libvlc_media_player_t* m_player;
};
#include "pch.h"
#include "VLCTOOL.h"
VLCTOOL::VLCTOOL()
{
	//初始化libvlc 
}

VLCTOOL::~VLCTOOL()
{
	//相反顺序析构
}

int VLCTOOL::SetMedia(const std::string& strUrl)
{
	//设置路径和初始化播放
}

int VLCTOOL::SetHwnd(HWND hWnd)
{
	//设置窗口
}

int VLCTOOL::Play()
{
	//播放
}

int VLCTOOL::Pause()
{
	//暂停
}

int VLCTOOL::Stop()
{
	//停止
}

float VLCTOOL::GetPostion()
{
	//得到当前播放位置
}

int VLCTOOL::SetPostion(float pos)
{
	//设置当前播放位置
}

int VLCTOOL::GetVolume()
{
	//得到声量
}

int VLCTOOL::SetVolume(int volume)
{
	//设置音量
}

VlcSize VLCTOOL::GetMediaInfo()
{
	//得到视频相关信息
}

举报

相关推荐

0 条评论