UniversalDashboard.VideoPlayer.psm1

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
$JsFile = Get-ChildItem "$PSScriptRoot\index.*.bundle.js"
# Source maps to make it easier to debug in the browser
$Maps = Get-ChildItem "$PSScriptRoot\*.map"

$AssetId = [UniversalDashboard.Services.AssetService]::Instance.RegisterScript($JsFile.FullName)
# Register all the source map files so we can make debugging easier.
foreach ($item in $Maps) {
    [UniversalDashboard.Services.AssetService]::Instance.RegisterAsset($item.FullName) | Out-Null
}

function New-UDVideoPlayer {
    param
    (
        [Parameter()]
        [string]$Id = [guid]::NewGuid(),
        [Parameter()]
        [string]$ClassName,
        [Parameter(Mandatory)]
        [string]$Url,
        [Parameter()]
        [switch]$Playing,
        [Parameter()]
        [switch]$Loop,
        [Parameter()]
        [switch]$Controls,
        [Parameter()]
        [switch]$Light,
        [Parameter()]
        [float]$Volume = 0.45,
        [Parameter()]
        [switch]$Muted,
        [Parameter()]
        [int]$Width = 640,
        [Parameter()]
        [int]$Height = 360,
        [Parameter()]
        [hashtable]$Style,
        [Parameter()]
        [int]$ProgressInterval,
        [Parameter()]
        [switch]$PlaysInLine,
        [Parameter()]
        [switch]$Pip
    )

    End {

        @{
            assetId          = $AssetId 
            isPlugin         = $true 
            id               = $Id 
            type             = 'ud-videoplayer'
            url              = $Url
            playing          = $Playing.IsPresent
            loop             = $Loop.IsPresent
            controls         = $Controls.IsPresent
            light            = $Light.IsPresent
            volume           = $Volume
            muted            = $Muted.IsPresent
            width            = $Width
            height           = $Height
            style            = $Style
            progressInterval = $ProgressInterval
            playsinline      = $PlaysInLine.IsPresent
            pip              = $Pip.IsPresent
            className        = $ClassName
        }
    }
}