mirror of
https://github.com/WarmUpTill/SceneSwitcher.git
synced 2026-09-07 00:56:00 -05:00
Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
8a603b1675 | ||
|
|
67dda18929 | ||
|
|
e11499c308 | ||
|
|
e76df589e2 | ||
|
|
1390565fc6 | ||
|
|
d76a37c785 | ||
|
|
ce8a35adea | ||
|
|
9030ba1adf |
16
.github/workflows/build-project.yaml
vendored
16
.github/workflows/build-project.yaml
vendored
@@ -249,6 +249,14 @@ jobs:
|
|||||||
name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-sources-${{ needs.check-event.outputs.commitHash }}
|
name: ${{ steps.setup.outputs.pluginName }}-${{ steps.setup.outputs.pluginVersion }}-sources-${{ needs.check-event.outputs.commitHash }}
|
||||||
path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-*-source.*
|
path: ${{ github.workspace }}/release/${{ steps.setup.outputs.pluginName }}-*-source.*
|
||||||
|
|
||||||
|
- name: Rename artifacts for Ubuntu 24 🏷️
|
||||||
|
run: |
|
||||||
|
: Rename artifacts for Ubuntu 24 🏷️
|
||||||
|
for f in ${{ github.workspace }}/release/*-x86_64-linux-gnu.*; do
|
||||||
|
[ -e "${f}" ] || continue
|
||||||
|
mv "${f}" "${f/x86_64-linux-gnu/x86_64-ubuntu24.04-linux-gnu}"
|
||||||
|
done
|
||||||
|
|
||||||
- name: Upload Artifacts 📡
|
- name: Upload Artifacts 📡
|
||||||
uses: actions/upload-artifact@v7
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
@@ -320,6 +328,14 @@ jobs:
|
|||||||
target: x86_64
|
target: x86_64
|
||||||
config: ${{ needs.check-event.outputs.config }}
|
config: ${{ needs.check-event.outputs.config }}
|
||||||
|
|
||||||
|
- name: Rename artifacts for Ubuntu 26 🏷️
|
||||||
|
run: |
|
||||||
|
: Rename artifacts for Ubuntu 26 🏷️
|
||||||
|
for f in ${{ github.workspace }}/release/*-x86_64-linux-gnu.*; do
|
||||||
|
[ -e "${f}" ] || continue
|
||||||
|
mv "${f}" "${f/x86_64-linux-gnu/x86_64-ubuntu26.04-linux-gnu}"
|
||||||
|
done
|
||||||
|
|
||||||
- name: Upload Artifacts 📡
|
- name: Upload Artifacts 📡
|
||||||
uses: actions/upload-artifact@v7
|
uses: actions/upload-artifact@v7
|
||||||
with:
|
with:
|
||||||
|
|||||||
1
.github/workflows/push.yaml
vendored
1
.github/workflows/push.yaml
vendored
@@ -78,6 +78,7 @@ jobs:
|
|||||||
'windows-x64;zip|exe'
|
'windows-x64;zip|exe'
|
||||||
'macos-universal;tar.xz|pkg'
|
'macos-universal;tar.xz|pkg'
|
||||||
'ubuntu-24.04-x86_64;tar.xz|deb|ddeb'
|
'ubuntu-24.04-x86_64;tar.xz|deb|ddeb'
|
||||||
|
'ubuntu-26.04-x86_64;tar.xz|deb|ddeb'
|
||||||
'sources;tar.xz'
|
'sources;tar.xz'
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|||||||
@@ -191,14 +191,21 @@ function(_check_dependencies)
|
|||||||
foreach(i RANGE 1 ${MAX_DOWNLOAD_RETRIES})
|
foreach(i RANGE 1 ${MAX_DOWNLOAD_RETRIES})
|
||||||
message(STATUS "Attempt ${i}/${MAX_DOWNLOAD_RETRIES} for ${url}")
|
message(STATUS "Attempt ${i}/${MAX_DOWNLOAD_RETRIES} for ${url}")
|
||||||
|
|
||||||
file(
|
file(DOWNLOAD "${url}" "${dependencies_dir}/${file}"
|
||||||
DOWNLOAD "${url}" "${dependencies_dir}/${file}"
|
STATUS download_status)
|
||||||
STATUS download_status
|
|
||||||
EXPECTED_HASH SHA256=${hash})
|
|
||||||
|
|
||||||
list(GET download_status 0 error_code)
|
list(GET download_status 0 error_code)
|
||||||
list(GET download_status 1 error_message)
|
list(GET download_status 1 error_message)
|
||||||
|
|
||||||
|
if(error_code EQUAL 0)
|
||||||
|
file(SHA256 "${dependencies_dir}/${file}" actual_hash)
|
||||||
|
if(NOT actual_hash STREQUAL hash)
|
||||||
|
set(error_code 1)
|
||||||
|
set(error_message
|
||||||
|
"hash mismatch (expected ${hash}, got ${actual_hash})")
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
if(error_code EQUAL 0)
|
if(error_code EQUAL 0)
|
||||||
message(STATUS "Downloading ${url} - success on attempt ${i}")
|
message(STATUS "Downloading ${url} - success on attempt ${i}")
|
||||||
set(download_success TRUE)
|
set(download_success TRUE)
|
||||||
|
|||||||
@@ -342,7 +342,9 @@ AdvSceneSwitcher.condition.audio.type.volume="Configured volume level"
|
|||||||
AdvSceneSwitcher.condition.audio.type.syncOffset="Sync offset"
|
AdvSceneSwitcher.condition.audio.type.syncOffset="Sync offset"
|
||||||
AdvSceneSwitcher.condition.audio.type.monitor="Audio monitoring"
|
AdvSceneSwitcher.condition.audio.type.monitor="Audio monitoring"
|
||||||
AdvSceneSwitcher.condition.audio.type.balance="Audio balance"
|
AdvSceneSwitcher.condition.audio.type.balance="Audio balance"
|
||||||
|
AdvSceneSwitcher.condition.audio.type.track="Audio track"
|
||||||
AdvSceneSwitcher.condition.audio.entry="{{checkType}}of{{audioSources}}is{{condition}}{{volume}}{{volumeDB}}{{percentDBToggle}}{{syncOffset}}{{monitorTypes}}"
|
AdvSceneSwitcher.condition.audio.entry="{{checkType}}of{{audioSources}}is{{condition}}{{volume}}{{volumeDB}}{{percentDBToggle}}{{syncOffset}}{{monitorTypes}}"
|
||||||
|
AdvSceneSwitcher.condition.audio.layout.track="{{audioSources}}is enabled on{{checkType}}{{track}}"
|
||||||
AdvSceneSwitcher.condition.cursor="Cursor"
|
AdvSceneSwitcher.condition.cursor="Cursor"
|
||||||
AdvSceneSwitcher.condition.cursor.type.region="is in region"
|
AdvSceneSwitcher.condition.cursor.type.region="is in region"
|
||||||
AdvSceneSwitcher.condition.cursor.type.moving="is moving"
|
AdvSceneSwitcher.condition.cursor.type.moving="is moving"
|
||||||
@@ -904,9 +906,19 @@ AdvSceneSwitcher.condition.streamDeck.stopListen="Stop listening"
|
|||||||
AdvSceneSwitcher.condition.streamDeck.pluginDownload="<html><head/><body><p>The Stream Deck plugin can be found <a href=\"https://github.com/WarmUpTill/advanced-scene-switcher-streamdeck-plugin/releases\"><span style=\" text-decoration: underline; color:#268bd2;\">here on GitHub</span></a>.</p></body></html>"
|
AdvSceneSwitcher.condition.streamDeck.pluginDownload="<html><head/><body><p>The Stream Deck plugin can be found <a href=\"https://github.com/WarmUpTill/advanced-scene-switcher-streamdeck-plugin/releases\"><span style=\" text-decoration: underline; color:#268bd2;\">here on GitHub</span></a>.</p></body></html>"
|
||||||
AdvSceneSwitcher.condition.gameCapture="Game capture"
|
AdvSceneSwitcher.condition.gameCapture="Game capture"
|
||||||
AdvSceneSwitcher.condition.gameCapture.entry="{{sources}}hooked a game."
|
AdvSceneSwitcher.condition.gameCapture.entry="{{sources}}hooked a game."
|
||||||
|
|
||||||
AdvSceneSwitcher.condition.screenshot="Screenshot"
|
AdvSceneSwitcher.condition.screenshot="Screenshot"
|
||||||
AdvSceneSwitcher.condition.screenshot.entry="A screenshot was taken"
|
AdvSceneSwitcher.condition.screenshot.entry="A screenshot was taken"
|
||||||
|
AdvSceneSwitcher.condition.nowPlaying="Now Playing"
|
||||||
|
AdvSceneSwitcher.condition.nowPlaying.checkType.playbackState="Playback state"
|
||||||
|
AdvSceneSwitcher.condition.nowPlaying.checkType.title="Title"
|
||||||
|
AdvSceneSwitcher.condition.nowPlaying.checkType.artist="Artist"
|
||||||
|
AdvSceneSwitcher.condition.nowPlaying.checkType.album="Album"
|
||||||
|
AdvSceneSwitcher.condition.nowPlaying.checkType.appName="App name"
|
||||||
|
AdvSceneSwitcher.condition.nowPlaying.playbackState.playing="Playing"
|
||||||
|
AdvSceneSwitcher.condition.nowPlaying.playbackState.paused="Paused"
|
||||||
|
AdvSceneSwitcher.condition.nowPlaying.playbackState.stopped="Stopped"
|
||||||
|
AdvSceneSwitcher.condition.nowPlaying.playbackState.opening="Opening"
|
||||||
|
AdvSceneSwitcher.condition.nowPlaying.playbackState.changing="Changing"
|
||||||
AdvSceneSwitcher.condition.mqtt="MQTT"
|
AdvSceneSwitcher.condition.mqtt="MQTT"
|
||||||
AdvSceneSwitcher.condition.mqtt.layout.match="Message was received from{{connection}} which matches{{regex}}:"
|
AdvSceneSwitcher.condition.mqtt.layout.match="Message was received from{{connection}} which matches{{regex}}:"
|
||||||
AdvSceneSwitcher.condition.mqtt.layout.listen="Set message selection to incoming message:{{listenButton}}"
|
AdvSceneSwitcher.condition.mqtt.layout.listen="Set message selection to incoming message:{{listenButton}}"
|
||||||
@@ -2364,6 +2376,7 @@ AdvSceneSwitcher.tempVar.audio.muted="Source muted"
|
|||||||
AdvSceneSwitcher.tempVar.audio.sync_offset="Source audio sync offset"
|
AdvSceneSwitcher.tempVar.audio.sync_offset="Source audio sync offset"
|
||||||
AdvSceneSwitcher.tempVar.audio.monitor="Source audio monitor type"
|
AdvSceneSwitcher.tempVar.audio.monitor="Source audio monitor type"
|
||||||
AdvSceneSwitcher.tempVar.audio.balance="Source audio balance"
|
AdvSceneSwitcher.tempVar.audio.balance="Source audio balance"
|
||||||
|
AdvSceneSwitcher.tempVar.audio.trackEnabled="Audio track enabled"
|
||||||
|
|
||||||
AdvSceneSwitcher.tempVar.clipboard.mimeType.primary="Primary clipboard item MIME type"
|
AdvSceneSwitcher.tempVar.clipboard.mimeType.primary="Primary clipboard item MIME type"
|
||||||
AdvSceneSwitcher.tempVar.clipboard.mimeType.primary.description="Highest priority MIME type of the current item stored in clipboard, if available."
|
AdvSceneSwitcher.tempVar.clipboard.mimeType.primary.description="Highest priority MIME type of the current item stored in clipboard, if available."
|
||||||
@@ -2599,6 +2612,12 @@ AdvSceneSwitcher.tempVar.gameCapture.class.description="Window class of the appl
|
|||||||
AdvSceneSwitcher.tempVar.gameCapture.executable="Executable"
|
AdvSceneSwitcher.tempVar.gameCapture.executable="Executable"
|
||||||
AdvSceneSwitcher.tempVar.gameCapture.executable.description="Executable name of the application captured by the source."
|
AdvSceneSwitcher.tempVar.gameCapture.executable.description="Executable name of the application captured by the source."
|
||||||
|
|
||||||
|
AdvSceneSwitcher.tempVar.nowPlaying.title="Title"
|
||||||
|
AdvSceneSwitcher.tempVar.nowPlaying.artist="Artist"
|
||||||
|
AdvSceneSwitcher.tempVar.nowPlaying.album="Album"
|
||||||
|
AdvSceneSwitcher.tempVar.nowPlaying.appName="App name"
|
||||||
|
AdvSceneSwitcher.tempVar.nowPlaying.playbackStatus="Playback status"
|
||||||
|
|
||||||
AdvSceneSwitcher.tempVar.http.status="Status code"
|
AdvSceneSwitcher.tempVar.http.status="Status code"
|
||||||
AdvSceneSwitcher.tempVar.http.error="Error"
|
AdvSceneSwitcher.tempVar.http.error="Error"
|
||||||
AdvSceneSwitcher.tempVar.http.error.description="Empty when no error occurred.\nOther possible values:\n\n * Could not establish connection\n * Failed to bind IP address\n * Failed to read connection\n * Failed to write connection\n * Maximum redirect count exceeded\n * Connection handling canceled\n * SSL connection failed\n * SSL certificate loading failed\n * SSL server verification failed\n * Unsupported HTTP multipart boundary characters\n * Compression failed\n * Connection timed out\n * Proxy connection failed\n * Unknown"
|
AdvSceneSwitcher.tempVar.http.error.description="Empty when no error occurred.\nOther possible values:\n\n * Could not establish connection\n * Failed to bind IP address\n * Failed to read connection\n * Failed to write connection\n * Maximum redirect count exceeded\n * Connection handling canceled\n * SSL connection failed\n * SSL certificate loading failed\n * SSL server verification failed\n * Unsupported HTTP multipart boundary characters\n * Compression failed\n * Connection timed out\n * Proxy connection failed\n * Unknown"
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -1,6 +1,7 @@
|
|||||||
#include "websocket-api.hpp"
|
#include "websocket-api.hpp"
|
||||||
#include "obs-websocket-api.h"
|
#include "obs-websocket-api.h"
|
||||||
#include "plugin-state-helpers.hpp"
|
#include "plugin-state-helpers.hpp"
|
||||||
|
#include "version.h"
|
||||||
|
|
||||||
// Must be after "obs-websocket-api.h" to avoid logging function conflict
|
// Must be after "obs-websocket-api.h" to avoid logging function conflict
|
||||||
#include "log-helper.hpp"
|
#include "log-helper.hpp"
|
||||||
@@ -15,6 +16,7 @@ static constexpr char VendorName[] = "AdvancedSceneSwitcher";
|
|||||||
static constexpr char VendorRequestStart[] = "AdvancedSceneSwitcherStart";
|
static constexpr char VendorRequestStart[] = "AdvancedSceneSwitcherStart";
|
||||||
static constexpr char VendorRequestStop[] = "AdvancedSceneSwitcherStop";
|
static constexpr char VendorRequestStop[] = "AdvancedSceneSwitcherStop";
|
||||||
static constexpr char VendorRequestStatus[] = "IsAdvancedSceneSwitcherRunning";
|
static constexpr char VendorRequestStatus[] = "IsAdvancedSceneSwitcherRunning";
|
||||||
|
static constexpr char VendorRequestVersion[] = "AdvancedSceneSwitcherVersion";
|
||||||
static obs_websocket_vendor vendor;
|
static obs_websocket_vendor vendor;
|
||||||
|
|
||||||
static void registerWebsocketVendor();
|
static void registerWebsocketVendor();
|
||||||
@@ -82,6 +84,12 @@ static void registerWebsocketVendor()
|
|||||||
obs_data_set_bool(response, "isRunning",
|
obs_data_set_bool(response, "isRunning",
|
||||||
PluginIsRunning());
|
PluginIsRunning());
|
||||||
});
|
});
|
||||||
|
registerWebsocketVendorRequest(
|
||||||
|
VendorRequestVersion,
|
||||||
|
[](obs_data_t *, obs_data_t *response, void *) {
|
||||||
|
obs_data_set_string(response, "version", g_GIT_TAG);
|
||||||
|
obs_data_set_string(response, "commit", g_GIT_SHA1);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const char *GetWebsocketVendorName()
|
const char *GetWebsocketVendorName()
|
||||||
|
|||||||
@@ -42,6 +42,7 @@ add_plugin(twitch)
|
|||||||
add_plugin(usb)
|
add_plugin(usb)
|
||||||
add_plugin(video)
|
add_plugin(video)
|
||||||
add_plugin(speech)
|
add_plugin(speech)
|
||||||
|
add_plugin(now-playing)
|
||||||
|
|
||||||
# ---------------------------------------------------------------------------- #
|
# ---------------------------------------------------------------------------- #
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,9 @@
|
|||||||
#include "macro-action-scene-collection.hpp"
|
#include "macro-action-scene-collection.hpp"
|
||||||
|
|
||||||
#include "layout-helpers.hpp"
|
#include "layout-helpers.hpp"
|
||||||
#include "plugin-state-helpers.hpp"
|
#include "plugin-state-helpers.hpp"
|
||||||
#include "selection-helpers.hpp"
|
#include "selection-helpers.hpp"
|
||||||
|
#include "ui-helpers.hpp"
|
||||||
|
|
||||||
#include <obs-frontend-api.h>
|
#include <obs-frontend-api.h>
|
||||||
|
|
||||||
@@ -15,6 +17,20 @@ bool MacroActionSceneCollection::_registered = MacroActionFactory::Register(
|
|||||||
MacroActionSceneCollectionEdit::Create,
|
MacroActionSceneCollectionEdit::Create,
|
||||||
"AdvSceneSwitcher.action.sceneCollection"});
|
"AdvSceneSwitcher.action.sceneCollection"});
|
||||||
|
|
||||||
|
template<typename F> void QueueUITaskLambda(F &&func)
|
||||||
|
{
|
||||||
|
using FnType = std::decay_t<F>;
|
||||||
|
auto *heapFunc = new FnType(std::forward<F>(func));
|
||||||
|
|
||||||
|
QueueUITask(
|
||||||
|
[](void *param) {
|
||||||
|
std::unique_ptr<FnType> fn(
|
||||||
|
static_cast<FnType *>(param));
|
||||||
|
(*fn)();
|
||||||
|
},
|
||||||
|
heapFunc);
|
||||||
|
}
|
||||||
|
|
||||||
bool MacroActionSceneCollection::PerformAction()
|
bool MacroActionSceneCollection::PerformAction()
|
||||||
{
|
{
|
||||||
// Changing the scene collection will also reload the settings of the
|
// Changing the scene collection will also reload the settings of the
|
||||||
@@ -23,7 +39,13 @@ bool MacroActionSceneCollection::PerformAction()
|
|||||||
if (SettingsWindowIsOpened()) {
|
if (SettingsWindowIsOpened()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
obs_frontend_set_current_scene_collection(_sceneCollection.c_str());
|
|
||||||
|
const auto collectionName = _sceneCollection;
|
||||||
|
QueueUITaskLambda([collectionName]() {
|
||||||
|
obs_frontend_set_current_scene_collection(
|
||||||
|
collectionName.c_str());
|
||||||
|
});
|
||||||
|
|
||||||
// It does not make sense to continue as the current settings will be
|
// It does not make sense to continue as the current settings will be
|
||||||
// invalid after switching scene collection.
|
// invalid after switching scene collection.
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -25,6 +25,8 @@ const static std::map<MacroConditionAudio::Type, std::string> checkTypes = {
|
|||||||
"AdvSceneSwitcher.condition.audio.type.monitor"},
|
"AdvSceneSwitcher.condition.audio.type.monitor"},
|
||||||
{MacroConditionAudio::Type::BALANCE,
|
{MacroConditionAudio::Type::BALANCE,
|
||||||
"AdvSceneSwitcher.condition.audio.type.balance"},
|
"AdvSceneSwitcher.condition.audio.type.balance"},
|
||||||
|
{MacroConditionAudio::Type::TRACK,
|
||||||
|
"AdvSceneSwitcher.condition.audio.type.track"},
|
||||||
};
|
};
|
||||||
|
|
||||||
const static std::map<MacroConditionAudio::OutputCondition, std::string>
|
const static std::map<MacroConditionAudio::OutputCondition, std::string>
|
||||||
@@ -245,6 +247,20 @@ bool MacroConditionAudio::CheckBalance()
|
|||||||
return ret && source;
|
return ret && source;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool MacroConditionAudio::CheckTrack()
|
||||||
|
{
|
||||||
|
if (!_audioSource.GetSource()) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
OBSSourceAutoRelease source =
|
||||||
|
obs_weak_source_get_source(_audioSource.GetSource());
|
||||||
|
uint32_t mixers = obs_source_get_audio_mixers(source);
|
||||||
|
bool enabled = (mixers >> (uint32_t)(_track - 1)) & 1u;
|
||||||
|
SetTempVarValue("track_enabled", enabled ? "true" : "false");
|
||||||
|
return enabled && source;
|
||||||
|
}
|
||||||
|
|
||||||
bool MacroConditionAudio::CheckCondition()
|
bool MacroConditionAudio::CheckCondition()
|
||||||
{
|
{
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
@@ -264,6 +280,9 @@ bool MacroConditionAudio::CheckCondition()
|
|||||||
case Type::BALANCE:
|
case Type::BALANCE:
|
||||||
ret = CheckBalance();
|
ret = CheckBalance();
|
||||||
break;
|
break;
|
||||||
|
case Type::TRACK:
|
||||||
|
ret = CheckTrack();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (GetVariableValue().empty()) {
|
if (GetVariableValue().empty()) {
|
||||||
@@ -281,6 +300,7 @@ bool MacroConditionAudio::Save(obs_data_t *obj) const
|
|||||||
_volumePercent.Save(obj, "volume");
|
_volumePercent.Save(obj, "volume");
|
||||||
_syncOffset.Save(obj, "syncOffset");
|
_syncOffset.Save(obj, "syncOffset");
|
||||||
_balance.Save(obj, "balance");
|
_balance.Save(obj, "balance");
|
||||||
|
_track.Save(obj, "track");
|
||||||
obs_data_set_int(obj, "checkType", static_cast<int>(_checkType));
|
obs_data_set_int(obj, "checkType", static_cast<int>(_checkType));
|
||||||
obs_data_set_int(obj, "outputCondition",
|
obs_data_set_int(obj, "outputCondition",
|
||||||
static_cast<int>(_outputCondition));
|
static_cast<int>(_outputCondition));
|
||||||
@@ -346,6 +366,7 @@ bool MacroConditionAudio::Load(obs_data_t *obj)
|
|||||||
_useDb = obs_data_get_bool(obj, "useDb");
|
_useDb = obs_data_get_bool(obj, "useDb");
|
||||||
_volumeDB.Load(obj, "volumeDB");
|
_volumeDB.Load(obj, "volumeDB");
|
||||||
}
|
}
|
||||||
|
_track.Load(obj, "track");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -421,6 +442,12 @@ void MacroConditionAudio::SetupTempVars()
|
|||||||
obs_module_text(
|
obs_module_text(
|
||||||
"AdvSceneSwitcher.tempVar.audio.balance"));
|
"AdvSceneSwitcher.tempVar.audio.balance"));
|
||||||
break;
|
break;
|
||||||
|
case Type::TRACK:
|
||||||
|
AddTempvar(
|
||||||
|
"track_enabled",
|
||||||
|
obs_module_text(
|
||||||
|
"AdvSceneSwitcher.tempVar.audio.trackEnabled"));
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -468,6 +495,7 @@ static QStringList getAudioSourcesList()
|
|||||||
MacroConditionAudioEdit::MacroConditionAudioEdit(
|
MacroConditionAudioEdit::MacroConditionAudioEdit(
|
||||||
QWidget *parent, std::shared_ptr<MacroConditionAudio> entryData)
|
QWidget *parent, std::shared_ptr<MacroConditionAudio> entryData)
|
||||||
: QWidget(parent),
|
: QWidget(parent),
|
||||||
|
_layout(new QHBoxLayout),
|
||||||
_checkTypes(new QComboBox()),
|
_checkTypes(new QComboBox()),
|
||||||
_sources(new SourceSelectionWidget(this, getAudioSourcesList, true)),
|
_sources(new SourceSelectionWidget(this, getAudioSourcesList, true)),
|
||||||
_condition(new QComboBox()),
|
_condition(new QComboBox()),
|
||||||
@@ -476,7 +504,8 @@ MacroConditionAudioEdit::MacroConditionAudioEdit(
|
|||||||
_percentDBToggle(new QPushButton),
|
_percentDBToggle(new QPushButton),
|
||||||
_syncOffset(new VariableSpinBox()),
|
_syncOffset(new VariableSpinBox()),
|
||||||
_monitorTypes(new QComboBox),
|
_monitorTypes(new QComboBox),
|
||||||
_balance(new SliderSpinBox(0., 1., ""))
|
_balance(new SliderSpinBox(0., 1., "")),
|
||||||
|
_track(new VariableSpinBox())
|
||||||
{
|
{
|
||||||
_volumePercent->setSuffix("%");
|
_volumePercent->setSuffix("%");
|
||||||
_volumePercent->setMaximum(100);
|
_volumePercent->setMaximum(100);
|
||||||
@@ -491,6 +520,9 @@ MacroConditionAudioEdit::MacroConditionAudioEdit(
|
|||||||
_syncOffset->setMaximum(20000);
|
_syncOffset->setMaximum(20000);
|
||||||
_syncOffset->setSuffix("ms");
|
_syncOffset->setSuffix("ms");
|
||||||
|
|
||||||
|
_track->setMinimum(1);
|
||||||
|
_track->setMaximum(32);
|
||||||
|
|
||||||
QWidget::connect(_checkTypes, SIGNAL(currentIndexChanged(int)), this,
|
QWidget::connect(_checkTypes, SIGNAL(currentIndexChanged(int)), this,
|
||||||
SLOT(CheckTypeChanged(int)));
|
SLOT(CheckTypeChanged(int)));
|
||||||
QWidget::connect(
|
QWidget::connect(
|
||||||
@@ -519,27 +551,16 @@ MacroConditionAudioEdit::MacroConditionAudioEdit(
|
|||||||
this, SLOT(VolumeDBChanged(const NumberVariable<double> &)));
|
this, SLOT(VolumeDBChanged(const NumberVariable<double> &)));
|
||||||
QWidget::connect(_percentDBToggle, SIGNAL(clicked()), this,
|
QWidget::connect(_percentDBToggle, SIGNAL(clicked()), this,
|
||||||
SLOT(PercentDBClicked()));
|
SLOT(PercentDBClicked()));
|
||||||
|
QWidget::connect(
|
||||||
|
_track,
|
||||||
|
SIGNAL(NumberVariableChanged(const NumberVariable<int> &)),
|
||||||
|
this, SLOT(TrackChanged(const NumberVariable<int> &)));
|
||||||
|
|
||||||
populateCheckTypes(_checkTypes);
|
populateCheckTypes(_checkTypes);
|
||||||
PopulateMonitorTypeSelection(_monitorTypes);
|
PopulateMonitorTypeSelection(_monitorTypes);
|
||||||
|
|
||||||
QHBoxLayout *switchLayout = new QHBoxLayout;
|
|
||||||
std::unordered_map<std::string, QWidget *> widgetPlaceholders = {
|
|
||||||
{"{{checkType}}", _checkTypes},
|
|
||||||
{"{{audioSources}}", _sources},
|
|
||||||
{"{{volume}}", _volumePercent},
|
|
||||||
{"{{syncOffset}}", _syncOffset},
|
|
||||||
{"{{monitorTypes}}", _monitorTypes},
|
|
||||||
{"{{balance}}", _balance},
|
|
||||||
{"{{condition}}", _condition},
|
|
||||||
{"{{volumeDB}}", _volumeDB},
|
|
||||||
{"{{percentDBToggle}}", _percentDBToggle},
|
|
||||||
};
|
|
||||||
PlaceWidgets(obs_module_text("AdvSceneSwitcher.condition.audio.entry"),
|
|
||||||
switchLayout, widgetPlaceholders);
|
|
||||||
|
|
||||||
QVBoxLayout *mainLayout = new QVBoxLayout;
|
QVBoxLayout *mainLayout = new QVBoxLayout;
|
||||||
mainLayout->addLayout(switchLayout);
|
mainLayout->addLayout(_layout);
|
||||||
mainLayout->addWidget(_balance);
|
mainLayout->addWidget(_balance);
|
||||||
setLayout(mainLayout);
|
setLayout(mainLayout);
|
||||||
|
|
||||||
@@ -608,6 +629,12 @@ void MacroConditionAudioEdit::BalanceChanged(const NumberVariable<double> &value
|
|||||||
_entryData->_balance = value;
|
_entryData->_balance = value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void MacroConditionAudioEdit::TrackChanged(const NumberVariable<int> &value)
|
||||||
|
{
|
||||||
|
GUARD_LOADING_AND_LOCK();
|
||||||
|
_entryData->_track = value;
|
||||||
|
}
|
||||||
|
|
||||||
void MacroConditionAudioEdit::VolumeDBChanged(
|
void MacroConditionAudioEdit::VolumeDBChanged(
|
||||||
const NumberVariable<double> &value)
|
const NumberVariable<double> &value)
|
||||||
{
|
{
|
||||||
@@ -692,6 +719,8 @@ void MacroConditionAudioEdit::CheckTypeChanged(int idx)
|
|||||||
} else if (_entryData->GetType() ==
|
} else if (_entryData->GetType() ==
|
||||||
MacroConditionAudio::Type::CONFIGURED_VOLUME) {
|
MacroConditionAudio::Type::CONFIGURED_VOLUME) {
|
||||||
populateVolumeConditionSelection(_condition);
|
populateVolumeConditionSelection(_condition);
|
||||||
|
} else if (_entryData->GetType() == MacroConditionAudio::Type::TRACK) {
|
||||||
|
_condition->clear();
|
||||||
}
|
}
|
||||||
SetWidgetVisibility();
|
SetWidgetVisibility();
|
||||||
}
|
}
|
||||||
@@ -708,6 +737,7 @@ void MacroConditionAudioEdit::UpdateEntryData()
|
|||||||
_syncOffset->SetValue(_entryData->_syncOffset);
|
_syncOffset->SetValue(_entryData->_syncOffset);
|
||||||
_monitorTypes->setCurrentIndex(_entryData->_monitorType);
|
_monitorTypes->setCurrentIndex(_entryData->_monitorType);
|
||||||
_balance->SetDoubleValue(_entryData->_balance);
|
_balance->SetDoubleValue(_entryData->_balance);
|
||||||
|
_track->SetValue(_entryData->_track);
|
||||||
_checkTypes->setCurrentIndex(
|
_checkTypes->setCurrentIndex(
|
||||||
_checkTypes->findData(static_cast<int>(_entryData->GetType())));
|
_checkTypes->findData(static_cast<int>(_entryData->GetType())));
|
||||||
|
|
||||||
@@ -748,26 +778,63 @@ void MacroConditionAudioEdit::SetWidgetVisibility()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_layout->removeWidget(_checkTypes);
|
||||||
|
_layout->removeWidget(_sources);
|
||||||
|
_layout->removeWidget(_condition);
|
||||||
|
_layout->removeWidget(_volumePercent);
|
||||||
|
_layout->removeWidget(_volumeDB);
|
||||||
|
_layout->removeWidget(_percentDBToggle);
|
||||||
|
_layout->removeWidget(_syncOffset);
|
||||||
|
_layout->removeWidget(_monitorTypes);
|
||||||
|
_layout->removeWidget(_track);
|
||||||
|
ClearLayout(_layout);
|
||||||
|
|
||||||
|
const std::unordered_map<std::string, QWidget *> placeholders = {
|
||||||
|
{"{{checkType}}", _checkTypes},
|
||||||
|
{"{{audioSources}}", _sources},
|
||||||
|
{"{{condition}}", _condition},
|
||||||
|
{"{{volume}}", _volumePercent},
|
||||||
|
{"{{volumeDB}}", _volumeDB},
|
||||||
|
{"{{percentDBToggle}}", _percentDBToggle},
|
||||||
|
{"{{syncOffset}}", _syncOffset},
|
||||||
|
{"{{monitorTypes}}", _monitorTypes},
|
||||||
|
{"{{track}}", _track},
|
||||||
|
};
|
||||||
|
|
||||||
|
const bool isTrack = _entryData->GetType() ==
|
||||||
|
MacroConditionAudio::Type::TRACK;
|
||||||
|
PlaceWidgets(
|
||||||
|
obs_module_text(
|
||||||
|
isTrack ? "AdvSceneSwitcher.condition.audio.layout.track"
|
||||||
|
: "AdvSceneSwitcher.condition.audio.entry"),
|
||||||
|
_layout, placeholders);
|
||||||
|
|
||||||
_condition->setVisible(
|
_condition->setVisible(
|
||||||
_entryData->GetType() ==
|
!isTrack &&
|
||||||
|
(_entryData->GetType() ==
|
||||||
MacroConditionAudio::Type::OUTPUT_VOLUME ||
|
MacroConditionAudio::Type::OUTPUT_VOLUME ||
|
||||||
_entryData->GetType() ==
|
_entryData->GetType() ==
|
||||||
MacroConditionAudio::Type::CONFIGURED_VOLUME ||
|
MacroConditionAudio::Type::CONFIGURED_VOLUME ||
|
||||||
_entryData->GetType() == MacroConditionAudio::Type::BALANCE ||
|
_entryData->GetType() == MacroConditionAudio::Type::BALANCE ||
|
||||||
|
_entryData->GetType() ==
|
||||||
|
MacroConditionAudio::Type::SYNC_OFFSET));
|
||||||
|
_syncOffset->setVisible(!isTrack &&
|
||||||
_entryData->GetType() ==
|
_entryData->GetType() ==
|
||||||
MacroConditionAudio::Type::SYNC_OFFSET);
|
MacroConditionAudio::Type::SYNC_OFFSET);
|
||||||
_syncOffset->setVisible(_entryData->GetType() ==
|
_monitorTypes->setVisible(!isTrack &&
|
||||||
MacroConditionAudio::Type::SYNC_OFFSET);
|
_entryData->GetType() ==
|
||||||
_monitorTypes->setVisible(_entryData->GetType() ==
|
|
||||||
MacroConditionAudio::Type::MONITOR);
|
MacroConditionAudio::Type::MONITOR);
|
||||||
|
_track->setVisible(isTrack);
|
||||||
|
_volumePercent->setVisible(!isTrack && HasVolumeControl() &&
|
||||||
|
!_entryData->_useDb);
|
||||||
|
_volumeDB->setVisible(!isTrack && HasVolumeControl() &&
|
||||||
|
_entryData->_useDb);
|
||||||
|
_percentDBToggle->setText(_entryData->_useDb ? "dB" : "%");
|
||||||
|
_percentDBToggle->setVisible(!isTrack && HasVolumeControl());
|
||||||
_balance->setVisible(_entryData->GetType() ==
|
_balance->setVisible(_entryData->GetType() ==
|
||||||
MacroConditionAudio::Type::BALANCE);
|
MacroConditionAudio::Type::BALANCE);
|
||||||
_volMeter->setVisible(_entryData->GetType() ==
|
_volMeter->setVisible(_entryData->GetType() ==
|
||||||
MacroConditionAudio::Type::OUTPUT_VOLUME);
|
MacroConditionAudio::Type::OUTPUT_VOLUME);
|
||||||
_volumePercent->setVisible(HasVolumeControl() && !_entryData->_useDb);
|
|
||||||
_volumeDB->setVisible(HasVolumeControl() && _entryData->_useDb);
|
|
||||||
_percentDBToggle->setText(_entryData->_useDb ? "dB" : "%");
|
|
||||||
_percentDBToggle->setVisible(HasVolumeControl());
|
|
||||||
adjustSize();
|
adjustSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
#include "source-selection.hpp"
|
#include "source-selection.hpp"
|
||||||
|
|
||||||
#include <limits>
|
#include <limits>
|
||||||
|
#include <QHBoxLayout>
|
||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <chrono>
|
#include <chrono>
|
||||||
@@ -36,6 +37,7 @@ public:
|
|||||||
SYNC_OFFSET,
|
SYNC_OFFSET,
|
||||||
MONITOR,
|
MONITOR,
|
||||||
BALANCE,
|
BALANCE,
|
||||||
|
TRACK,
|
||||||
};
|
};
|
||||||
void SetType(const Type &);
|
void SetType(const Type &);
|
||||||
Type GetType() const { return _checkType; }
|
Type GetType() const { return _checkType; }
|
||||||
@@ -60,6 +62,7 @@ public:
|
|||||||
IntVariable _syncOffset = 0;
|
IntVariable _syncOffset = 0;
|
||||||
obs_monitoring_type _monitorType = OBS_MONITORING_TYPE_NONE;
|
obs_monitoring_type _monitorType = OBS_MONITORING_TYPE_NONE;
|
||||||
DoubleVariable _balance = 0.5;
|
DoubleVariable _balance = 0.5;
|
||||||
|
IntVariable _track = 1;
|
||||||
OutputCondition _outputCondition = OutputCondition::ABOVE;
|
OutputCondition _outputCondition = OutputCondition::ABOVE;
|
||||||
VolumeCondition _volumeCondition = VolumeCondition::ABOVE;
|
VolumeCondition _volumeCondition = VolumeCondition::ABOVE;
|
||||||
obs_volmeter_t *_volmeter = nullptr;
|
obs_volmeter_t *_volmeter = nullptr;
|
||||||
@@ -70,6 +73,7 @@ private:
|
|||||||
bool CheckSyncOffset();
|
bool CheckSyncOffset();
|
||||||
bool CheckMonitor();
|
bool CheckMonitor();
|
||||||
bool CheckBalance();
|
bool CheckBalance();
|
||||||
|
bool CheckTrack();
|
||||||
void SetupTempVars();
|
void SetupTempVars();
|
||||||
float GetVolumePeak();
|
float GetVolumePeak();
|
||||||
|
|
||||||
@@ -111,6 +115,7 @@ private slots:
|
|||||||
void VolumeDBChanged(const NumberVariable<double> &value);
|
void VolumeDBChanged(const NumberVariable<double> &value);
|
||||||
void PercentDBClicked();
|
void PercentDBClicked();
|
||||||
void SyncSliderAndValueSelection(bool sliderMoved);
|
void SyncSliderAndValueSelection(bool sliderMoved);
|
||||||
|
void TrackChanged(const NumberVariable<int> &value);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void HeaderInfoChanged(const QString &);
|
void HeaderInfoChanged(const QString &);
|
||||||
@@ -119,6 +124,7 @@ private:
|
|||||||
void SetWidgetVisibility();
|
void SetWidgetVisibility();
|
||||||
bool HasVolumeControl() const;
|
bool HasVolumeControl() const;
|
||||||
|
|
||||||
|
QHBoxLayout *_layout;
|
||||||
QComboBox *_checkTypes;
|
QComboBox *_checkTypes;
|
||||||
SourceSelectionWidget *_sources;
|
SourceSelectionWidget *_sources;
|
||||||
QComboBox *_condition;
|
QComboBox *_condition;
|
||||||
@@ -128,6 +134,7 @@ private:
|
|||||||
VariableSpinBox *_syncOffset;
|
VariableSpinBox *_syncOffset;
|
||||||
QComboBox *_monitorTypes;
|
QComboBox *_monitorTypes;
|
||||||
SliderSpinBox *_balance;
|
SliderSpinBox *_balance;
|
||||||
|
VariableSpinBox *_track;
|
||||||
VolControl *_volMeter = nullptr;
|
VolControl *_volMeter = nullptr;
|
||||||
|
|
||||||
std::shared_ptr<MacroConditionAudio> _entryData;
|
std::shared_ptr<MacroConditionAudio> _entryData;
|
||||||
|
|||||||
17
plugins/now-playing/CMakeLists.txt
Normal file
17
plugins/now-playing/CMakeLists.txt
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.14)
|
||||||
|
project(advanced-scene-switcher-now-playing)
|
||||||
|
|
||||||
|
if(NOT WIN32)
|
||||||
|
message(WARNING "Now playing condition is only supported on Windows.")
|
||||||
|
return()
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_library(${PROJECT_NAME} MODULE)
|
||||||
|
target_sources(${PROJECT_NAME} PRIVATE macro-condition-now-playing.cpp
|
||||||
|
macro-condition-now-playing.hpp)
|
||||||
|
|
||||||
|
target_link_libraries(${PROJECT_NAME} PRIVATE windowsapp)
|
||||||
|
|
||||||
|
setup_advss_plugin(${PROJECT_NAME})
|
||||||
|
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "")
|
||||||
|
install_advss_plugin(${PROJECT_NAME})
|
||||||
338
plugins/now-playing/macro-condition-now-playing.cpp
Normal file
338
plugins/now-playing/macro-condition-now-playing.cpp
Normal file
@@ -0,0 +1,338 @@
|
|||||||
|
#include "macro-condition-now-playing.hpp"
|
||||||
|
#include "layout-helpers.hpp"
|
||||||
|
#include "sync-helpers.hpp"
|
||||||
|
|
||||||
|
#include <util/base.h>
|
||||||
|
|
||||||
|
#include <roapi.h>
|
||||||
|
#include <winrt/Windows.Foundation.h>
|
||||||
|
#include <winrt/Windows.Media.Control.h>
|
||||||
|
|
||||||
|
namespace advss {
|
||||||
|
|
||||||
|
using namespace winrt::Windows::Media::Control;
|
||||||
|
|
||||||
|
const std::string MacroConditionNowPlaying::id = "now_playing";
|
||||||
|
|
||||||
|
bool MacroConditionNowPlaying::_registered = MacroConditionFactory::Register(
|
||||||
|
MacroConditionNowPlaying::id,
|
||||||
|
{MacroConditionNowPlaying::Create, MacroConditionNowPlayingEdit::Create,
|
||||||
|
"AdvSceneSwitcher.condition.nowPlaying"});
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
struct SessionInfo {
|
||||||
|
bool hasSession = false;
|
||||||
|
std::string title;
|
||||||
|
std::string artist;
|
||||||
|
std::string album;
|
||||||
|
std::string appName;
|
||||||
|
GlobalSystemMediaTransportControlsSessionPlaybackStatus playbackStatus =
|
||||||
|
GlobalSystemMediaTransportControlsSessionPlaybackStatus::Closed;
|
||||||
|
};
|
||||||
|
|
||||||
|
static bool initWinRT()
|
||||||
|
{
|
||||||
|
HRESULT hr = RoInitialize(RO_INIT_MULTITHREADED);
|
||||||
|
// S_OK: initialized, S_FALSE: already initialized with same type,
|
||||||
|
// RPC_E_CHANGED_MODE: thread is STA (OBS UI thread) - WinRT still usable
|
||||||
|
return SUCCEEDED(hr) || hr == RPC_E_CHANGED_MODE;
|
||||||
|
}
|
||||||
|
|
||||||
|
static SessionInfo getCurrentSessionInfo()
|
||||||
|
{
|
||||||
|
thread_local bool initialized = initWinRT();
|
||||||
|
(void)initialized;
|
||||||
|
|
||||||
|
SessionInfo info;
|
||||||
|
|
||||||
|
try {
|
||||||
|
auto manager =
|
||||||
|
GlobalSystemMediaTransportControlsSessionManager::
|
||||||
|
RequestAsync()
|
||||||
|
.get();
|
||||||
|
auto session = manager.GetCurrentSession();
|
||||||
|
if (!session) {
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
info.hasSession = true;
|
||||||
|
info.appName = winrt::to_string(session.SourceAppUserModelId());
|
||||||
|
|
||||||
|
auto playbackInfo = session.GetPlaybackInfo();
|
||||||
|
info.playbackStatus = playbackInfo.PlaybackStatus();
|
||||||
|
|
||||||
|
auto props = session.TryGetMediaPropertiesAsync().get();
|
||||||
|
if (props) {
|
||||||
|
info.title = winrt::to_string(props.Title());
|
||||||
|
info.artist = winrt::to_string(props.Artist());
|
||||||
|
info.album = winrt::to_string(props.AlbumTitle());
|
||||||
|
}
|
||||||
|
} catch (const winrt::hresult_error &e) {
|
||||||
|
blog(LOG_WARNING, "now playing: WinRT error 0x%08X",
|
||||||
|
static_cast<uint32_t>(e.code()));
|
||||||
|
}
|
||||||
|
|
||||||
|
return info;
|
||||||
|
}
|
||||||
|
|
||||||
|
static std::string PlaybackStatusToString(
|
||||||
|
GlobalSystemMediaTransportControlsSessionPlaybackStatus status)
|
||||||
|
{
|
||||||
|
switch (status) {
|
||||||
|
case GlobalSystemMediaTransportControlsSessionPlaybackStatus::Playing:
|
||||||
|
return "Playing";
|
||||||
|
case GlobalSystemMediaTransportControlsSessionPlaybackStatus::Paused:
|
||||||
|
return "Paused";
|
||||||
|
case GlobalSystemMediaTransportControlsSessionPlaybackStatus::Stopped:
|
||||||
|
return "Stopped";
|
||||||
|
case GlobalSystemMediaTransportControlsSessionPlaybackStatus::Opened:
|
||||||
|
return "Opening";
|
||||||
|
case GlobalSystemMediaTransportControlsSessionPlaybackStatus::Changing:
|
||||||
|
return "Changing";
|
||||||
|
default:
|
||||||
|
return "Closed";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
bool MacroConditionNowPlaying::CheckCondition()
|
||||||
|
{
|
||||||
|
const auto info = getCurrentSessionInfo();
|
||||||
|
|
||||||
|
SetTempVarValue("title", info.title);
|
||||||
|
SetTempVarValue("artist", info.artist);
|
||||||
|
SetTempVarValue("album", info.album);
|
||||||
|
SetTempVarValue("appName", info.appName);
|
||||||
|
SetTempVarValue("playbackStatus",
|
||||||
|
PlaybackStatusToString(info.playbackStatus));
|
||||||
|
|
||||||
|
if (!info.hasSession) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto textMatches = [this](const std::string &field) -> bool {
|
||||||
|
const QString pattern = QString::fromStdString(_matchText);
|
||||||
|
const QString value = QString::fromStdString(field);
|
||||||
|
if (_regex.Enabled()) {
|
||||||
|
return _regex.Matches(value, pattern);
|
||||||
|
}
|
||||||
|
return value == pattern;
|
||||||
|
};
|
||||||
|
|
||||||
|
switch (_checkType) {
|
||||||
|
case CheckType::PLAYBACK_STATE: {
|
||||||
|
using S =
|
||||||
|
GlobalSystemMediaTransportControlsSessionPlaybackStatus;
|
||||||
|
switch (_playbackState) {
|
||||||
|
case PlaybackState::PLAYING:
|
||||||
|
return info.playbackStatus == S::Playing;
|
||||||
|
case PlaybackState::PAUSED:
|
||||||
|
return info.playbackStatus == S::Paused;
|
||||||
|
case PlaybackState::STOPPED:
|
||||||
|
return info.playbackStatus == S::Stopped;
|
||||||
|
case PlaybackState::OPENING:
|
||||||
|
return info.playbackStatus == S::Opened;
|
||||||
|
case PlaybackState::CHANGING:
|
||||||
|
return info.playbackStatus == S::Changing;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CheckType::TITLE:
|
||||||
|
return textMatches(info.title);
|
||||||
|
case CheckType::ARTIST:
|
||||||
|
return textMatches(info.artist);
|
||||||
|
case CheckType::ALBUM:
|
||||||
|
return textMatches(info.album);
|
||||||
|
case CheckType::APP_NAME:
|
||||||
|
return textMatches(info.appName);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MacroConditionNowPlaying::Save(obs_data_t *obj) const
|
||||||
|
{
|
||||||
|
MacroCondition::Save(obj);
|
||||||
|
obs_data_set_int(obj, "checkType", static_cast<int>(_checkType));
|
||||||
|
obs_data_set_int(obj, "playbackState",
|
||||||
|
static_cast<int>(_playbackState));
|
||||||
|
_matchText.Save(obj, "matchText");
|
||||||
|
_regex.Save(obj);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool MacroConditionNowPlaying::Load(obs_data_t *obj)
|
||||||
|
{
|
||||||
|
MacroCondition::Load(obj);
|
||||||
|
_checkType = static_cast<CheckType>(obs_data_get_int(obj, "checkType"));
|
||||||
|
_playbackState = static_cast<PlaybackState>(
|
||||||
|
obs_data_get_int(obj, "playbackState"));
|
||||||
|
_matchText.Load(obj, "matchText");
|
||||||
|
_regex.Load(obj);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MacroConditionNowPlaying::SetupTempVars()
|
||||||
|
{
|
||||||
|
AddTempvar(
|
||||||
|
"title",
|
||||||
|
obs_module_text("AdvSceneSwitcher.tempVar.nowPlaying.title"));
|
||||||
|
AddTempvar(
|
||||||
|
"artist",
|
||||||
|
obs_module_text("AdvSceneSwitcher.tempVar.nowPlaying.artist"));
|
||||||
|
AddTempvar(
|
||||||
|
"album",
|
||||||
|
obs_module_text("AdvSceneSwitcher.tempVar.nowPlaying.album"));
|
||||||
|
AddTempvar(
|
||||||
|
"appName",
|
||||||
|
obs_module_text("AdvSceneSwitcher.tempVar.nowPlaying.appName"));
|
||||||
|
AddTempvar(
|
||||||
|
"playbackStatus",
|
||||||
|
obs_module_text(
|
||||||
|
"AdvSceneSwitcher.tempVar.nowPlaying.playbackStatus"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// ---------------------------------------------------------------------------
|
||||||
|
|
||||||
|
static void populateCheckTypeSelection(QComboBox *list)
|
||||||
|
{
|
||||||
|
static const std::map<MacroConditionNowPlaying::CheckType, std::string> checkTypes = {
|
||||||
|
{MacroConditionNowPlaying::CheckType::PLAYBACK_STATE,
|
||||||
|
"AdvSceneSwitcher.condition.nowPlaying.checkType.playbackState"},
|
||||||
|
{MacroConditionNowPlaying::CheckType::TITLE,
|
||||||
|
"AdvSceneSwitcher.condition.nowPlaying.checkType.title"},
|
||||||
|
{MacroConditionNowPlaying::CheckType::ARTIST,
|
||||||
|
"AdvSceneSwitcher.condition.nowPlaying.checkType.artist"},
|
||||||
|
{MacroConditionNowPlaying::CheckType::ALBUM,
|
||||||
|
"AdvSceneSwitcher.condition.nowPlaying.checkType.album"},
|
||||||
|
{MacroConditionNowPlaying::CheckType::APP_NAME,
|
||||||
|
"AdvSceneSwitcher.condition.nowPlaying.checkType.appName"},
|
||||||
|
};
|
||||||
|
|
||||||
|
for (const auto &[type, name] : checkTypes) {
|
||||||
|
list->addItem(obs_module_text(name.c_str()),
|
||||||
|
static_cast<int>(type));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void populatePlaybackStateSelection(QComboBox *list)
|
||||||
|
{
|
||||||
|
static const std::map<MacroConditionNowPlaying::PlaybackState, std::string> playbackStates = {
|
||||||
|
{MacroConditionNowPlaying::PlaybackState::PLAYING,
|
||||||
|
"AdvSceneSwitcher.condition.nowPlaying.playbackState.playing"},
|
||||||
|
{MacroConditionNowPlaying::PlaybackState::PAUSED,
|
||||||
|
"AdvSceneSwitcher.condition.nowPlaying.playbackState.paused"},
|
||||||
|
{MacroConditionNowPlaying::PlaybackState::STOPPED,
|
||||||
|
"AdvSceneSwitcher.condition.nowPlaying.playbackState.stopped"},
|
||||||
|
{MacroConditionNowPlaying::PlaybackState::OPENING,
|
||||||
|
"AdvSceneSwitcher.condition.nowPlaying.playbackState.opening"},
|
||||||
|
{MacroConditionNowPlaying::PlaybackState::CHANGING,
|
||||||
|
"AdvSceneSwitcher.condition.nowPlaying.playbackState.changing"},
|
||||||
|
};
|
||||||
|
|
||||||
|
for (const auto &[state, name] : playbackStates) {
|
||||||
|
list->addItem(obs_module_text(name.c_str()),
|
||||||
|
static_cast<int>(state));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
MacroConditionNowPlayingEdit::MacroConditionNowPlayingEdit(
|
||||||
|
QWidget *parent, std::shared_ptr<MacroConditionNowPlaying> entryData)
|
||||||
|
: QWidget(parent),
|
||||||
|
_checkType(new QComboBox(this)),
|
||||||
|
_playbackState(new QComboBox(this)),
|
||||||
|
_matchText(new VariableLineEdit(this)),
|
||||||
|
_regex(new RegexConfigWidget(this))
|
||||||
|
{
|
||||||
|
populateCheckTypeSelection(_checkType);
|
||||||
|
populatePlaybackStateSelection(_playbackState);
|
||||||
|
|
||||||
|
connect(_checkType, QOverload<int>::of(&QComboBox::currentIndexChanged),
|
||||||
|
this, &MacroConditionNowPlayingEdit::CheckTypeChanged);
|
||||||
|
connect(_playbackState,
|
||||||
|
QOverload<int>::of(&QComboBox::currentIndexChanged), this,
|
||||||
|
&MacroConditionNowPlayingEdit::PlaybackStateChanged);
|
||||||
|
connect(_matchText, &VariableLineEdit::textEdited, this,
|
||||||
|
&MacroConditionNowPlayingEdit::MatchTextChanged);
|
||||||
|
connect(_regex, &RegexConfigWidget::RegexConfigChanged, this,
|
||||||
|
&MacroConditionNowPlayingEdit::RegexChanged);
|
||||||
|
|
||||||
|
_layout = new QHBoxLayout();
|
||||||
|
_layout->addWidget(_checkType);
|
||||||
|
_layout->addWidget(_playbackState);
|
||||||
|
_layout->addWidget(_matchText);
|
||||||
|
_layout->addWidget(_regex);
|
||||||
|
setLayout(_layout);
|
||||||
|
|
||||||
|
_entryData = entryData;
|
||||||
|
UpdateEntryData();
|
||||||
|
_loading = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MacroConditionNowPlayingEdit::UpdateEntryData()
|
||||||
|
{
|
||||||
|
if (!_entryData) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
_checkType->setCurrentIndex(
|
||||||
|
_checkType->findData(static_cast<int>(_entryData->_checkType)));
|
||||||
|
_playbackState->setCurrentIndex(_playbackState->findData(
|
||||||
|
static_cast<int>(_entryData->_playbackState)));
|
||||||
|
_matchText->setText(QString::fromStdString(_entryData->_matchText));
|
||||||
|
_regex->SetRegexConfig(_entryData->_regex);
|
||||||
|
|
||||||
|
SetWidgetVisibility();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MacroConditionNowPlayingEdit::CheckTypeChanged(int)
|
||||||
|
{
|
||||||
|
GUARD_LOADING_AND_LOCK();
|
||||||
|
_entryData->_checkType =
|
||||||
|
static_cast<MacroConditionNowPlaying::CheckType>(
|
||||||
|
_checkType->currentData().toInt());
|
||||||
|
SetWidgetVisibility();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MacroConditionNowPlayingEdit::PlaybackStateChanged(int)
|
||||||
|
{
|
||||||
|
GUARD_LOADING_AND_LOCK();
|
||||||
|
_entryData->_playbackState =
|
||||||
|
static_cast<MacroConditionNowPlaying::PlaybackState>(
|
||||||
|
_playbackState->currentData().toInt());
|
||||||
|
}
|
||||||
|
|
||||||
|
void MacroConditionNowPlayingEdit::MatchTextChanged(const QString &text)
|
||||||
|
{
|
||||||
|
GUARD_LOADING_AND_LOCK();
|
||||||
|
_entryData->_matchText = text.toStdString();
|
||||||
|
}
|
||||||
|
|
||||||
|
void MacroConditionNowPlayingEdit::RegexChanged(const RegexConfig ®ex)
|
||||||
|
{
|
||||||
|
GUARD_LOADING_AND_LOCK();
|
||||||
|
_entryData->_regex = regex;
|
||||||
|
}
|
||||||
|
|
||||||
|
void MacroConditionNowPlayingEdit::SetWidgetVisibility()
|
||||||
|
{
|
||||||
|
const bool isStateCheck =
|
||||||
|
_entryData->_checkType ==
|
||||||
|
MacroConditionNowPlaying::CheckType::PLAYBACK_STATE;
|
||||||
|
_playbackState->setVisible(isStateCheck);
|
||||||
|
_matchText->setVisible(!isStateCheck);
|
||||||
|
_regex->setVisible(!isStateCheck);
|
||||||
|
|
||||||
|
if (isStateCheck) {
|
||||||
|
AddStretchIfNecessary(_layout);
|
||||||
|
} else {
|
||||||
|
RemoveStretchIfPresent(_layout);
|
||||||
|
}
|
||||||
|
|
||||||
|
adjustSize();
|
||||||
|
updateGeometry();
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace advss
|
||||||
86
plugins/now-playing/macro-condition-now-playing.hpp
Normal file
86
plugins/now-playing/macro-condition-now-playing.hpp
Normal file
@@ -0,0 +1,86 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "macro-condition-edit.hpp"
|
||||||
|
#include "regex-config.hpp"
|
||||||
|
#include "variable-line-edit.hpp"
|
||||||
|
|
||||||
|
#include <QComboBox>
|
||||||
|
|
||||||
|
namespace advss {
|
||||||
|
|
||||||
|
class MacroConditionNowPlaying : public MacroCondition {
|
||||||
|
public:
|
||||||
|
enum class CheckType {
|
||||||
|
PLAYBACK_STATE,
|
||||||
|
TITLE,
|
||||||
|
ARTIST,
|
||||||
|
ALBUM,
|
||||||
|
APP_NAME,
|
||||||
|
};
|
||||||
|
|
||||||
|
enum class PlaybackState {
|
||||||
|
PLAYING,
|
||||||
|
PAUSED,
|
||||||
|
STOPPED,
|
||||||
|
OPENING,
|
||||||
|
CHANGING,
|
||||||
|
};
|
||||||
|
|
||||||
|
MacroConditionNowPlaying(Macro *m) : MacroCondition(m) {}
|
||||||
|
bool CheckCondition();
|
||||||
|
bool Save(obs_data_t *obj) const;
|
||||||
|
bool Load(obs_data_t *obj);
|
||||||
|
std::string GetId() const { return id; }
|
||||||
|
static std::shared_ptr<MacroCondition> Create(Macro *m)
|
||||||
|
{
|
||||||
|
return std::make_shared<MacroConditionNowPlaying>(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
CheckType _checkType = CheckType::PLAYBACK_STATE;
|
||||||
|
PlaybackState _playbackState = PlaybackState::PLAYING;
|
||||||
|
StringVariable _matchText;
|
||||||
|
RegexConfig _regex;
|
||||||
|
|
||||||
|
private:
|
||||||
|
void SetupTempVars();
|
||||||
|
|
||||||
|
static bool _registered;
|
||||||
|
static const std::string id;
|
||||||
|
};
|
||||||
|
|
||||||
|
class MacroConditionNowPlayingEdit : public QWidget {
|
||||||
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
MacroConditionNowPlayingEdit(
|
||||||
|
QWidget *parent,
|
||||||
|
std::shared_ptr<MacroConditionNowPlaying> cond = nullptr);
|
||||||
|
void UpdateEntryData();
|
||||||
|
static QWidget *Create(QWidget *parent,
|
||||||
|
std::shared_ptr<MacroCondition> cond)
|
||||||
|
{
|
||||||
|
return new MacroConditionNowPlayingEdit(
|
||||||
|
parent,
|
||||||
|
std::dynamic_pointer_cast<MacroConditionNowPlaying>(
|
||||||
|
cond));
|
||||||
|
}
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void CheckTypeChanged(int);
|
||||||
|
void PlaybackStateChanged(int);
|
||||||
|
void MatchTextChanged(const QString &);
|
||||||
|
void RegexChanged(const RegexConfig &);
|
||||||
|
|
||||||
|
private:
|
||||||
|
void SetWidgetVisibility();
|
||||||
|
|
||||||
|
QHBoxLayout *_layout;
|
||||||
|
QComboBox *_checkType;
|
||||||
|
QComboBox *_playbackState;
|
||||||
|
VariableLineEdit *_matchText;
|
||||||
|
RegexConfigWidget *_regex;
|
||||||
|
|
||||||
|
std::shared_ptr<MacroConditionNowPlaying> _entryData;
|
||||||
|
bool _loading = true;
|
||||||
|
};
|
||||||
|
|
||||||
|
} // namespace advss
|
||||||
@@ -61,9 +61,14 @@ function(_advss_whisper_suppress_werror dir)
|
|||||||
endif()
|
endif()
|
||||||
target_compile_options(
|
target_compile_options(
|
||||||
${_target}
|
${_target}
|
||||||
PRIVATE $<$<C_COMPILER_ID:GNU,Clang,AppleClang>:-Wno-error>
|
PRIVATE $<$<C_COMPILER_ID:GNU,Clang,AppleClang>:-Wno-error
|
||||||
$<$<CXX_COMPILER_ID:GNU,Clang,AppleClang>:-Wno-error>
|
-Wno-shorten-64-to-32
|
||||||
$<$<C_COMPILER_ID:MSVC>:/WX-> $<$<CXX_COMPILER_ID:MSVC>:/WX->)
|
-Wno-ambiguous-macro>
|
||||||
|
$<$<CXX_COMPILER_ID:GNU,Clang,AppleClang>:-Wno-error
|
||||||
|
-Wno-shorten-64-to-32
|
||||||
|
-Wno-ambiguous-macro>
|
||||||
|
$<$<C_COMPILER_ID:MSVC>:/WX->
|
||||||
|
$<$<CXX_COMPILER_ID:MSVC>:/WX->)
|
||||||
endforeach()
|
endforeach()
|
||||||
endfunction()
|
endfunction()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user