Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

obs-powershell 0.1.7 #72

Merged
merged 183 commits into from
Mar 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
183 commits
Select commit Hold shift + click to select a range
b9ce1c7
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
6d6f23f
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
b0e4e39
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
3ad4da2
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
2156cab
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
2f74811
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
e973dc0
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
8d4e4ff
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
36c0223
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
e432782
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
aa51659
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
e5c4291
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
e33cd41
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
a5d0b57
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
05fb8c9
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
015001d
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
fcfef83
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
14885d1
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
94a3ef4
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
902fd40
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
29411f6
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
1cc18d9
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
4c7b95d
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
5d24532
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
ef79806
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
76b9cae
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
e093657
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
15e0b98
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
a526cba
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
9611087
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
778c4a6
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
139ebe8
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
067f18c
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
be45392
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
946edd0
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
dbdc01a
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
72fbaa9
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
73ac13f
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
1c1750d
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
ed2f3e3
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
17b0201
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
aa3098c
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
7a09152
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
ee2d2b2
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
9039b67
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
0103d26
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
47daf9b
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
f078dcb
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
0b80f97
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
4fb766b
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
0fbc504
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
02d431d
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
6e54ea4
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
1d574ba
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
0e316bd
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
95870aa
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
3f0b9a7
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
8541256
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
a53a9b7
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
753a397
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
781f2dd
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
5e8bc3d
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
61d07dc
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
417729f
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
78ac9c1
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
c0257a3
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
8d12e30
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
bc3cd7e
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
3339a2e
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
349dfa1
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
755b4c4
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
38c6c46
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
54670a1
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
a106674
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
bf17527
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
3e968b7
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
71f4a01
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
a7256b4
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
f38f4de
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
06aa7fd
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
84b6b56
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
e47017b
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
d406c5e
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
071d49b
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
82b0426
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
069beab
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
5240217
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
66ef570
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
03695c6
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
5cb25d1
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
485e264
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
2d99293
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
9120dbc
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
a31f214
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
1ad8dcf
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
480834e
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
941a51b
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
639e7bd
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
8ee4a4a
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
6a06749
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
39557e1
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
7fe542e
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
8f17cf4
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
9574278
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
a798f65
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
f2431b0
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
7e8bf58
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
a3e2406
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
0241425
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
aba5a4a
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
a2517a6
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
9738336
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
ea2dde7
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
f3b5d17
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
ff2c8c1
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
5a35dbd
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
1caabd0
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
b4626dd
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
ac75cbb
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
a2dea76
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
3486a42
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
d8dc5e4
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
cc27639
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
d9687bc
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
5851bd0
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
d63d924
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
728be92
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
066ec09
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
05a4efb
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
3181874
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
2070d92
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
275a940
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
6fb1979
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
2caa7bc
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
be0f38d
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
d2e73fc
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
796c6af
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
5ceb60f
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
5697ade
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
ddcd032
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
376ce02
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
8755b2b
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
0a87837
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
12dc358
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
c2a71bc
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
ec005cd
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
46e0fbc
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
c8a1f71
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
d89c4c4
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
0b57f44
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
aa2caaa
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
d2e0290
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
0a7b385
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
309215e
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
6d16212
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
44becf0
Adding -Force to Add-OBS*Source commands (Fixes #69)
Mar 9, 2023
3772ee1
Merge branch 'Show-OBS' of https://github.com/StartAutomating/obs-pow…
Mar 9, 2023
40a18c6
Merge branch 'Show-OBS' of https://github.com/StartAutomating/obs-pow…
Mar 9, 2023
4c008f1
Adding Remove-OBS (Fixes #68)
Mar 11, 2023
140d430
Adding Remove-OBS (Fixes #68)
Mar 11, 2023
9f94868
Adding Remove-OBS (Fixes #68)
Mar 11, 2023
9650032
Adding Hide-OBS (Fixes #67)
Mar 11, 2023
e02cff4
Adding Hide-OBS (Fixes #67)
Mar 11, 2023
2d1a91b
Hide-OBS: Fixing parameter signature (re #67)
Mar 11, 2023
74b6316
Hide-OBS: Fixing parameter signature (re #67)
Mar 11, 2023
69252d2
Hide-OBS: Fixing parameter signature (re #67)
Mar 11, 2023
ca9cae7
Hide-OBS: Fixing parameter signature (re #67)
Mar 11, 2023
0191579
Adding Show-OBS (Fixes #66)
Mar 11, 2023
a1089b0
Add-OBS*Source Commands: Supporting -SceneItemEnabled (Fixes #70)
Mar 11, 2023
4ae733d
Add-OBS*Source Commands: Supporting -SceneItemEnabled (Fixes #70)
Mar 11, 2023
925c14a
Add-OBS*Source Commands: Supporting -SceneItemEnabled (Fixes #70)
Mar 11, 2023
52a768d
Add-OBS*Source Commands: Supporting -SceneItemEnabled (Fixes #70)
Mar 11, 2023
6ce46b5
Add-OBSMediaSource, adding -FitToScreen
Mar 11, 2023
3d5143f
Add-OBSMediaSource, adding -FitToScreen
Mar 11, 2023
e461bac
Add-OBSMediaSource, adding -FitToScreen
Mar 11, 2023
9bd92cb
Add-OBSMediaSource, adding -FitToScreen
Mar 11, 2023
6897cf1
Show-OBS: Adding -FitToScreen (re #66)
Mar 11, 2023
f982e08
Hide-OBS: Fixing filter (re #67)
Mar 11, 2023
6ee6de6
Show-OBS: Adding -FitToScreen (re #66)
Mar 11, 2023
a19bc75
Merge branch 'Show-OBS' of https://github.com/StartAutomating/obs-pow…
Mar 11, 2023
810b98f
Updating Module Version [0.1.7] and CHANGELOG
Mar 11, 2023
183555b
Updating Module Version [0.1.7] and CHANGELOG
Mar 11, 2023
50e22a1
Updating Module Version [0.1.7] and CHANGELOG
Mar 11, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
## obs-powershell 0.1.7:

* New Commands:
* Show-OBS (Fixes #66)
* Hide-OBS (Fixes #67)
* Remove-OBS (Fixes #68)

* Adding -Force to Add-OBS*Source commands (Fixes #69)
* Add-OBS*Source Commands: Supporting -SceneItemEnabled (Fixes #70)
* Add-OBSMediaSource, adding -FitToScreen (Fixes #71)

---

## obs-powershell 0.1.6:

* Adding OBS.SceneItem .Scale (Fixes #64)
Expand Down
43 changes: 43 additions & 0 deletions Commands/Hide-OBS.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
function Hide-OBS {
<#
.SYNOPSIS
Hide OBS
.DESCRIPTION
Hides items in OBS
.EXAMPLE
Hide-OBS -SourceName "foo"
.LINK
Set-OBSSceneItemEnabled
#>
[CmdletBinding(SupportsShouldProcess,ConfirmImpact='Medium')]
param(
# The name of the item we want to Hide
[Parameter(Mandatory,ValueFromPipelineByPropertyName)]
[Alias('SourceName','InputName')]
$ItemName,

# The name of the scene. If not provided, the current program scene will be used.
[Parameter(ValueFromPipelineByPropertyName)]
[string]
$SceneName
)

process {
# If no scene was provided
if (-not $SceneName) {
# find the current program scene
$sceneName = Get-OBSCurrentProgramScene
}

# Walk over all items in the scene
foreach ($sceneItem in Get-OBSSceneItem -SceneName $SceneName) {
# If the match our wildcard and we confirm, remove it.
if ($sceneItem.SourceName -like $ItemName -and
$PSCmdlet.ShouldProcess("Hide input $($sceneItem.SourceName)")) {
# Hide it.
$sceneItem | Set-OBSSceneItemEnabled -SceneItemEnabled:$false
}
}
}
}

51 changes: 51 additions & 0 deletions Commands/Remove-OBS.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
function Remove-OBS {
<#
.SYNOPSIS
Remove OBS
.DESCRIPTION
Removes items from OBS
.EXAMPLE
Remove-OBS -SourceName "foo"
.EXAMPLE
Remove-OBS -SceneName "bar"
.LINK
Remove-OBSInput
.LINK
Remove-OBSScene
#>
[CmdletBinding(SupportsShouldProcess,ConfirmImpact='High')]
param(
# The name of the item we want to remove
[Parameter(Mandatory,ValueFromPipelineByPropertyName)]
[Alias('SourceName','InputName','SceneName')]
$ItemName
)

process {
# If we remove an input, we don't want to remove a scene
$removedAnInput = $false
# Go over each input
foreach ($obsInput in Get-OBSInput) {
# If it matches our wildcard and we confirm
if ($obsInput.InputName -like $ItemName -and
$PSCmdlet.ShouldProcess("Remove input $($obsInput.InputName)")) {
# remove it.
Remove-OBSInput -InputName $obsInput.InputName
$removedAnInput = $true
}
}

# Return if we removed an input.
if ($removedAnInput) { return }

# Go over all scenes
foreach ($obsScene in (Get-OBSScene).Scenes) {
# If the name matches our wildcard and we confirm
if ($obsScene.SceneName -like $ItemName -and
$PSCmdlet.ShouldProcess("Remove scene $($obsScene.SceneName)")) {
# remove the scene.
Remove-OBSScene -SceneName $obsScene.SceneName
}
}
}
}
164 changes: 164 additions & 0 deletions Commands/Show-OBS.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,164 @@
function Show-OBS {
<#
.SYNOPSIS
Shows content in OBS
.DESCRIPTION
Shows content in Open Broadcasting Studio
.EXAMPLE
'<svg viewBox="0 0 1 1" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://www.w3.org/2000/svg">
<polygon points="0 0 0 1 1 1 1 0" fill="blue" />
</svg>' | Set-Content .\BlueRect.svg
Show-OBS -FilePath .\BlueRect.svg
.EXAMPLE
Show-OBS -FilePath *excited* -RootPath $home\Pictures\Gif
#>
param(
# The path or URI to show in OBS.
[Parameter(Mandatory,ValueFromPipelineByPropertyName)]
[Alias('FullName','Src', 'Uri','FileName')]
[string]
$FilePath,

# The name of the source in OBS.
# If this is not provided, it will be derived from the -FilePath.
[Parameter(ValueFromPipelineByPropertyName)]
[string]
$Name,

# A root path.
# If not provided, this will be the root of the -FilePath (if it is a filepath).
# If the file path was a URI, the root path will be ignored.
[Parameter(ValueFromPipelineByPropertyName)]
[string]
$RootPath,

# The name of the scene.
# If no scene name is provided, the current program scene will be used.
[Parameter(ValueFromPipelineByPropertyName)]
[string]
$Scene,

# The opacity to use for the input.
# If not provided, will default to 2/3rds.
# Will only be used when showing a browser source with a -FilePath
[Parameter(ValueFromPipelineByPropertyName)]
[double]
$Opacity = (2/3),

# Any parameters to pass to the source command.
[Parameter(ValueFromPipelineByPropertyName)]
[Collections.IDictionary]
$SourceParameter = [ordered]@{},

# If set, will check if the source exists in the scene before creating it and removing any existing sources found.
# If not set, you will get an error if a source with the same name exists.
[Parameter(ValueFromPipelineByPropertyName)]
[switch]
$Force,

# If set, will make the input become the size of the screen.
[Parameter(ValueFromPipelineByPropertyName)]
[switch]
$FitToScreen
)

begin {
filter FitToScreenAndOutput {
if ($FitToScreen -and $_.FitToScreen) {
$_.FitToScreen()
}
$_
}
}

process {
# If we had a -RootPath
if ($RootPath) {
# Look in the root path
$imageFiles = @(Get-ChildItem $RootPath -Recurse -File|
# For files like this keyword
Where-Object FullName -like "*$filePath*" |
# that are extensions we could show
Where-Object Extension -in '.html', '.jpg', '.jpeg', '.gif', '.apng', '.png'
)
if ($imageFiles.Count) {
$FilePath = ($imageFiles | Get-Random).FullName
}
}



# Determine if the thing we are showing will be a ffmpeg source.
$IsMediaSource =
# If it's an http path, it's not
if ($FilePath -like 'http*') {
$false
} elseif (
# If it's an HTML-friendly path, it's not
$FilePath -match '.(?>html?|gif|jpe?g|a?png|svg)$'
) {
$false
} else {
# Otherwise, let's give it a try.
$true
}

if (-not $RootPath -and $filePath -notlike 'http*') {
$RootPath = "$($FilePath | Split-Path)"
}

# If we provided a scene
if ($Scene) {
# pass it down.
$SourceParameter.Scene = $Scene
}

# If we want to use -Force
if ($Force) {
# pass it down
$SourceParameter.Force = $Force
}

# If we do not want to create a media source,
if (-not $IsMediaSource) {
# we create a browser source.
$SourceParameter.Uri = $FilePath
# If the path was not already HTML,
if ($RootPath -and $FilePath -notmatch '\.html{0,1}$') {
# we make a minimal frame in a .html file
$relativePath = $FilePath.Substring($RootPath.Length + 1)
$htmlFrame = "<html>
<body style='width:100%;height:100%'>
<img src='$relativePath' style='width:100%;height:100%' />'
<body>
</html>"

$leafPath = $filePath | Split-Path -Leaf
$htmlPath = Join-Path $RootPath "$($leafPath).html"

$htmlFrame | Set-Content -Path $htmlPath
# And set up the CSS for that frame, passing down -Opacity.
# (this may not work for all images)
$css = "
body {
background-color: rgba(0, 0, 0, 0); margin: 0px auto; overflow: hidden;
}
img {
width: 100%
height: 100%;
opacity: $opacity;
}
"
$SourceParameter.Uri = $htmlPath
$SourceParameter.CSS = $css
Add-OBSBrowserSource @SourceParameter | FitToScreenAndOutput
} else {
Add-OBSBrowserSource @SourceParameter | FitToScreenAndOutput
}

} else {
$SourceParameter.FilePath = $FilePath
Add-OBSMediaSource @SourceParameter | FitToScreenAndOutput
}
}
}
31 changes: 29 additions & 2 deletions Commands/Sources/Add-OBSBrowserSource.ps.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,13 @@ function Add-OBSBrowserSource
# If no name is provided, the last segment of the URI or file path will be the input name.
[Parameter(ValueFromPipelineByPropertyName)]
[string]
$Name
$Name,

# If set, will check if the source exists in the scene before creating it and removing any existing sources found.
# If not set, you will get an error if a source with the same name exists.
[Parameter(ValueFromPipelineByPropertyName)]
[switch]
$Force
)

process {
Expand Down Expand Up @@ -144,8 +150,29 @@ function Add-OBSBrowserSource
}
}

# If -Force is provided
if ($Force) {
# Clear any items from that scene
Get-OBSSceneItem -sceneName $myParameters["Scene"] |
Where-Object SourceName -eq $name |
Remove-OBSInput -InputName { $_.SourceName }
}


$addObsInputParams = [Ordered]@{
sceneName = $myParameters["Scene"]
inputKind = "browser_source"
inputSettings = $myParameterData
inputName = $Name
}
# If -SceneItemEnabled was passed,
if ($myParameters.Contains('SceneItemEnabled')) {
# propagate it to Add-OBSInput.
$addObsInputParams.SceneItemEnabled = $myParameters['SceneItemEnabled'] -as [bool]
}

$outputAddedResult =
Add-OBSInput -sceneName $myParameters["Scene"] -inputKind "browser_source" -inputSettings $myParameterData -inputName $Name
Add-OBSInput @addObsInputParams

if ($outputAddedResult) {
Get-OBSSceneItem -sceneName $myParameters["Scene"] |
Expand Down
28 changes: 26 additions & 2 deletions Commands/Sources/Add-OBSBrowserSource.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,12 @@ function Add-OBSBrowserSource {
# If no name is provided, the last segment of the URI or file path will be the input name.
[Parameter(ValueFromPipelineByPropertyName)]
[string]
$Name
$Name,
# If set, will check if the source exists in the scene before creating it and removing any existing sources found.
# If not set, you will get an error if a source with the same name exists.
[Parameter(ValueFromPipelineByPropertyName)]
[switch]
$Force
)
dynamicParam {
$baseCommand =
Expand Down Expand Up @@ -160,8 +165,27 @@ dynamicParam {
$uri
}
}
# If -Force is provided
if ($Force) {
# Clear any items from that scene
Get-OBSSceneItem -sceneName $myParameters["Scene"] |
Where-Object SourceName -eq $name |
Remove-OBSInput -InputName { $_.SourceName }
}
$addObsInputParams = [Ordered]@{
sceneName = $myParameters["Scene"]
inputKind = "browser_source"
inputSettings = $myParameterData
inputName = $Name
}
# If -SceneItemEnabled was passed,
if ($myParameters.Contains('SceneItemEnabled')) {
# propagate it to Add-OBSInput.
$addObsInputParams.SceneItemEnabled = $myParameters['SceneItemEnabled'] -as [bool]
}

$outputAddedResult =
Add-OBSInput -sceneName $myParameters["Scene"] -inputKind "browser_source" -inputSettings $myParameterData -inputName $Name
Add-OBSInput @addObsInputParams
if ($outputAddedResult) {
Get-OBSSceneItem -sceneName $myParameters["Scene"] |
Where-Object SourceName -eq $name
Expand Down
Loading