microsoft/dotnet-podcasts

Podcasts don't play the first time you press the play button in the Blazor web app

danroth27 opened this issue · 2 comments

The first time I try to play a podcast using the Blazor web app I get the following exception in the browser dev console:

       Unhandled Exception:
       Microsoft.JSInterop.JSException: The play() request was interrupted by a new load request.
       undefined
          at Microsoft.JSInterop.JSRuntime.<InvokeAsync>d__16`1[[Microsoft.JSInterop.Infrastructure.IJSVoidResult, Microsoft.JSInterop, Version=6.0.0.0, Culture=neutral, PublicKeyToken=adb9793829ddae60]].MoveNext()
          at Microsoft.JSInterop.JSObjectReferenceExtensions.InvokeVoidAsync(IJSObjectReference jsObjectReference, String identifier, Object[] args)
          at Podcast.Components.AudioInterop.PlayAsync(ElementReference element) in C:\Users\daroth\Documents\GitHub\microsoft\dotnet-podcasts\src\Web\Components\AudioInterop.cs:line 19
          at Podcast.Pages.Shared.Player.Audio.OnPlayingChanged(Boolean play) in C:\Users\daroth\Documents\GitHub\microsoft\dotnet-podcasts\src\Web\Pages\Shared\Player\Audio.razor:line 97
          at System.Threading.Tasks.Task.<>c.<ThrowAsync>b__128_1(Object state)
          at System.Threading.QueueUserWorkItemCallbackDefaultContext.Execute()
          at System.Threading.ThreadPoolWorkQueue.Dispatch()
          at System.Threading.ThreadPool.Callback()
       ThreadPool Callback threw an unhandled exception of type Microsoft.JSInterop.JSException

If I stop play and try to play again the podcast plays fine.

In general, to play a podcast I'm finding I have to click the play button once, pause it, and then play it again to hear sound.

Seems to be caused by c3f31b9. If I revert that commit the audio plays without error the first time you press play.

Same