示例#1
0
        /// <summary>
        ///  Initializes the <see cref="InteropWindow"/>.
        /// </summary>
        protected override async Task OnAfterRenderAsync(bool firstRender)
        {
            await base.OnAfterRenderAsync(firstRender);

            //This can be called more then once
            if (!firstRender)
            {
                return;
            }

            //Load the sound interop in JavaScript
            _interopSounds = new InteropSounds(JsRuntime);

            if (!await _interopSounds.Initialize(_controller.ActionSounds))
            {
                Console.WriteLine($"ERROR '{nameof(InteropSounds)}': Could not initialize sounds in JavaScript.");
            }

            //Load the window interop in JavaScript
            _interopWindow = new InteropWindow(JsRuntime);
            await _interopWindow.Initialize();

            //Force a refresh
            await InvokeAsync(StateHasChanged);
        }
示例#2
0
        /// <summary>
        /// Loads the sound streams in JavaScript.
        /// </summary>
        protected override async Task OnInitializedAsync()
        {
            await base.OnInitializedAsync();

            //Load the sounds in JavaScript
            _interopSounds = new InteropSounds(JsRuntime);

            if (!await _interopSounds.Initialize(_controller.ActionSounds))
            {
                Console.WriteLine($"ERROR '{nameof(InteropSounds)}': Could not initialize sounds in JavaScript.");
            }
        }
        /// <summary>
        /// Loads the sound streams in JavaScript.
        /// </summary>
        /// <remarks>
        ///  Base <see cref="BlazorComponent.OnInitAsync"/> returns null so do not call.
        /// </remarks>
        protected override async Task OnInitAsync()
        {
            //First load the stream to storage
            await LoadSoundStreams();

            //Load the sounds in JavaScript
            _interopSounds = new InteropSounds(JSRuntime);
            var sounds = Enum
                         .GetNames(typeof(ActionSound))
                         .Select(s => s.ToLowerInvariant());

            await _interopSounds.LoadSounds(sounds);
        }