内容共享功能提供了屏幕共享、应用共享和文件共享的完整解决方案,支持桌面共享、应用窗口共享、媒体文件共享等多种共享方式。通过内容共享,用户可以在会议中展示屏幕内容、应用程序或播放媒体文件。
启动内容共享功能:
// 开始内容共享 - 启动共享功能
NemoSdkAdaptor::getInstance()->startContentSharing();
// 开始内容采集 - 开始采集屏幕或应用内容
NemoSdkAdaptor::getInstance()->startContentCapture();
控制共享的暂停、恢复和停止:
// 暂停共享 - 暂停内容采集
NemoSdkAdaptor::getInstance()->pauseContentCapture();
// 恢复共享 - 恢复内容采集
NemoSdkAdaptor::getInstance()->resumeContentCapture();
// 停止共享 - 停止内容采集和共享
NemoSdkAdaptor::getInstance()->stopContentCapture();
NemoSdkAdaptor::getInstance()->stopContentSharing();
配置共享参数和选项:
// 设置不忽略小鱼程序窗口 - 包含小鱼程序窗口在共享中
NemoSdkAdaptor::getInstance()->setNotIgnoreCaptureWnd(true);
// 设置不排除窗口 - 不排除特定窗口
NemoSdkAdaptor::getInstance()->setNotExcludeWnd(true);
// 开启双屏模式 - 启用双屏显示模式
NemoSdkAdaptor::getInstance()->setEnableDualScreenMode(true);
共享和播放媒体文件:
// 获取媒体文件信息 - 传入文件路径
NemoSdkAdaptor::getInstance()->getMediaFileInfo("video.mp4");
// 设置播放进度 - 跳转到30秒位置
NemoSdkAdaptor::getInstance()->setContentSeekTo(30.0);
// 设置音量 - 设置为80%音量
NemoSdkAdaptor::getInstance()->setContentVolume(80);
API: startContentSharing
接口定义:
virtual void startContentSharing() = 0;
示例:
NemoSdkAdaptor::getInstance()->startContentSharing();
API: stopContentSharing
接口定义:
virtual void stopContentSharing() = 0;
示例:
NemoSdkAdaptor::getInstance()->stopContentSharing();
API: startContentCapture
接口定义:
virtual void startContentCapture() = 0;
示例:
NemoSdkAdaptor::getInstance()->startContentCapture();
API: pauseContentCapture
接口定义:
virtual void pauseContentCapture() = 0;
API: pauseContentCapture
示例:
NemoSdkAdaptor::getInstance()->pauseContentCapture();
API: resumeContentCapture
接口定义:
virtual void resumeContentCapture() = 0;
示例:
NemoSdkAdaptor::getInstance()->resumeContentCapture();
API: stopContentCapture
接口定义:
virtual void stopContentCapture() = 0;
示例:
NemoSdkAdaptor::getInstance()->stopContentCapture();
接口定义:
virtual void setNotIgnoreCaptureWnd(bool notIgnore) = 0;
参数:
notIgnore
: bool - 是否不忽略小鱼程序窗口示例:
// 设置不忽略小鱼程序窗口
NemoSdkAdaptor::getInstance()->setNotIgnoreCaptureWnd(true);
API: setNotExcludeWnd
接口定义:
virtual void setNotExcludeWnd(bool notExclude) = 0;
参数:
notExclude
: bool - 是否不排除窗口示例:
// 设置不排除窗口
NemoSdkAdaptor::getInstance()->setNotExcludeWnd(true);
接口定义:
virtual void setEnableDualScreenMode(bool enable) = 0;
参数:
enable
: bool - 是否开启双屏模式示例:
// 开启双屏模式
NemoSdkAdaptor::getInstance()->setEnableDualScreenMode(true);
API: getTopLevelAppList
示例:
NemoSdkAdaptor::getInstance()->getTopLevelAppList();
参数:
windowHandle
: 窗口句柄示例:
NemoSdkAdaptor::getInstance()->getAppWindowVisibleArea(windowHandle);
API: getMonitorThumbnail
示例:
NemoSdkAdaptor::getInstance()->getMonitorThumbnail();
API: getMediaFileInfo
参数:
filePath
: 文件路径示例:
NemoSdkAdaptor::getInstance()->getMediaFileInfo("video.mp4");
API: setContentSeekTo
参数:
time
: 播放时间点(秒)示例:
// 跳转到30秒
NemoSdkAdaptor::getInstance()->setContentSeekTo(30.0);
API: setContentVolume
参数:
volume
: 音量值(0-100)示例:
// 设置音量为80%
NemoSdkAdaptor::getInstance()->setContentVolume(80);
参数:
enable
: 是否开启多路共享音频示例:
// 开启多路共享音频
NemoSdkAdaptor::getInstance()->setEnableMutilContent(true);
API: needSpeakerChanged
参数:
need
: 是否需要监听扬声器变化示例:
// 监听扬声器变化
NemoSdkAdaptor::getInstance()->needSpeakerChanged(true);
class ContentShareManager {
private:
bool _isSharing = false;
bool _isCapturing = false;
bool _isPaused = false;
QString _currentSharedFile;
int _contentVolume = 80;
bool _dualScreenMode = false;
public:
// 共享控制
void startSharing() {
if (!_isSharing) {
NemoSdkAdaptor::getInstance()->startContentSharing();
_isSharing = true;
}
}
void stopSharing() {
if (_isSharing) {
NemoSdkAdaptor::getInstance()->stopContentSharing();
_isSharing = false;
_isCapturing = false;
_isPaused = false;
}
}
// 内容采集控制
void startCapture() {
if (!_isCapturing) {
NemoSdkAdaptor::getInstance()->startContentCapture();
_isCapturing = true;
_isPaused = false;
}
}
void pauseCapture() {
if (_isCapturing && !_isPaused) {
NemoSdkAdaptor::getInstance()->pauseContentCapture();
_isPaused = true;
}
}
void resumeCapture() {
if (_isCapturing && _isPaused) {
NemoSdkAdaptor::getInstance()->resumeContentCapture();
_isPaused = false;
}
}
void stopCapture() {
if (_isCapturing) {
NemoSdkAdaptor::getInstance()->stopContentCapture();
_isCapturing = false;
_isPaused = false;
}
}
// 共享设置
void setNotIgnoreCaptureWnd(bool notIgnore) {
NemoSdkAdaptor::getInstance()->setNotIgnoreCaptureWnd(notIgnore);
}
void setNotExcludeWnd(bool notExclude) {
NemoSdkAdaptor::getInstance()->setNotExcludeWnd(notExclude);
}
void setDualScreenMode(bool enable) {
_dualScreenMode = enable;
NemoSdkAdaptor::getInstance()->setEnableDualScreenMode(enable);
}
// 应用管理
void getTopLevelApps() {
NemoSdkAdaptor::getInstance()->getTopLevelAppList();
}
void getWindowVisibleArea(void* windowHandle) {
NemoSdkAdaptor::getInstance()->getAppWindowVisibleArea(windowHandle);
}
void getMonitorThumbnail() {
NemoSdkAdaptor::getInstance()->getMonitorThumbnail();
}
// 媒体文件共享
void getMediaFileInfo(const QString& filePath) {
_currentSharedFile = filePath;
NemoSdkAdaptor::getInstance()->getMediaFileInfo(filePath.toStdString());
}
void seekToTime(double time) {
NemoSdkAdaptor::getInstance()->setContentSeekTo(time);
}
void setContentVolume(int volume) {
_contentVolume = qBound(0, volume, 100);
NemoSdkAdaptor::getInstance()->setContentVolume(_contentVolume);
}
// 音频控制
void setMultiContentAudio(bool enable) {
NemoSdkAdaptor::getInstance()->setEnableMutilContent(enable);
}
void setSpeakerChangeListener(bool need) {
NemoSdkAdaptor::getInstance()->needSpeakerChanged(need);
}
// 内容状态变化回调
void onContentStateChanged(XYContentState state) {
qDebug() << "Content state changed:" << state;
switch (state) {
case XYContentState_Started:
_isSharing = true;
break;
case XYContentState_Stopped:
_isSharing = false;
_isCapturing = false;
_isPaused = false;
break;
case XYContentState_Paused:
_isPaused = true;
break;
case XYContentState_Resumed:
_isPaused = false;
break;
}
emit contentStateChanged(state);
}
// 应用窗口捕获状态变化回调
void onAppWindowCaptureStateChanged(const XYString& appName, bool isCapturing) {
QString appNameStr(appName.str());
qDebug() << "App window capture state changed:" << appNameStr << "isCapturing:" << isCapturing;
emit appWindowCaptureStateChanged(appNameStr, isCapturing);
}
// 共享媒体文件状态变化回调
void onShareMediaFileStatusChanged(const XYString& filePath, XYMediaFileStatus status) {
QString filePathStr(filePath.str());
qDebug() << "Share media file status changed:" << filePathStr << "status:" << status;
emit shareMediaFileStatusChanged(filePathStr, status);
}
// 媒体文件开始回调
void onMediaFileStart(const XYString& filePath) {
QString filePathStr(filePath.str());
qDebug() << "Media file started:" << filePathStr;
emit mediaFileStarted(filePathStr);
}
// 媒体文件停止回调
void onMediaFileStop(const XYString& filePath) {
QString filePathStr(filePath.str());
qDebug() << "Media file stopped:" << filePathStr;
emit mediaFileStopped(filePathStr);
}
// 应用窗口可见区域回调
void onAppWindowVisibleArea(const XYString& appName, const XYRect& area) {
QString appNameStr(appName.str());
qDebug() << "App window visible area:" << appNameStr << "area:" << area.x << area.y << area.width << area.height;
emit appWindowVisibleAreaChanged(appNameStr, area);
}
// Getter方法
bool isSharing() const { return _isSharing; }
bool isCapturing() const { return _isCapturing; }
bool isPaused() const { return _isPaused; }
QString getCurrentSharedFile() const { return _currentSharedFile; }
int getContentVolume() const { return _contentVolume; }
bool isDualScreenMode() const { return _dualScreenMode; }
};
状态 | 说明 |
| 内容共享已开始 |
| 内容共享已停止 |
| 内容共享已暂停 |
| 内容共享已恢复 |
状态 | 说明 |
| 正在播放 |
| 已暂停 |
| 已停止 |
| 播放完成 |
方法 | 描述 | 链接 |
开始共享 | ||
停止内容共享 |
方法 | 描述 | 链接 |
开始进行共享内容采集 | ||
暂停共享内容采集 | ||
恢复共享内容采集 | ||
停止共享内容采集 |
方法 | 描述 | 链接 |
共享是否关闭扣掉小鱼程序 | ||
设置wgc适配属性窗口是否不设置蓝框和标注窗口 | ||
设置是否开启双屏模式 |
方法 | 描述 | 链接 |
获得分享桌面中的最顶层应用列表 | ||
根据窗口句柄获取窗口的显示区域 | ||
获取显示器截图 |
方法 | 描述 | 链接 |
根据文件路径获取文件的信息 | ||
采集共享文件的某一个时间点的内容 | ||
调正共享的音视频声音大小 |
方法 | 描述 | 链接 |
设置是否开启多路共享音频 | ||
设置是否需要监听当前speaker变化 |
回调 | 描述 | 链接 |
内容状态变化回调 | ||
应用窗口捕获状态变化回调 | ||
共享媒体文件状态变化回调 | ||
媒体文件开始回调 | ||
媒体文件停止回调 | ||
应用窗口可见区域回调 |
枚举 | 描述 | 链接 |
内容状态枚举 | ||
媒体文件状态枚举 |