{"TotalCount":28,"Files":[{"Ident":"duccsoft.videopanel","Path":"Assembly.cs","FileName":"Assembly.cs","PackageType":"library","CodeKind":"Game","AssetVersionId":75857,"IsPrivate":false,"Code":"global using Sandbox;\r\nglobal using System.Collections.Generic;\r\nglobal using System.Linq;\r\n"},{"Ident":"duccsoft.videopanel","Path":"AsyncVideoLoader.cs","FileName":"AsyncVideoLoader.cs","PackageType":"library","CodeKind":"Game","AssetVersionId":75857,"IsPrivate":false,"Code":"using System.Threading.Tasks;\r\nusing System.Threading;\r\nusing System;\r\n\r\nnamespace Duccsoft;\r\n\r\n/// \u003Csummary\u003E\r\n/// Provides a handy asynchronous wrapper for loading a VideoPlayer and waiting\r\n/// until its video and audio are both loaded.\r\n/// \u003C/summary\u003E\r\npublic class AsyncVideoLoader\r\n{\r\n\tpublic AsyncVideoLoader() \r\n\t{\r\n\t\t_videoPlayer = new VideoPlayer();\r\n\t}\r\n\r\n\tpublic AsyncVideoLoader( VideoPlayer player )\r\n\t{\r\n\t\t_videoPlayer = player ?? new VideoPlayer();\r\n\t}\r\n\r\n\tpublic bool IsLoading { get; private set; }\r\n\r\n\tprivate VideoPlayer _videoPlayer;\r\n\tprivate Action _onLoaded;\r\n\tprivate Action _onAudioReady;\r\n\r\n\tpublic async Task\u003CVideoPlayer\u003E LoadFromUrl( string url, CancellationToken cancelToken = default )\r\n\t{\r\n\t\tvoid Play( VideoPlayer player ) =\u003E player.Play( url );\r\n\r\n\t\tawait Load( Play, cancelToken );\r\n\t\treturn _videoPlayer;\r\n\t}\r\n\r\n\tpublic async Task\u003CVideoPlayer\u003E LoadFromFile( BaseFileSystem fileSystem, string path, CancellationToken cancelToken )\r\n\t{\r\n\t\tvoid Play( VideoPlayer player ) =\u003E player.Play( fileSystem, path );\r\n\r\n\t\tawait Load( Play, cancelToken );\r\n\t\treturn _videoPlayer;\r\n\t}\r\n\r\n\tprivate async Task Load( Action\u003CVideoPlayer\u003E playAction, CancellationToken cancelToken = default )\r\n\t{\r\n\t\t// Attempting to play a video from a thread would throw an exception.\r\n\t\tawait GameTask.MainThread( cancelToken );\r\n\r\n\t\tif ( IsLoading )\r\n\t\t{\r\n\t\t\tthrow new InvalidOperationException( \u0022Another video was already being loaded. Check IsLoading or create a new instance of AsyncVideoLoader.\u0022 );\r\n\t\t}\r\n\r\n\t\tIsLoading = true;\r\n\r\n\t\tbool videoLoaded = false;\r\n\t\tbool audioLoaded = false;\r\n\r\n\t\t// Assign private members instead of named methods to the invocation lists of the\r\n\t\t// VideoPlayer delegates to break reference equality between runs.\r\n\t\t_onLoaded = () =\u003E videoLoaded = true;\r\n\t\t_onAudioReady = () =\u003E audioLoaded = true;\r\n\r\n\t\t_videoPlayer.OnLoaded = _onLoaded;\r\n\t\t_videoPlayer.OnAudioReady = _onAudioReady;\r\n\r\n\t\tplayAction?.Invoke( _videoPlayer );\r\n\r\n\t\t// Non-blocking spin until video and audio are loaded.\r\n\t\twhile ( !videoLoaded || !audioLoaded )\r\n\t\t{\r\n\t\t\t// If OnLoaded or OnAudioReady are changed externally before we\u0027re finished\r\n\t\t\t// loading, the video will likely never load. Abort to avoid spinning forever.\r\n\t\t\tvar callbacksChanged = _onLoaded != _videoPlayer.OnLoaded || _onAudioReady != _videoPlayer.OnAudioReady;\r\n\t\t\tif ( callbacksChanged || cancelToken.IsCancellationRequested )\r\n\t\t\t{\r\n\t\t\t\tIsLoading = false;\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tawait GameTask.Yield();\r\n\t\t}\r\n\r\n\t\tIsLoading = false;\r\n\t}\r\n}\r\n"},{"Ident":"duccsoft.videopanel","Path":"__gen_RazorNamespace.cs","FileName":"__gen_RazorNamespace.cs","PackageType":"library","CodeKind":"Game","AssetVersionId":75857,"IsPrivate":false,"Code":"global using Microsoft.AspNetCore.Components; \nglobal using Microsoft.AspNetCore.Components.Rendering;\n"},{"Ident":"duccsoft.videopanel","Path":"Code/IAudioAccessor.cs","FileName":"IAudioAccessor.cs","PackageType":"library","CodeKind":"Game","AssetVersionId":75857,"IsPrivate":false,"Code":"using Sandbox.Audio;\r\n\r\nnamespace Duccsoft;\r\n\r\n/// \u003Csummary\u003E\r\n/// Provides access to the audio-related functionality of VideoPlayer.\r\n/// \u003C/summary\u003E\r\npublic interface IAudioAccessor\r\n{\r\n\t/// \u003Csummary\u003E\r\n\t/// The position from which to play the sound.\r\n\t/// \u003C/summary\u003E\r\n\tpublic Vector3 Position { get; set; }\r\n\t/// \u003Csummary\u003E\r\n\t/// The volume at which the audio should play.\r\n\t/// \u003C/summary\u003E\r\n\tpublic float Volume { get; set; }\r\n\t/// \u003Csummary\u003E\r\n\t/// If true, audio will play as if it is coming from the UI. Otherwise, the\r\n\t/// audio will be spatialized to sound as if it coming from the world at \u003Csee cref=\u0022Position\u0022/\u003E.\r\n\t/// \u003C/summary\u003E\r\n\tpublic bool ListenLocal { get; set; }\r\n\t/// \u003Csummary\u003E\r\n\t/// Specifies which audio mixer the sound should be played through.\r\n\t/// \u003C/summary\u003E\r\n\tpublic Mixer TargetMixer { get; set; }\r\n\t/// \u003Csummary\u003E\r\n\t/// Specifies whether the audio should be muted. The state of \u003Csee cref=\u0022Muted\u0022/\u003E\r\n\t/// may not necessarily depend on the state of \u003Csee cref=\u0022Volume\u0022/\u003E or vice versa.\r\n\t/// \u003C/summary\u003E\r\n\tpublic bool Muted { get; set; }\r\n}\r\n"},{"Ident":"duccsoft.videopanel","Path":"Code/UI/VideoPanel.razor.scss","FileName":"VideoPanel.razor.scss","PackageType":"library","CodeKind":"Game","AssetVersionId":75857,"IsPrivate":false,"Code":".video-texture {\r\n    background-size: contain;\r\n    background-position: center;\r\n    background-repeat: no-repeat;\r\n}\r\n"},{"Ident":"duccsoft.videopanel","Path":"VideoRoot.cs","FileName":"VideoRoot.cs","PackageType":"library","CodeKind":"Game","AssetVersionId":75857,"IsPrivate":false,"Code":"namespace Duccsoft;\r\n\r\n/// \u003Csummary\u003E\r\n/// Specifies the root directory of video path.\r\n/// \u003C/summary\u003E\r\npublic enum VideoRoot\r\n{\r\n\t/// \u003Csummary\u003E\r\n\t/// Video path is relative to FileSystem.Mounted\r\n\t/// \u003C/summary\u003E\r\n\t[Icon(\u0022inventory_2\u0022)]\r\n\tMountedFileSystem,\r\n\t/// \u003Csummary\u003E\r\n\t/// Video path is relative to FileSystem.Data\r\n\t/// \u003C/summary\u003E\r\n\t[Icon(\u0022save\u0022)]\r\n\tDataFileSystem,\r\n\t/// \u003Csummary\u003E\r\n\t/// Video path is relative to FileSystem.OrganizationData\r\n\t/// \u003C/summary\u003E\r\n\t[Icon(\u0022business\u0022)]\r\n\tOrganizationDataFileSystem,\r\n\t/// \u003Csummary\u003E\r\n\t/// Video path is a URL to an video stream on the internet. This should be\r\n\t/// a direct link to the stream itself.\r\n\t/// \u003Cbr/\u003E\u003Cbr/\u003E\r\n\t/// To manually test whether a stream is valid, you can use the Open Network Stream \r\n\t/// feature of VLC Media Player, but not every stream that plays in VLC will work here.\r\n\t/// \u003C/summary\u003E\r\n\t[Icon(\u0022language\u0022)]\r\n\tWebStream\r\n}\r\n\r\npublic static class VideoRootExtensions\r\n{\r\n\t/// \u003Csummary\u003E\r\n\t/// Returns the file system associated with the given VideoRoot, or null if \r\n\t/// no file system exists.\r\n\t/// \u003C/summary\u003E\r\n\tpublic static BaseFileSystem AsFileSystem( this VideoRoot videoRoot )\r\n\t{\r\n\t\treturn videoRoot switch\r\n\t\t{\r\n\t\t\tVideoRoot.MountedFileSystem\t\t\t\t=\u003E FileSystem.Mounted,\r\n\t\t\tVideoRoot.DataFileSystem\t\t\t\t=\u003E FileSystem.Data,\r\n\t\t\tVideoRoot.OrganizationDataFileSystem\t=\u003E FileSystem.OrganizationData,\r\n\t\t\t_ =\u003E null\r\n\t\t};\r\n\t}\r\n}\t\r\n"},{"Ident":"duccsoft.videopanel","Path":"Code/UI/VideoControlOverlay.razor","FileName":"VideoControlOverlay.razor","PackageType":"library","CodeKind":"Game","AssetVersionId":75857,"IsPrivate":false,"Code":"@using Sandbox.UI;\r\n@namespace Duccsoft\r\n@inherits Panel\r\n\r\n\u003Croot class=@OverlayClass\u003E\r\n    \u003Cimage id=\u0022spinner\u0022 src=\u0022ui/img/BufferingCircle.png\u0022/\u003E\r\n    \u003Cdiv id=\u0022bottomBar\u0022\u003E\r\n        \u003Cdiv class=\u0022button symbol\u0022 onclick=@TogglePause\u003E@PlayButtonIcon\u003C/div\u003E\r\n        \u003Cdiv id=\u0022timecodeArea\u0022 class=@TimecodeAreaClass\u003E\r\n            \u003Cdiv class=\u0022progress time\u0022\u003E@ProgressText\u003C/div\u003E\r\n            \u003Cdiv class=\u0022progress center\u0022\u003E/\u003C/div\u003E\r\n            \u003Cdiv class=\u0022progress time right\u0022\u003E@DurationText\u003C/div\u003E\r\n        \u003C/div\u003E\r\n        \u003CSliderControl id=\u0022progressBar\u0022 Min=@(0) Max=@DurationSeconds \r\n            Value:bind=@PlaybackTime OnValueChanged=@ProgressBarChanged ShowValueTooltip=@false/\u003E\r\n        \u003Cdiv class=\u0022button symbol\u0022 onclick=@ToggleMute\u003E@VolumeButtonIcon\u003C/div\u003E\r\n    \u003C/div\u003E\r\n\u003C/root\u003E\r\n"},{"Ident":"duccsoft.videopanel","Path":"MediaUpdateSystem.cs","FileName":"MediaUpdateSystem.cs","PackageType":"library","CodeKind":"Game","AssetVersionId":75857,"IsPrivate":false,"Code":"namespace Duccsoft;\r\n\r\n/// \u003Csummary\u003E\r\n/// Responsible for updating every IMediaUpdateListener that has registered with this system.\r\n/// \u003C/summary\u003E\r\npublic class MediaUpdateSystem : GameObjectSystem\r\n{\r\n\tpublic MediaUpdateSystem( Scene scene ) : base( scene )\r\n\t{\r\n\t\tListen( Stage.StartUpdate, 0, Update, \u0022Media Update\u0022 );\r\n\t}\r\n\r\n\tprivate HashSet\u003CIMediaUpdateListener\u003E _listeners = new();\r\n\r\n\tprivate void Update()\r\n\t{\r\n\t\tforeach( var listener in _listeners )\r\n\t\t{\r\n\t\t\tlistener?.MediaUpdate();\r\n\t\t}\r\n\t}\r\n\r\n\t/// \u003Csummary\u003E\r\n\t/// Allows an IMediaUpdateListener to have its MediaUpdate method called every frame.\r\n\t/// \u003C/summary\u003E\r\n\tpublic void Register( IMediaUpdateListener listener )\r\n\t{\r\n\t\t_listeners.Add( listener );\r\n\t}\r\n\r\n\t/// \u003Csummary\u003E\r\n\t/// Removes an IMediaUpdateListener from the set of listeners that would have their\r\n\t/// MediaUpdate method called every frame. This should be called in the destructor\r\n\t/// or in Dispose.\r\n\t/// \u003C/summary\u003E\r\n\tpublic void Unregister( IMediaUpdateListener listener )\r\n\t{\r\n\t\t_listeners.Remove( listener );\r\n\t}\r\n}\r\n"},{"Ident":"duccsoft.videopanel","Path":"Code/IMediaUpdateListener.cs","FileName":"IMediaUpdateListener.cs","PackageType":"library","CodeKind":"Game","AssetVersionId":75857,"IsPrivate":false,"Code":"using System;\r\n\r\nnamespace Duccsoft;\r\n\r\n/// \u003Csummary\u003E\r\n/// Represents a presentation-related object that must be updated every frame.\r\n/// For example, a video that must update a texture, or a sound that must update \r\n/// its position.\r\n/// \u003C/summary\u003E\r\npublic interface IMediaUpdateListener : IDisposable\r\n{\r\n\t/// \u003Csummary\u003E\r\n\t/// Contains the code that must run every frame. Will only be called\r\n\t/// if this object has been registered with a MediaUpdateSystem.\r\n\t/// \u003C/summary\u003E\r\n\tvoid MediaUpdate();\r\n\r\n\t/// \u003Cinheritdoc cref=\u0022MediaUpdateSystem.Register(IMediaUpdateListener)\u0022/\u003E\r\n\tpublic static void Register( IMediaUpdateListener listener )\r\n\t{\r\n\t\tif ( listener is null )\r\n\t\t\treturn;\r\n\r\n\t\tvar system = Game.ActiveScene?.GetSystem\u003CMediaUpdateSystem\u003E();\r\n\t\tif ( system is null )\r\n\t\t\treturn;\r\n\r\n\t\tsystem.Register( listener );\r\n\t}\r\n\r\n\t/// \u003Cinheritdoc cref=\u0022MediaUpdateSystem.Unregister(IMediaUpdateListener)\u0022/\u003E\r\n\tpublic static void Unregister( IMediaUpdateListener listener )\r\n\t{\r\n\t\tif ( listener is null )\r\n\t\t\treturn;\r\n\r\n\t\tvar system = Game.ActiveScene?.GetSystem\u003CMediaUpdateSystem\u003E();\r\n\t\tif ( system is null )\r\n\t\t\treturn;\r\n\r\n\t\tsystem.Unregister( listener );\r\n\t}\r\n}\r\n"},{"Ident":"duccsoft.videopanel","Path":"Code/AsyncVideoLoader.cs","FileName":"AsyncVideoLoader.cs","PackageType":"library","CodeKind":"Game","AssetVersionId":75857,"IsPrivate":false,"Code":"using System.Threading.Tasks;\r\nusing System.Threading;\r\nusing System;\r\n\r\nnamespace Duccsoft;\r\n\r\n/// \u003Csummary\u003E\r\n/// Provides a handy asynchronous wrapper for loading a VideoPlayer and waiting\r\n/// until its video and audio are both loaded.\r\n/// \u003C/summary\u003E\r\npublic class AsyncVideoLoader\r\n{\r\n\tpublic AsyncVideoLoader() \r\n\t{\r\n\t\t_videoPlayer = new VideoPlayer();\r\n\t}\r\n\r\n\tpublic AsyncVideoLoader( VideoPlayer player )\r\n\t{\r\n\t\t_videoPlayer = player ?? new VideoPlayer();\r\n\t}\r\n\r\n\tpublic bool IsLoading { get; private set; }\r\n\r\n\tprivate VideoPlayer _videoPlayer;\r\n\tprivate Action _onLoaded;\r\n\tprivate Action _onAudioReady;\r\n\r\n\tpublic async Task\u003CVideoPlayer\u003E LoadFromUrl( string url, CancellationToken cancelToken = default )\r\n\t{\r\n\t\tvoid Play( VideoPlayer player ) =\u003E player.Play( url );\r\n\r\n\t\tawait Load( Play, cancelToken );\r\n\t\treturn _videoPlayer;\r\n\t}\r\n\r\n\tpublic async Task\u003CVideoPlayer\u003E LoadFromFile( BaseFileSystem fileSystem, string path, CancellationToken cancelToken )\r\n\t{\r\n\t\tvoid Play( VideoPlayer player ) =\u003E player.Play( fileSystem, path );\r\n\r\n\t\tawait Load( Play, cancelToken );\r\n\t\treturn _videoPlayer;\r\n\t}\r\n\r\n\tprivate async Task Load( Action\u003CVideoPlayer\u003E playAction, CancellationToken cancelToken = default )\r\n\t{\r\n\t\t// Attempting to play a video from a thread would throw an exception.\r\n\t\tawait GameTask.MainThread( cancelToken );\r\n\r\n\t\tif ( IsLoading )\r\n\t\t{\r\n\t\t\tthrow new InvalidOperationException( \u0022Another video was already being loaded. Check IsLoading or create a new instance of AsyncVideoLoader.\u0022 );\r\n\t\t}\r\n\r\n\t\tIsLoading = true;\r\n\r\n\t\tbool videoLoaded = false;\r\n\t\tbool audioLoaded = false;\r\n\r\n\t\t// Assign private members instead of named methods to the invocation lists of the\r\n\t\t// VideoPlayer delegates to break reference equality between runs.\r\n\t\t_onLoaded = () =\u003E videoLoaded = true;\r\n\t\t_onAudioReady = () =\u003E audioLoaded = true;\r\n\r\n\t\t_videoPlayer.OnLoaded = _onLoaded;\r\n\t\t_videoPlayer.OnAudioReady = _onAudioReady;\r\n\r\n\t\tplayAction?.Invoke( _videoPlayer );\r\n\r\n\t\t// Non-blocking spin until video and audio are loaded.\r\n\t\twhile ( !videoLoaded || !audioLoaded )\r\n\t\t{\r\n\t\t\t// If OnLoaded or OnAudioReady are changed externally before we\u0027re finished\r\n\t\t\t// loading, the video will likely never load. Abort to avoid spinning forever.\r\n\t\t\tvar callbacksChanged = _onLoaded != _videoPlayer.OnLoaded || _onAudioReady != _videoPlayer.OnAudioReady;\r\n\t\t\tif ( callbacksChanged || cancelToken.IsCancellationRequested )\r\n\t\t\t{\r\n\t\t\t\tIsLoading = false;\r\n\t\t\t\treturn;\r\n\t\t\t}\r\n\r\n\t\t\tawait GameTask.Yield();\r\n\t\t}\r\n\r\n\t\tIsLoading = false;\r\n\t}\r\n}\r\n"},{"Ident":"duccsoft.videopanel","Path":"UI/VideoControlOverlay.razor","FileName":"VideoControlOverlay.razor","PackageType":"library","CodeKind":"Game","AssetVersionId":75857,"IsPrivate":false,"Code":"@using Sandbox.UI;\r\n@namespace Duccsoft\r\n@inherits Panel\r\n\r\n\u003Croot class=@OverlayClass\u003E\r\n    \u003Cimage id=\u0022spinner\u0022 src=\u0022ui/img/BufferingCircle.png\u0022/\u003E\r\n    \u003Cdiv id=\u0022bottomBar\u0022\u003E\r\n        \u003Cdiv class=\u0022button symbol\u0022 onclick=@TogglePause\u003E@PlayButtonIcon\u003C/div\u003E\r\n        \u003Cdiv id=\u0022timecodeArea\u0022 class=@TimecodeAreaClass\u003E\r\n            \u003Cdiv class=\u0022progress time\u0022\u003E@ProgressText\u003C/div\u003E\r\n            \u003Cdiv class=\u0022progress center\u0022\u003E/\u003C/div\u003E\r\n            \u003Cdiv class=\u0022progress time right\u0022\u003E@DurationText\u003C/div\u003E\r\n        \u003C/div\u003E\r\n        \u003CSliderControl id=\u0022progressBar\u0022 Min=@(0) Max=@DurationSeconds \r\n            Value:bind=@PlaybackTime OnValueChanged=@ProgressBarChanged ShowValueTooltip=@false/\u003E\r\n        \u003Cdiv class=\u0022button symbol\u0022 onclick=@ToggleMute\u003E@VolumeButtonIcon\u003C/div\u003E\r\n    \u003C/div\u003E\r\n\u003C/root\u003E\r\n"},{"Ident":"duccsoft.videopanel","Path":"Code/MediaUpdateSystem.cs","FileName":"MediaUpdateSystem.cs","PackageType":"library","CodeKind":"Game","AssetVersionId":75857,"IsPrivate":false,"Code":"namespace Duccsoft;\r\n\r\n/// \u003Csummary\u003E\r\n/// Responsible for updating every IMediaUpdateListener that has registered with this system.\r\n/// \u003C/summary\u003E\r\npublic class MediaUpdateSystem : GameObjectSystem\r\n{\r\n\tpublic MediaUpdateSystem( Scene scene ) : base( scene )\r\n\t{\r\n\t\tListen( Stage.StartUpdate, 0, Update, \u0022Media Update\u0022 );\r\n\t}\r\n\r\n\tprivate HashSet\u003CIMediaUpdateListener\u003E _listeners = new();\r\n\r\n\tprivate void Update()\r\n\t{\r\n\t\tforeach( var listener in _listeners )\r\n\t\t{\r\n\t\t\tlistener?.MediaUpdate();\r\n\t\t}\r\n\t}\r\n\r\n\t/// \u003Csummary\u003E\r\n\t/// Allows an IMediaUpdateListener to have its MediaUpdate method called every frame.\r\n\t/// \u003C/summary\u003E\r\n\tpublic void Register( IMediaUpdateListener listener )\r\n\t{\r\n\t\t_listeners.Add( listener );\r\n\t}\r\n\r\n\t/// \u003Csummary\u003E\r\n\t/// Removes an IMediaUpdateListener from the set of listeners that would have their\r\n\t/// MediaUpdate method called every frame. This should be called in the destructor\r\n\t/// or in Dispose.\r\n\t/// \u003C/summary\u003E\r\n\tpublic void Unregister( IMediaUpdateListener listener )\r\n\t{\r\n\t\t_listeners.Remove( listener );\r\n\t}\r\n}\r\n"},{"Ident":"duccsoft.videopanel","Path":"Code/UI/VideoControlOverlay.razor.cs","FileName":"VideoControlOverlay.razor.cs","PackageType":"library","CodeKind":"Game","AssetVersionId":75857,"IsPrivate":false,"Code":"using Sandbox.UI;\r\nusing System;\r\n\r\nnamespace Duccsoft;\r\n\r\n/// \u003Csummary\u003E\r\n/// A Panel meant to stretch over an entire VideoPanel and provide a progress bar and buttons.\r\n/// \u003C/summary\u003E\r\npublic partial class VideoControlOverlay : Panel\r\n{\r\n\t/// \u003Csummary\u003E\r\n\t/// The VideoPanel instance that we will be controlling. You may replace this with any\r\n\t/// \u003Csee cref=\u0022IVideoPanel\u0022/\u003E object that you that you wish to control using this UI.\r\n\t/// \u003C/summary\u003E\r\n\tpublic IVideoPanel VideoPanel { get; set; }\r\n\t/// \u003Csummary\u003E\r\n\t/// If true, the video controls will automatically be hidden after the AutoHideDelay period has elapsed\r\n\t/// and the user is not hovering their mouse over this panel.\r\n\t/// \u003C/summary\u003E\r\n\tpublic bool AutoHide { get; set; } = true;\r\n\t/// \u003Csummary\u003E\r\n\t/// If AutoHide is true, this is the time in seconds that must elapse before this panel\r\n\t/// will conceal the video controls.\r\n\t/// \u003C/summary\u003E\r\n\tpublic float AutoHideDelay { get; set; } = 1f;\r\n\r\n\t#region Presentation\r\n\tprivate string OverlayClass\r\n\t{\r\n\t\tget\r\n\t\t{\r\n\t\t\tvar overlayClass = VideoPanel?.IsLoading == true ? \u0022loading\u0022 : string.Empty;\r\n\r\n\t\t\tif ( !AutoHide )\r\n\t\t\t\treturn overlayClass;\r\n\r\n\t\t\tvar hovered = PseudoClass.HasFlag( PseudoClass.Hover );\r\n\t\t\tif ( hovered )\r\n\t\t\t{\r\n\t\t\t\t_lastHovered = 0f;\r\n\t\t\t\treturn overlayClass;\r\n\t\t\t}\r\n\t\t\treturn _lastHovered \u003E AutoHideDelay ? $\u0022{overlayClass} conceal\u0022 : overlayClass;\r\n\t\t}\r\n\t}\r\n\tprivate string TimecodeAreaClass =\u003E ProgressSeconds \u003E 3600 || DurationSeconds \u003E 3600\r\n\t\t? \u0022big\u0022\r\n\t\t: string.Empty;\r\n\tprivate string ProgressText =\u003E FormatTime( ProgressSeconds );\r\n\tprivate string DurationText =\u003E FormatTime( DurationSeconds );\r\n\tprivate string FormatTime( float seconds )\r\n\t{\r\n\t\tvar time = TimeSpan.FromSeconds( seconds );\r\n\t\treturn time.Hours \u003E 0\r\n\t\t\t? time.ToString( \u0022hh\u0027:\u0027mm\u0027:\u0027ss\u0022 )\r\n\t\t\t: time.ToString( \u0022mm\u0027:\u0027ss\u0022 );\r\n\t}\r\n\tprivate string PlayButtonIcon\r\n\t{\r\n\t\tget\r\n\t\t{\r\n\t\t\tif ( !VideoPanel.IsValid() )\r\n\t\t\t\treturn \u0022play_arrow\u0022;\r\n\r\n\t\t\treturn VideoPanel.IsPaused ? \u0022play_arrow\u0022 : \u0022pause\u0022;\r\n\t\t}\r\n\t}\r\n\r\n\tprivate float ProgressSeconds =\u003E VideoPanel?.PlaybackTime ?? 0f;\r\n\tprivate float DurationSeconds =\u003E VideoPanel?.Duration ?? 0f;\r\n\tprivate string VolumeButtonIcon =\u003E VideoPanel?.Audio?.Muted == false ? \u0022volume_up\u0022 : \u0022volume_off\u0022;\r\n\t#endregion\r\n\r\n\tprivate RealTimeSince _lastHovered = 20f;\r\n\r\n\tprotected override int BuildHash()\r\n\t{\r\n\t\treturn HashCode.Combine( VideoPanel?.IsPlaying, VideoPanel?.IsPaused, VideoPanel?.Audio?.Muted, (int)ProgressSeconds, TimecodeAreaClass, OverlayClass  );\r\n\t}\r\n\r\n\t#region Controls\r\n\tprivate float PlaybackTime\r\n\t{\r\n\t\tget =\u003E ProgressSeconds;\r\n\t\tset =\u003E VideoPanel?.Seek( value );\r\n\t}\r\n\r\n\tprivate void ProgressBarChanged( float value )\r\n\t{\r\n\t\tPlaybackTime = value;\r\n\t}\r\n\r\n\tprivate void TogglePause() =\u003E VideoPanel?.TogglePause();\r\n\tprivate void ToggleMute()\r\n\t{\r\n\t\tif ( !VideoPanel.IsValid() || VideoPanel.Audio is null )\r\n\t\t\treturn;\r\n\r\n\t\tVideoPanel.Audio.Muted = !VideoPanel.Audio.Muted;\r\n\t}\r\n\t#endregion\r\n}\r\n"},{"Ident":"duccsoft.videopanel","Path":"Code/UI/VideoControlOverlay.razor.scss","FileName":"VideoControlOverlay.razor.scss","PackageType":"library","CodeKind":"Game","AssetVersionId":75857,"IsPrivate":false,"Code":"@keyframes pop-up {\r\n    from {\r\n        opacity: 0;\r\n        transform: translateY( 100% );\r\n    }\r\n\r\n    to {\r\n        opacity: 1;\r\n        transform: translateY( 0% );\r\n    }\r\n}\r\n\r\n@keyframes hide {\r\n    from {\r\n        opacity: 1;\r\n        transform: translateY( 0% );\r\n    }\r\n\r\n    to {\r\n        opacity: 0;\r\n        transform: translateY( 100% );\r\n    }\r\n}\r\n\r\n@keyframes spin {\r\n    from {\r\n        transform: rotate( 0deg );\r\n    }\r\n\r\n    to {\r\n        transform: rotate( 360deg );\r\n    }\r\n}\r\n\r\nVideoControlOverlay {\r\n    position: absolute;\r\n    width: 100%;\r\n    height: 100%;\r\n    overflow: hidden;\r\n\r\n    \u003E #spinner {\r\n        display: none;\r\n    }\r\n\r\n    \u0026.loading \u003E #spinner {\r\n        display: flex;\r\n        position: absolute;\r\n        left: 30%;\r\n        top: 30%;\r\n        width: 40%;\r\n        height: 40%;\r\n        animation: spin 1s infinite;\r\n        background-size: contain;\r\n        background-position: center;\r\n        background-repeat: no-repeat;\r\n    }\r\n\r\n    \u0026.conceal \u003E #bottomBar {\r\n        transform: translateY( 100% );\r\n        opacity: 0;\r\n        animation: hide 0.08s;\r\n    }\r\n\r\n    \u003E #bottomBar {\r\n        position: absolute;\r\n        bottom: 0%;\r\n        width: 100%;\r\n        align-items: center;\r\n        padding: 5px;\r\n        font-family: Poppins;\r\n        background-color: #000000FC;\r\n        color: #FFFFFFF0;\r\n\r\n        transform: translateY( 0% );\r\n        opacity: 1;\r\n        animation: pop-up 0.08s;\r\n\r\n        .button {\r\n            border: 1px solid #FFFFFF02;\r\n            border-radius: 5px;\r\n            padding: 5px;\r\n            background-color: #000E;\r\n\r\n            \u0026:hover {\r\n                background-color: #222E;\r\n            }\r\n\r\n            \u0026:active {\r\n                transform: scale(0.98);\r\n            }\r\n        }\r\n\r\n        .symbol {\r\n            font-size: 32px;\r\n            font-family: Material Icons;\r\n        }\r\n\r\n        \u003E * {\r\n            margin: 0px 5px;\r\n        }\r\n\r\n        #timecodeArea {\r\n            position: relative;\r\n            width: 20%;\r\n            justify-content: center;\r\n            align-items: center;\r\n            font-size: 18px;\r\n\r\n            \u0026.big {\r\n                width: 22.5%;\r\n            }\r\n\r\n            .progress {\r\n                flex-wrap: nowrap;\r\n                align-items: center;\r\n\r\n                \u0026.time {\r\n                    min-width: 10%;\r\n                }\r\n\r\n                \u0026.right {\r\n                    justify-content: flex-end;\r\n                }\r\n            }\r\n        }\r\n\r\n        #progressBar {\r\n\r\n            .inner {\r\n                justify-content: center;\r\n                min-height: 0px;\r\n\r\n                .track {\r\n                    height: 14px;\r\n                    margin: 0px;\r\n\r\n                    .thumb {\r\n                        height: 14px;\r\n                        width: 14px;\r\n                    }\r\n                }\r\n            }\r\n\r\n            .value-tooltip {\r\n                // Only required because SliderControl.ShowValueTooltip isn\u0027t hooked up to anything.\r\n                display: none;\r\n            }\r\n        }\r\n    }\r\n}\r\n"},{"Ident":"duccsoft.videopanel","Path":"UI/VideoPanel.razor.cs","FileName":"VideoPanel.razor.cs","PackageType":"library","CodeKind":"Game","AssetVersionId":75857,"IsPrivate":false,"Code":"using Sandbox.Audio;\r\nusing Sandbox.UI;\r\nusing System;\r\nusing System.Threading;\r\nusing System.Threading.Tasks;\r\n\r\nnamespace Duccsoft;\r\n\r\n/// \u003Csummary\u003E\r\n/// A Panel that manages an instance of a VideoPlayer, using its texture as the background image.\r\n/// Supports all the playback controls of VideoPlayer.\r\n/// \u003C/summary\u003E\r\n[Alias(\u0022video\u0022)]\r\npublic partial class VideoPanel : Panel, IVideoPanel\r\n{\r\n\t/// \u003Csummary\u003E\r\n\t/// The path/url of a video relative to VideoRoot.\r\n\t/// \u003C/summary\u003E\r\n\tpublic string VideoPath { get; set; }\r\n\t/// \u003Csummary\u003E\r\n\t/// Specifies where the video may be found, whether it comes from a BaseFileSystem or a website.\r\n\t/// Set this to \u003Csee cref=\u0022VideoRoot.WebStream\u0022/\u003E if VideoPath is a URL.\r\n\t/// \u003C/summary\u003E\r\n\tpublic VideoRoot VideoRoot { get; set; } = VideoRoot.MountedFileSystem;\r\n\t/// \u003Csummary\u003E\r\n\t/// If true, the video will automatically loop whenever HasReachedEnd is true.\r\n\t/// \u003C/summary\u003E\r\n\tpublic bool ShouldLoop { get; set; } = true;\r\n\tpublic bool AutoPlay { get; set; } = true;\r\n\tpublic bool StartMuted { get; set; } = false;\r\n\r\n\r\n\tpublic bool ShowControls { get; set; } = false;\r\n\tpublic bool AutoHideControls { get; set; } = true;\r\n\tpublic float AutoHideDelay { get; set; } = 1f;\r\n\t\r\n\tpublic float Width\r\n\t{\r\n\t\tget\r\n\t\t{\r\n\t\t\tif ( Style is null || Parent is null )\r\n\t\t\t\treturn 0f;\r\n\r\n\t\t\treturn Style.Width.Value.GetPixels( Parent.Box.Rect.Width );\r\n\t\t}\r\n\t\tset\r\n\t\t{\r\n\t\t\tif ( Style is null )\r\n\t\t\t\treturn;\r\n\r\n\t\t\tStyle.Width = Length.Pixels( value );\r\n\t\t}\r\n\t}\r\n\tpublic float Height\r\n\t{\r\n\t\tget\r\n\t\t{\r\n\t\t\tif ( Style is null || Parent is null )\r\n\t\t\t\treturn 0f;\r\n\r\n\t\t\treturn Style.Height.Value.GetPixels( Parent.Box.Rect.Height );\r\n\t\t}\r\n\t\tset\r\n\t\t{\r\n\t\t\tif ( Style is null )\r\n\t\t\t\treturn;\r\n\r\n\t\t\tStyle.Height = Length.Pixels( value );\r\n\t\t}\r\n\t}\r\n\r\n\t/// \u003Csummary\u003E\r\n\t/// If true, the video is in the process of being loaded (e.g. from a remote server).\r\n\t/// \u003C/summary\u003E\r\n\tpublic bool IsLoading =\u003E _videoLoader?.IsLoading != false || ( IsPlaying \u0026\u0026 _sinceLastTextureUpdate \u003E 0.2f );\r\n\t/// \u003Csummary\u003E\r\n\t/// If true, the video is playing, is not paused, and has not yet finished playing.\r\n\t/// \u003C/summary\u003Ea\r\n\tpublic bool IsPlaying =\u003E !HasReachedEnd \u0026\u0026 VideoPlayer is not null \u0026\u0026 !VideoPlayer.IsPaused;\r\n\t/// \u003Csummary\u003E\r\n\t/// If true, this video has reached the end of the file. If ShouldLoop is enabled, the video will\r\n\t/// automatically loop.\r\n\t/// \u003C/summary\u003E\r\n\tpublic bool HasReachedEnd =\u003E VideoPlayer != null \u0026\u0026 VideoPlayer.PlaybackTime \u003E= VideoPlayer.Duration;\r\n\r\n\t#region Controls\r\n\t/// \u003Cinheritdoc cref=\u0022VideoPlayer.Pause\u0022/\u003E\r\n\tpublic void Pause() =\u003E VideoPlayer?.Pause();\r\n\r\n\t/// \u003Cinheritdoc cref=\u0022VideoPlayer.IsPaused\u0022/\u003E\r\n\tpublic bool IsPaused =\u003E VideoPlayer?.IsPaused == true;\r\n\r\n\t/// \u003Cinheritdoc cref=\u0022VideoPlayer.Resume\u0022/\u003E\r\n\tpublic void Resume() =\u003E VideoPlayer?.Resume();\r\n\r\n\t/// \u003Cinheritdoc cref=\u0022VideoPlayer.TogglePause\u0022/\u003E\r\n\tpublic void TogglePause() =\u003E VideoPlayer?.TogglePause();\r\n\r\n\t/// \u003Cinheritdoc cref=\u0022VideoPlayer.Seek(float)\u0022/\u003E\r\n\tpublic void Seek( float time ) =\u003E VideoPlayer?.Seek( time );\r\n\r\n\t/// \u003Cinheritdoc cref=\u0022VideoPlayer.Duration\u0022/\u003E\r\n\tpublic float Duration =\u003E VideoPlayer?.Duration ?? 0f;\r\n\r\n\t/// \u003Csummary\u003E\r\n\t/// Returns the current playback time in seconds of the video, or if setting,\r\n\t/// will seek to the specified playback time in seconds.\r\n\t/// \u003C/summary\u003E\r\n\tpublic float PlaybackTime\r\n\t{\r\n\t\tget =\u003E VideoPlayer?.PlaybackTime ?? 0f;\r\n\t\tset =\u003E Seek( value );\r\n\t}\r\n\r\n\t/// \u003Cinheritdoc cref=\u0022VideoPlayer.Stop\u0022/\u003E\r\n\tpublic void Stop() =\u003E VideoPlayer?.Stop();\r\n\r\n\t/// \u003Csummary\u003E\r\n\t/// Provides access to the various audio-related properties of VideoPlayer such\r\n\t/// as Volume and Position.\r\n\t/// \u003C/summary\u003E\r\n\tpublic IAudioAccessor Audio =\u003E _audioAccessor;\r\n\r\n\t/// \u003Csummary\u003E\r\n\t/// Specifies a GameObject in the world from which the audio of this video shall be emitted.\r\n\t/// \u003C/summary\u003E\r\n\tpublic GameObject AudioSource \r\n\t{\r\n\t\tget =\u003E _audioSource;\r\n\t\tset\r\n\t\t{\r\n\t\t\t_audioSource = value;\r\n\t\t\tif ( _audioAccessor is not null )\r\n\t\t\t{\r\n\t\t\t\t_audioAccessor.Target = value;\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tprivate GameObject _audioSource;\r\n\tpublic MixerHandle TargetMixer\r\n\t{\r\n\t\tget =\u003E _targetMixer;\r\n\t\tset\r\n\t\t{\r\n\t\t\t_targetMixer = value;\r\n\t\t\tif ( _audioAccessor is not null )\r\n\t\t\t{\r\n\t\t\t\t_audioAccessor.TargetMixer = value.Get();\r\n\t\t\t}\r\n\t\t}\r\n\t}\r\n\tprivate MixerHandle _targetMixer;\r\n\t#endregion\r\n\r\n\t// Internal state\r\n\tprivate VideoPlayer VideoPlayer { get; set; }\r\n\tprivate Texture VideoTexture { get; set; }\r\n\tprivate AsyncVideoLoader _videoLoader;\r\n\tprivate Task\u003CVideoPlayer\u003E _videoLoadTask;\r\n\tprivate TrackingAudioAccessor _audioAccessor;\r\n\tprivate CancellationTokenSource _cancelSource = new();\r\n\tprivate bool _shouldPauseNextFrame;\r\n\tprivate RealTimeSince _sinceLastTextureUpdate;\r\n\r\n\tprotected override int BuildHash() =\u003E HashCode.Combine( ShowControls, AutoHideControls, AutoHideDelay );\r\n\r\n\tpublic override void SetProperty( string name, string value )\r\n\t{\r\n\t\tif ( name == \u0022src\u0022 )\r\n\t\t{\r\n\t\t\tVideoPath = value;\r\n\t\t}\r\n\r\n\t\tif ( name == \u0022width\u0022 )\r\n\t\t{\r\n\t\t\tStyle.Width = Length.Pixels( value.ToFloat( 160 ) );\r\n\t\t}\r\n\r\n\t\tif ( name == \u0022height\u0022 )\r\n\t\t{\r\n\t\t\tStyle.Height = Length.Pixels( value.ToFloat( 90 ) );\r\n\t\t}\r\n\r\n\t\tif ( name == \u0022muted\u0022 )\r\n\t\t{\r\n\t\t\tStartMuted = value.ToBool();\r\n\t\t}\r\n\r\n\t\tbase.SetProperty( name, value );\r\n\t}\r\n\r\n\tprotected async override void OnAfterTreeRender( bool firstTime )\r\n\t{\r\n\t\tbase.OnAfterTreeRender( firstTime );\r\n\r\n\t\tif ( !firstTime )\r\n\t\t\treturn;\r\n\r\n\t\tVideoPlayer = new VideoPlayer();\r\n\r\n\t\t// Attempt to play whatever video is specified by the initial VideoPath and VideoRoot.\r\n\t\tawait PlayVideo();\r\n\t}\r\n\r\n\t/// \u003Csummary\u003E\r\n\t/// Attempt to play whatever video is specified by the current VideoPath and VideoRoot.\r\n\t/// \u003C/summary\u003E\r\n\tprivate async Task PlayVideo()\r\n\t{\r\n\t\t// Now we\u0027re using the new video path and root.\r\n\t\t_previousVideoPath = VideoPath;\r\n\t\t_previousVideoRoot = VideoRoot;\r\n\r\n\t\tStop();\r\n\r\n\t\t// Blank out the background when setting a new background image.\r\n\t\tStyle.SetBackgroundImage( (Texture)null );\r\n\t\tStateHasChanged();\r\n\t\tVideoTexture = null;\r\n\r\n\t\t// Trying to play nothing? Success means stopping the current video.\r\n\t\tif ( string.IsNullOrWhiteSpace( VideoPath ) )\r\n\t\t{\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// Cancel whatever other video might be loading.\r\n\t\tif ( _videoLoadTask is not null )\r\n\t\t{\r\n\t\t\tCancelVideoLoad();\r\n\t\t\t// Wait for that video to finish cancelling before we load our own.\r\n\t\t\tawait _videoLoadTask;\r\n\t\t}\r\n\r\n\t\tVideoPlayer ??= new VideoPlayer();\r\n\t\tVideoPlayer.OnTextureData = OnTextureData;\r\n\r\n\t\t_cancelSource = new CancellationTokenSource();\r\n\t\t// Cache the CancellationToken because Task.IsCanceled isn\u0027t whitelisted,\r\n\t\t// and subsequent calls to PlayVideo would create a new CancellationTokenSource.\r\n\t\tvar cancelToken = _cancelSource.Token;\r\n\r\n\t\t_videoLoadTask = LoadVideo( cancelToken );\r\n\t\tVideoPlayer = await _videoLoadTask;\r\n\t\t_videoLoadTask = null;\r\n\r\n\t\t// If loading the video was cancelled...\r\n\t\tif ( cancelToken.IsCancellationRequested )\r\n\t\t{\r\n\t\t\t// ...don\u0027t touch the video player, and don\u0027t update anything, because\r\n\t\t\t// there may be another video that began loading later and finished before\r\n\t\t\t// this one, and we don\u0027t want to overwrite the effect it had.\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t_shouldPauseNextFrame = !AutoPlay;\r\n\t\tConfigureAudio();\r\n\t\tUpdateBackgroundImage();\r\n\t}\r\n\r\n\tprivate void OnTextureData( ReadOnlySpan\u003Cbyte\u003E span, Vector2 size )\r\n\t{\r\n\t\t_sinceLastTextureUpdate = 0f;\r\n\t\tint width = (int)size.x;\r\n\t\tint height = (int)size.y;\r\n\t\tif ( VideoTexture is null || VideoTexture.Size != size )\r\n\t\t{\r\n\t\t\tVideoTexture = Texture.Create( width, height, ImageFormat.RGBA8888 )\r\n\t\t\t\t.WithName( \u0022VideoPanel_Texture\u0022 )\r\n\t\t\t\t.Finish();\r\n\t\t\tUpdateBackgroundImage();\r\n\t\t}\r\n\t\tVideoTexture.Update( span, 0, 0, width, height );\r\n\r\n\t\tif ( _shouldPauseNextFrame )\r\n\t\t{\r\n\t\t\tVideoPlayer.Pause();\r\n\t\t\t_shouldPauseNextFrame = false;\r\n\t\t}\r\n\t}\r\n\r\n\t/// \u003Csummary\u003E\r\n\t/// By default, will ensure that a TrackingAudioAccessor is created and\r\n\t/// configured to use the VideoPlayer and AudioSource of this VideoPanel.\r\n\t/// \u003Cbr/\u003E\u003Cbr/\u003E\r\n\t/// Called in PlayVideo after a video is loaded, but before OnPostVideoLoad.\r\n\t/// \u003C/summary\u003E\r\n\tprivate void ConfigureAudio()\r\n\t{\r\n\t\t_audioAccessor ??= new TrackingAudioAccessor()\r\n\t\t{\r\n\t\t\tMuted = StartMuted\r\n\t\t};\r\n\t\t_audioAccessor.VideoPlayer = VideoPlayer;\r\n\t\t_audioAccessor.Target = AudioSource;\r\n\t\t_audioAccessor.TargetMixer = TargetMixer.Get();\r\n\t}\r\n\r\n\t/// \u003Csummary\u003E\r\n\t/// By default, sets the background image of this panel to VideoTexture and rebuilds the UI.\r\n\t/// \u003Cbr/\u003E\u003Cbr/\u003E\r\n\t/// Called in PlayVideo after a video is loaded, but before OnPostVideoLoad.\r\n\t/// \u003C/summary\u003E\r\n\tprivate void UpdateBackgroundImage()\r\n\t{\r\n\t\tif ( VideoPlayer is null )\r\n\t\t\treturn;\r\n\r\n\t\tStyle.SetBackgroundImage( VideoTexture );\r\n\t\tStateHasChanged();\r\n\t}\r\n\t\r\n\r\n\t/// \u003Csummary\u003E\r\n\t/// Load whatever video is specified by the current VideoPath and VideoRoot, returning\r\n\t/// an instance of a VideoPlayer. Called during PlayVideo.\r\n\t/// \u003C/summary\u003E\r\n\tprivate async Task\u003CVideoPlayer\u003E LoadVideo( CancellationToken cancelToken )\r\n\t{\r\n\t\t_videoLoader ??= new AsyncVideoLoader( VideoPlayer );\r\n\r\n\t\tif ( VideoRoot == VideoRoot.WebStream )\r\n\t\t{\r\n\t\t\treturn await _videoLoader.LoadFromUrl( VideoPath, cancelToken );\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\treturn await _videoLoader.LoadFromFile( VideoRoot.AsFileSystem(), VideoPath, cancelToken );\r\n\t\t}\r\n\t}\r\n\r\n\tprivate void CancelVideoLoad()\r\n\t{\r\n\t\t_cancelSource?.Cancel();\r\n\t\t_cancelSource?.Dispose();\r\n\t\t_cancelSource = null;\r\n\t}\r\n\r\n\t// Refresh detection\r\n\tprivate string _previousVideoPath;\r\n\tprivate VideoRoot _previousVideoRoot;\r\n\r\n\tprivate bool VideoHasChanged =\u003E _previousVideoPath != VideoPath || _previousVideoRoot != VideoRoot;\r\n\r\n\tpublic override void Tick()\r\n\t{\r\n\t\tif ( VideoPlayer is null )\r\n\t\t\treturn;\r\n\r\n\t\t// If the VideoPath or VideoRoot have changed...\r\n\t\tif ( VideoHasChanged )\r\n\t\t{\r\n\t\t\t// ...play that new video instead.\r\n\t\t\t_ = PlayVideo();\r\n\t\t\treturn;\r\n\t\t}\r\n\r\n\t\t// The VideoTexture will not update unless Present is called.\r\n\t\tVideoPlayer.Present();\r\n\r\n\t\tDetectAndHandleLoop();\r\n\t}\r\n\r\n\t/// \u003Csummary\u003E\r\n\t/// By default, detects whether the video has reached its conclusion. \r\n\t/// If so, and if ShouldLoop is true, the playback time will be \r\n\t/// set to the start of the video.\r\n\t/// \u003C/summary\u003E\r\n\tprivate void DetectAndHandleLoop()\r\n\t{\r\n\t\t// We use a custom looping mechanism because VideoPlayer.Repeat seems to mess up PlaybackTime.\r\n\t\tif ( ShouldLoop \u0026\u0026 HasReachedEnd )\r\n\t\t{\r\n\t\t\tVideoPlayer.Seek( 0f );\r\n\t\t}\r\n\t}\r\n\r\n\tpublic override void OnDeleted()\r\n\t{\r\n\t\tCancelVideoLoad();\r\n\t\tVideoPlayer?.Stop();\r\n\t\tVideoPlayer?.Dispose();\r\n\t\tVideoTexture?.Dispose();\r\n\t\t_audioAccessor?.Dispose();\r\n\t}\r\n}\r\n"},{"Ident":"duccsoft.videopanel","Path":"Code/TrackingAudioAccessor.cs","FileName":"TrackingAudioAccessor.cs","PackageType":"library","CodeKind":"Game","AssetVersionId":75857,"IsPrivate":false,"Code":"using Sandbox.Audio;\r\nusing System;\r\n\r\nnamespace Duccsoft;\r\n\r\n/// \u003Csummary\u003E\r\n/// Stores and applies the audio settings of a VideoPlayer, with the option\r\n/// to have the audio position track a GameObject.\r\n/// \u003C/summary\u003E\r\npublic class TrackingAudioAccessor : IAudioAccessor, IMediaUpdateListener\r\n{\r\n\t/// \u003Csummary\u003E\r\n\t/// Creates a new TrackingAudioAccessort that does not yet target a VideoPlayer.\r\n\t/// \u003C/summary\u003E\r\n\tpublic TrackingAudioAccessor() \r\n\t{\r\n\t\tIMediaUpdateListener.Register( this );\r\n\t}\r\n\t\r\n\t/// \u003Csummary\u003E\r\n\t/// Creates a new TrackingAudioAccessor targeting the specified VideoPlayer.\r\n\t/// \u003C/summary\u003E\r\n\tpublic TrackingAudioAccessor( VideoPlayer videoPlayer )\n\t{\n\t\tVideoPlayer = videoPlayer;\r\n\t\tIMediaUpdateListener.Register( this );\n\t}\r\n\r\n\t/// \u003Csummary\u003E\r\n\t/// The instance of VideoPlayer that shall have its audio settings changed by this object.\r\n\t/// \u003C/summary\u003E\r\n\tpublic VideoPlayer VideoPlayer \r\n\t{\r\n\t\tget =\u003E _videoPlayer;\r\n\t\tset\r\n\t\t{\r\n\t\t\t_videoPlayer = value;\r\n\t\t\tMediaUpdate();\r\n\t\t}\r\n\t}\r\n\tprivate VideoPlayer _videoPlayer;\r\n\r\n\t/// \u003Csummary\u003E\r\n\t/// The GameObject from which to play the sound. The sound will automatically\r\n\t/// follow the GameObject.\r\n\t/// \u003C/summary\u003E\r\n\tpublic GameObject Target \r\n\t{\r\n\t\tget =\u003E _target;\r\n\t\tset\r\n\t\t{\r\n\t\t\t_target = value;\r\n\t\t\t_listenLocal = !_target.IsValid();\r\n\t\t\tif ( !_listenLocal )\r\n\t\t\t{\r\n\t\t\t\t_position = _target.WorldPosition;\r\n\t\t\t}\r\n\t\t\tMediaUpdate();\r\n\t\t}\r\n\t}\r\n\tprivate GameObject _target;\r\n\r\n\t/// \u003Csummary\u003E\r\n\t/// The position from which to play the sound. Setting this will also\r\n\t/// set \u003Csee cref=\u0022Target\u0022/\u003E to null.\r\n\t/// \u003C/summary\u003E\r\n\tpublic Vector3 Position \r\n\t{\r\n\t\tget =\u003E _position;\r\n\t\tset\r\n\t\t{\r\n\t\t\t_position = value;\r\n\t\t\t_target = null;\r\n\t\t\tMediaUpdate();\r\n\t\t}\r\n\t}\r\n\tprivate Vector3 _position;\r\n\r\n\t/// \u003Cinheritdoc cref=\u0022IAudioAccessor.Volume\u0022/\u003E\r\n\tpublic float Volume \r\n\t{ \r\n\t\tget =\u003E _volume;\r\n\t\tset\r\n\t\t{\r\n\t\t\t_volume = value;\r\n\t\t\tMediaUpdate();\r\n\t\t}\r\n\t}\r\n\tprivate float _volume = 1f;\r\n\r\n\t/// \u003Cinheritdoc cref=\u0022IAudioAccessor.ListenLocal\u0022/\u003E\r\n\tpublic bool ListenLocal \r\n\t{\r\n\t\tget =\u003E _listenLocal;\r\n\t\tset\r\n\t\t{\r\n\t\t\t_listenLocal = value;\r\n\t\t\tif ( _listenLocal )\r\n\t\t\t{\r\n\t\t\t\t_target = null;\r\n\t\t\t}\r\n\t\t\tMediaUpdate();\r\n\t\t}\r\n\t}\r\n\tprivate bool _listenLocal;\r\n\r\n\t/// \u003Cinheritdoc cref=\u0022IAudioAccessor.TargetMixer\u0022/\u003E\r\n\tpublic Mixer TargetMixer\r\n\t{\r\n\t\tget =\u003E _targetMixer;\r\n\t\tset\r\n\t\t{\r\n\t\t\t_targetMixer = value;\r\n\t\t\tMediaUpdate();\r\n\t\t}\r\n\t}\r\n\tprivate Mixer _targetMixer;\r\n\r\n\t/// \u003Cinheritdoc cref=\u0022IAudioAccessor.Muted\u0022/\u003E\r\n\tpublic bool Muted\r\n\t{\r\n\t\tget =\u003E _muted;\r\n\t\tset \r\n\t\t{\r\n\t\t\t_muted = value;\r\n\t\t\tMediaUpdate();\r\n\t\t}\r\n\t}\r\n\tprivate bool _muted;\r\n\r\n\t/// \u003Csummary\u003E\r\n\t/// Updates properties of the underlying audio player to match the values specified in this object.\r\n\t/// This will automatically be called on every frame.\r\n\t/// \u003C/summary\u003E\r\n\tpublic void MediaUpdate()\r\n\t{\r\n\t\tif ( VideoPlayer is null )\r\n\t\t\treturn;\r\n\r\n\t\tif ( Target.IsValid() )\r\n\t\t{\r\n\t\t\t_position = Target.WorldPosition;\r\n\t\t}\r\n\r\n\t\tVideoPlayer.Muted = Muted;\r\n\t\tVideoPlayer.Audio.Position = Position;\r\n\t\tVideoPlayer.Audio.Volume = Volume;\r\n\t\tVideoPlayer.Audio.ListenLocal = ListenLocal;\r\n\t\tVideoPlayer.Audio.TargetMixer = TargetMixer;\r\n\t}\r\n\r\n\t/// \u003Csummary\u003E\r\n\t/// Unregisters this \u003Csee cref=\u0022IMediaUpdateListener\u0022/\u003E from \u003Csee cref=\u0022MediaUpdateSystem\u0022/\u003E.\r\n\t/// \u003C/summary\u003E\r\n\tpublic void Dispose()\r\n\t{\r\n\t\tIMediaUpdateListener.Unregister( this );\r\n\t\tGC.SuppressFinalize( this );\r\n\t}\r\n}\r\n"},{"Ident":"duccsoft.videopanel","Path":"Code/UI/VideoPanel.razor","FileName":"VideoPanel.razor","PackageType":"library","CodeKind":"Game","AssetVersionId":75857,"IsPrivate":false,"Code":"@using Sandbox.UI;\r\n@namespace Duccsoft\r\n@inherits Panel\r\n\r\n\u003Croot class=\u0022video-texture\u0022\u003E\r\n    @if ( ShowControls )\r\n    {\r\n        \u003CVideoControlOverlay VideoPanel=@this AutoHide=@AutoHideControls AutoHideDelay=@AutoHideDelay/\u003E\r\n    }\r\n\u003C/root\u003E\r\n"},{"Ident":"duccsoft.videopanel","Path":".obj/__compiler_extra.cs","FileName":"__compiler_extra.cs","PackageType":"library","CodeKind":"Game","AssetVersionId":75857,"IsPrivate":false,"Code":"global using static Sandbox.Internal.GlobalGameNamespace;\r\n[assembly: global::System.Reflection.AssemblyMetadata( \u0022AddonTitle\u0022, \u0022Video Panel\u0022 )]\r\n[assembly: global::System.Reflection.AssemblyMetadata( \u0022AddonIdent\u0022, \u0022videopanel\u0022 )]\r\n[assembly: global::System.Reflection.AssemblyMetadata( \u0022OrgIdent\u0022, \u0022duccsoft\u0022 )]\r\n[assembly: global::System.Reflection.AssemblyMetadata( \u0022Ident\u0022, \u0022duccsoft.videopanel\u0022 )]\r\n[assembly: global::System.Reflection.AssemblyMetadata( \u0022CompileTime\u0022, \u002211/1/2024 11:25:02 PM\u0022 )]\r\n[assembly: global::System.Reflection.AssemblyMetadata( \u0022EngineVersion\u0022, \u002217\u0022 )]\r\n[assembly: global::System.Reflection.AssemblyMetadata( \u0022EngineMinorVersion\u0022, \u00221\u0022 )]\r\n\r\n[assembly: System.Runtime.Versioning.TargetFramework( \u0022.NETCoreApp,Version=v7.0\u0022, FrameworkDisplayName = \u0022.NET 7.0\u0022 )]\r\n[assembly: global::System.Reflection.AssemblyVersion(\u00220.0.155.0\u0022)]\r\n[assembly: global::System.Reflection.AssemblyFileVersion(\u00220.0.155.0\u0022)]"},{"Ident":"duccsoft.videopanel","Path":"UI/VideoControlOverlay.razor.cs","FileName":"VideoControlOverlay.razor.cs","PackageType":"library","CodeKind":"Game","AssetVersionId":75857,"IsPrivate":false,"Code":"using Sandbox.UI;\r\nusing System;\r\n\r\nnamespace Duccsoft;\r\n\r\n/// \u003Csummary\u003E\r\n/// A Panel meant to stretch over an entire VideoPanel and provide a progress bar and buttons.\r\n/// \u003C/summary\u003E\r\npublic partial class VideoControlOverlay : Panel\r\n{\r\n\t/// \u003Csummary\u003E\r\n\t/// The VideoPanel instance that we will be controlling. You may replace this with any\r\n\t/// \u003Csee cref=\u0022IVideoPanel\u0022/\u003E object that you that you wish to control using this UI.\r\n\t/// \u003C/summary\u003E\r\n\tpublic IVideoPanel VideoPanel { get; set; }\r\n\t/// \u003Csummary\u003E\r\n\t/// If true, the video controls will automatically be hidden after the AutoHideDelay period has elapsed\r\n\t/// and the user is not hovering their mouse over this panel.\r\n\t/// \u003C/summary\u003E\r\n\tpublic bool AutoHide { get; set; } = true;\r\n\t/// \u003Csummary\u003E\r\n\t/// If AutoHide is true, this is the time in seconds that must elapse before this panel\r\n\t/// will conceal the video controls.\r\n\t/// \u003C/summary\u003E\r\n\tpublic float AutoHideDelay { get; set; } = 1f;\r\n\r\n\t#region Presentation\r\n\tprivate string OverlayClass\r\n\t{\r\n\t\tget\r\n\t\t{\r\n\t\t\tvar overlayClass = VideoPanel?.IsLoading == true ? \u0022loading\u0022 : string.Empty;\r\n\r\n\t\t\tif ( !AutoHide )\r\n\t\t\t\treturn overlayClass;\r\n\r\n\t\t\tvar hovered = PseudoClass.HasFlag( PseudoClass.Hover );\r\n\t\t\tif ( hovered )\r\n\t\t\t{\r\n\t\t\t\t_lastHovered = 0f;\r\n\t\t\t\treturn overlayClass;\r\n\t\t\t}\r\n\t\t\treturn _lastHovered \u003E AutoHideDelay ? $\u0022{overlayClass} conceal\u0022 : overlayClass;\r\n\t\t}\r\n\t}\r\n\tprivate string TimecodeAreaClass =\u003E ProgressSeconds \u003E 3600 || DurationSeconds \u003E 3600\r\n\t\t? \u0022big\u0022\r\n\t\t: string.Empty;\r\n\tprivate string ProgressText =\u003E FormatTime( ProgressSeconds );\r\n\tprivate string DurationText =\u003E FormatTime( DurationSeconds );\r\n\tprivate string FormatTime( float seconds )\r\n\t{\r\n\t\tvar time = TimeSpan.FromSeconds( seconds );\r\n\t\treturn time.Hours \u003E 0\r\n\t\t\t? time.ToString( \u0022hh\u0027:\u0027mm\u0027:\u0027ss\u0022 )\r\n\t\t\t: time.ToString( \u0022mm\u0027:\u0027ss\u0022 );\r\n\t}\r\n\tprivate string PlayButtonIcon\r\n\t{\r\n\t\tget\r\n\t\t{\r\n\t\t\tif ( !VideoPanel.IsValid() )\r\n\t\t\t\treturn \u0022play_arrow\u0022;\r\n\r\n\t\t\treturn VideoPanel.IsPaused ? \u0022play_arrow\u0022 : \u0022pause\u0022;\r\n\t\t}\r\n\t}\r\n\r\n\tprivate float ProgressSeconds =\u003E VideoPanel?.PlaybackTime ?? 0f;\r\n\tprivate float DurationSeconds =\u003E VideoPanel?.Duration ?? 0f;\r\n\tprivate string VolumeButtonIcon =\u003E VideoPanel?.Audio?.Muted == false ? \u0022volume_up\u0022 : \u0022volume_off\u0022;\r\n\t#endregion\r\n\r\n\tprivate RealTimeSince _lastHovered = 20f;\r\n\r\n\tprotected override int BuildHash()\r\n\t{\r\n\t\treturn HashCode.Combine( VideoPanel?.IsPlaying, VideoPanel?.IsPaused, VideoPanel?.Audio?.Muted, (int)ProgressSeconds, TimecodeAreaClass, OverlayClass  );\r\n\t}\r\n\r\n\t#region Controls\r\n\tprivate float PlaybackTime\r\n\t{\r\n\t\tget =\u003E ProgressSeconds;\r\n\t\tset =\u003E VideoPanel?.Seek( value );\r\n\t}\r\n\r\n\tprivate void ProgressBarChanged( float value )\r\n\t{\r\n\t\tPlaybackTime = value;\r\n\t}\r\n\r\n\tprivate void TogglePause() =\u003E VideoPanel?.TogglePause();\r\n\tprivate void ToggleMute()\r\n\t{\r\n\t\tif ( !VideoPanel.IsValid() || VideoPanel.Audio is null )\r\n\t\t\treturn;\r\n\r\n\t\tVideoPanel.Audio.Muted = !VideoPanel.Audio.Muted;\r\n\t}\r\n\t#endregion\r\n}\r\n"},{"Ident":"duccsoft.videopanel","Path":"Code/VideoRoot.cs","FileName":"VideoRoot.cs","PackageType":"library","CodeKind":"Game","AssetVersionId":75857,"IsPrivate":false,"Code":"namespace Duccsoft;\r\n\r\n/// \u003Csummary\u003E\r\n/// Specifies the root directory of video path.\r\n/// \u003C/summary\u003E\r\npublic enum VideoRoot\r\n{\r\n\t/// \u003Csummary\u003E\r\n\t/// Video path is relative to FileSystem.Mounted\r\n\t/// \u003C/summary\u003E\r\n\t[Icon(\u0022inventory_2\u0022)]\r\n\tMountedFileSystem,\r\n\t/// \u003Csummary\u003E\r\n\t/// Video path is relative to FileSystem.Data\r\n\t/// \u003C/summary\u003E\r\n\t[Icon(\u0022save\u0022)]\r\n\tDataFileSystem,\r\n\t/// \u003Csummary\u003E\r\n\t/// Video path is relative to FileSystem.OrganizationData\r\n\t/// \u003C/summary\u003E\r\n\t[Icon(\u0022business\u0022)]\r\n\tOrganizationDataFileSystem,\r\n\t/// \u003Csummary\u003E\r\n\t/// Video path is a URL to an video stream on the internet. This should be\r\n\t/// a direct link to the stream itself.\r\n\t/// \u003Cbr/\u003E\u003Cbr/\u003E\r\n\t/// To manually test whether a stream is valid, you can use the Open Network Stream \r\n\t/// feature of VLC Media Player, but not every stream that plays in VLC will work here.\r\n\t/// \u003C/summary\u003E\r\n\t[Icon(\u0022language\u0022)]\r\n\tWebStream\r\n}\r\n\r\npublic static class VideoRootExtensions\r\n{\r\n\t/// \u003Csummary\u003E\r\n\t/// Returns the file system associated with the given VideoRoot, or null if \r\n\t/// no file system exists.\r\n\t/// \u003C/summary\u003E\r\n\tpublic static BaseFileSystem AsFileSystem( this VideoRoot videoRoot )\r\n\t{\r\n\t\treturn videoRoot switch\r\n\t\t{\r\n\t\t\tVideoRoot.MountedFileSystem\t\t\t\t=\u003E FileSystem.Mounted,\r\n\t\t\tVideoRoot.DataFileSystem\t\t\t\t=\u003E FileSystem.Data,\r\n\t\t\tVideoRoot.OrganizationDataFileSystem\t=\u003E FileSystem.OrganizationData,\r\n\t\t\t_ =\u003E null\r\n\t\t};\r\n\t}\r\n}\t\r\n"}]}