Closed JPVenson closed 3 years ago
I cannot reproduce this issue - can you create a repo where I can see what is happening please? It may be related to whatever media source you are using, possibly - as that is the only thing not shown above in your example.
Sure: https://github.com/JPVenson/BlazoredBugNo3 Start the project, open your Browser debugger Console and you will see that the state is null
But i think i already found the problem. When attaching to an event without setting the VideoStateOptions will result in that behavior.
@SQL-MisterMagoo Added Source element
Ah yes, well spotted - you do need to provide VideoStateOptions - the default is to return nothing - because the choice for a default was either nothing, or all - and all seemed a bit messy as a default.
If you are not bothered about what is returned, then leaving it null should be fine - but if you do need something from the state, then you need to define what it is you are interested in.
"nothing" is ok, but not null. I expected the object to be at least created and empty but never null. It was just unexpected.
HI, I am installed this package from nugget manager. I am working on simple blazor wasm application (.NET 5). To get the current times when user clicks on play and pause buttons. I am always getting VideoState as null on my OnPlay and OnPause events. My implementation is pretty simple as you can see below. I don't understand if there is something I am missing or doing wrong?
<BlazoredVideo VideoStateOptions="options" Play="OnPlay" Pause="OnPause"
class="w-100"
style="width:1280px;"
controls="controls" >
<source src="https://res.cloudinary.com/blazoredgitter/video/upload/v1557015491/samples/elephants.mp4" type="video/mp4" />
</BlazoredVideo>
<span>Current` Time: @currentTime</span>
@code{
public Dictionary<VideoEvents, VideoStateOptions> options {get; set; }
private double currentTime;
protected override void OnInitialized()
{
options = new Dictionary<VideoEvents, VideoStateOptions>();
options[VideoEvents.TimeUpdate] = new VideoStateOptions { All=true };
options[VideoEvents.Pause] = new VideoStateOptions { All=true };
options[VideoEvents.Play] = new VideoStateOptions { All=true};
}
private void OnPlay(VideoState state)
{
collapseNavMenu = true;
currentTime = state.CurrentTime;
}
private void OnPause(VideoState state)
{
collapseNavMenu = false;
currentTime = state.CurrentTime;
}
}
@mithunta Try initializing the options inline:
public Dictionary<VideoEvents, VideoStateOptions> options {get; set; } = new Dictionary<VideoEvents, VideoStateOptions>();
Or use a componentBase class and put the initialization in your constructor.
@JPVenson . Thank you for the suggestion. I tried both of your options. I still get VideoState as null during Play and Pause action i am doing. I have committed the code to Git repo - https://github.com/mithunta/blazoredvideo_net5
@mithunta You have a typo in your code:
Its:
VideoEventOptions
not VideoStateOptions
@JPVenson Darn it. Thank you!
@SQL-MisterMagoo - I think there is an error in the example code in Readme.md. This is where I took the implementation.
@JPVenson Darn it. Thank you!
@SQL-MisterMagoo - I think there is an error in the example code in Readme.md. This is where I took the implementation.
Exactly, I have done the same, and just to be sure copy-pasted the exact code from the readme... :D This explains why VS didn't like that parameter
Describe the bug When attaching to the PlayCallback on an BlazoredVideo element, the VideoState is null
To Reproduce
Is always null when i start of stop the video.
Expected behavior A clear and concise description of what you expected to happen.
Screenshots If applicable, add screenshots to help explain your problem.
Hosting Model (is this issue happening with a certain hosting model?):
Additional context Add any other context about the problem here.