增加多屏显示,视频播放
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
using UnrealBuildTool;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class SpaceStudioClientTarget : TargetRules
|
||||
{
|
||||
public SpaceStudioClientTarget(TargetInfo Target) : base(Target)
|
||||
{
|
||||
Type = TargetType.Game;
|
||||
DefaultBuildSettings = BuildSettingsVersion.V4;
|
||||
|
||||
ExtraModuleNames.AddRange( new string[] { "SpaceStudioClient" } );
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
|
||||
#include "MyActor.h"
|
||||
|
||||
// Sets default values
|
||||
AMyActor::AMyActor()
|
||||
{
|
||||
// Set this actor to call Tick() every frame. You can turn this off to improve performance if you don't need it.
|
||||
PrimaryActorTick.bCanEverTick = true;
|
||||
|
||||
}
|
||||
|
||||
// Called when the game starts or when spawned
|
||||
void AMyActor::BeginPlay()
|
||||
{
|
||||
Super::BeginPlay();
|
||||
|
||||
}
|
||||
|
||||
// Called every frame
|
||||
void AMyActor::Tick(float DeltaTime)
|
||||
{
|
||||
Super::Tick(DeltaTime);
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,133 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
#include "MyBlueprintFunctionLibrary.h"
|
||||
|
||||
#include <windows.h>
|
||||
#include <mmdeviceapi.h>
|
||||
#include <endpointvolume.h>
|
||||
#include <audioclient.h>
|
||||
#include <iostream>
|
||||
#pragma comment(lib, "ole32.lib")
|
||||
|
||||
// 获取当前系统音量
|
||||
float _GetSystemVolume() {
|
||||
HRESULT hr;
|
||||
IMMDeviceEnumerator* pEnumerator = NULL;
|
||||
IMMDevice* pDevice = NULL;
|
||||
IAudioEndpointVolume* pEndpointVolume = NULL;
|
||||
float currentVolume = 0.0f;
|
||||
|
||||
// 初始化COM库
|
||||
hr = CoInitialize(NULL);
|
||||
if (FAILED(hr)) {
|
||||
UE_LOG(LogTemp, Warning, TEXT("COM初始化失败"));
|
||||
return -1.0f;
|
||||
}
|
||||
|
||||
// 创建设备枚举器
|
||||
hr = CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL, CLSCTX_ALL,
|
||||
__uuidof(IMMDeviceEnumerator), (void**)&pEnumerator);
|
||||
if (FAILED(hr)) {
|
||||
UE_LOG(LogTemp, Warning, TEXT("创建设备枚举器失败"));
|
||||
CoUninitialize();
|
||||
return -1.0f;
|
||||
}
|
||||
|
||||
// 获取默认音频端点
|
||||
hr = pEnumerator->GetDefaultAudioEndpoint(eRender, eConsole, &pDevice);
|
||||
if (FAILED(hr)) {
|
||||
UE_LOG(LogTemp, Warning, TEXT("获取默认音频端点失败"));
|
||||
pEnumerator->Release();
|
||||
CoUninitialize();
|
||||
return -1.0f;
|
||||
}
|
||||
|
||||
// 激活音频端点音量接口
|
||||
hr = pDevice->Activate(__uuidof(IAudioEndpointVolume), CLSCTX_ALL, NULL, (void**)&pEndpointVolume);
|
||||
if (FAILED(hr)) {
|
||||
UE_LOG(LogTemp, Warning, TEXT("激活音频端点音量接口失败"));
|
||||
pDevice->Release();
|
||||
pEnumerator->Release();
|
||||
CoUninitialize();
|
||||
return -1.0f;
|
||||
}
|
||||
|
||||
// 获取当前音量
|
||||
hr = pEndpointVolume->GetMasterVolumeLevelScalar(¤tVolume);
|
||||
if (FAILED(hr)) {
|
||||
UE_LOG(LogTemp, Warning, TEXT("获取音量失败"));
|
||||
}
|
||||
|
||||
// 释放资源
|
||||
pEndpointVolume->Release();
|
||||
pDevice->Release();
|
||||
pEnumerator->Release();
|
||||
CoUninitialize();
|
||||
|
||||
return currentVolume;
|
||||
}
|
||||
|
||||
// 设置系统音量
|
||||
bool _SetSystemVolume(float volume) {
|
||||
HRESULT hr;
|
||||
IMMDeviceEnumerator* pEnumerator = NULL;
|
||||
IMMDevice* pDevice = NULL;
|
||||
IAudioEndpointVolume* pEndpointVolume = NULL;
|
||||
|
||||
// 初始化COM库
|
||||
hr = CoInitialize(NULL);
|
||||
if (FAILED(hr)) {
|
||||
UE_LOG(LogTemp, Warning, TEXT("COM初始化失败"));
|
||||
return false;
|
||||
}
|
||||
|
||||
// 创建设备枚举器
|
||||
hr = CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL, CLSCTX_ALL,
|
||||
__uuidof(IMMDeviceEnumerator), (void**)&pEnumerator);
|
||||
if (FAILED(hr)) {
|
||||
UE_LOG(LogTemp, Warning, TEXT("创建设备枚举器失败"));
|
||||
CoUninitialize();
|
||||
return false;
|
||||
}
|
||||
|
||||
// 获取默认音频端点
|
||||
hr = pEnumerator->GetDefaultAudioEndpoint(eRender, eConsole, &pDevice);
|
||||
if (FAILED(hr)) {
|
||||
UE_LOG(LogTemp, Warning, TEXT("获取默认音频端点失败"));
|
||||
pEnumerator->Release();
|
||||
CoUninitialize();
|
||||
return false;
|
||||
}
|
||||
|
||||
// 激活音频端点音量接口
|
||||
hr = pDevice->Activate(__uuidof(IAudioEndpointVolume), CLSCTX_ALL, NULL, (void**)&pEndpointVolume);
|
||||
if (FAILED(hr)) {
|
||||
UE_LOG(LogTemp, Warning, TEXT("激活音频端点音量接口失败"));
|
||||
pDevice->Release();
|
||||
pEnumerator->Release();
|
||||
CoUninitialize();
|
||||
return false;
|
||||
}
|
||||
|
||||
// 设置音量
|
||||
hr = pEndpointVolume->SetMasterVolumeLevelScalar(volume, NULL);
|
||||
if (FAILED(hr)) {
|
||||
UE_LOG(LogTemp, Warning, TEXT("设置音量失败"));
|
||||
}
|
||||
|
||||
// 释放资源
|
||||
pEndpointVolume->Release();
|
||||
pDevice->Release();
|
||||
pEnumerator->Release();
|
||||
CoUninitialize();
|
||||
|
||||
return SUCCEEDED(hr);
|
||||
}
|
||||
bool UMyBlueprintFunctionLibrary::SetSystemVolume(float volume)
|
||||
{
|
||||
return _SetSystemVolume(volume);
|
||||
}
|
||||
|
||||
float UMyBlueprintFunctionLibrary::GetSystemVolume()
|
||||
{
|
||||
return _GetSystemVolume();
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "GameFramework/Actor.h"
|
||||
#include "MyActor.generated.h"
|
||||
|
||||
UCLASS()
|
||||
class SPACESTUDIOCLIENT_API AMyActor : public AActor
|
||||
{
|
||||
GENERATED_BODY()
|
||||
|
||||
public:
|
||||
// Sets default values for this actor's properties
|
||||
AMyActor();
|
||||
|
||||
protected:
|
||||
// Called when the game starts or when spawned
|
||||
virtual void BeginPlay() override;
|
||||
|
||||
public:
|
||||
// Called every frame
|
||||
virtual void Tick(float DeltaTime) override;
|
||||
|
||||
};
|
||||
@@ -0,0 +1,21 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
#include "Kismet/BlueprintFunctionLibrary.h"
|
||||
#include "MyBlueprintFunctionLibrary.generated.h"
|
||||
|
||||
/**
|
||||
*
|
||||
*/
|
||||
UCLASS()
|
||||
class SPACESTUDIOCLIENT_API UMyBlueprintFunctionLibrary : public UBlueprintFunctionLibrary
|
||||
{
|
||||
GENERATED_BODY()
|
||||
UFUNCTION(BlueprintCallable, Category = "MyLibrary|Sound", meta = (DisplayName = "set system volume"))
|
||||
static bool SetSystemVolume(float volume);
|
||||
|
||||
UFUNCTION(BlueprintCallable, Category = "MyLibrary|Sound", meta = (DisplayName = "get system volume"))
|
||||
static float GetSystemVolume();
|
||||
};
|
||||
@@ -0,0 +1,23 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
using UnrealBuildTool;
|
||||
|
||||
public class SpaceStudioClient : ModuleRules
|
||||
{
|
||||
public SpaceStudioClient(ReadOnlyTargetRules Target) : base(Target)
|
||||
{
|
||||
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
|
||||
|
||||
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine", "InputCore" });
|
||||
|
||||
PrivateDependencyModuleNames.AddRange(new string[] { });
|
||||
|
||||
// Uncomment if you are using Slate UI
|
||||
// PrivateDependencyModuleNames.AddRange(new string[] { "Slate", "SlateCore" });
|
||||
|
||||
// Uncomment if you are using online features
|
||||
// PrivateDependencyModuleNames.Add("OnlineSubsystem");
|
||||
|
||||
// To include OnlineSubsystemSteam, add it to the plugins section in your uproject file with the Enabled attribute set to true
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#include "SpaceStudioClient.h"
|
||||
#include "Modules/ModuleManager.h"
|
||||
|
||||
IMPLEMENT_PRIMARY_GAME_MODULE( FDefaultGameModuleImpl, SpaceStudioClient, "SpaceStudioClient" );
|
||||
@@ -0,0 +1,6 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "CoreMinimal.h"
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
// Fill out your copyright notice in the Description page of Project Settings.
|
||||
|
||||
using UnrealBuildTool;
|
||||
using System.Collections.Generic;
|
||||
|
||||
public class SpaceStudioClientEditorTarget : TargetRules
|
||||
{
|
||||
public SpaceStudioClientEditorTarget(TargetInfo Target) : base(Target)
|
||||
{
|
||||
Type = TargetType.Editor;
|
||||
DefaultBuildSettings = BuildSettingsVersion.V4;
|
||||
|
||||
ExtraModuleNames.AddRange( new string[] { "SpaceStudioClient" } );
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user