-
-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Added VideoQueue Control * Added VideoQueue Example * Added Additional Attributes bag support * Added conditional render for additional attributes * Fixed NREX with Additional Attributes * Added Play method for direct playback of a single VideoSource * Added warning ignores * Added additional check that no prior event is overwritten * Updated comment for delay clarification * Added additional event types * Added Extensive exception information * Updated Example property access * Updated Example * Updated Readme --------- Co-authored-by: JPVenson <[email protected]>
- Loading branch information
Showing
11 changed files
with
633 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
@page "/queue" | ||
|
||
<h1>Blazored Video Demo - Queue</h1> | ||
|
||
<div class="d-flex flex-row"> | ||
<BlazoredVideo class="w-40" | ||
autoplay="autoplay" | ||
style="max-width: 300px;"> | ||
<VideoQueue @ref="videoQueue" | ||
OnNextPlayedEvent="StateHasChanged" | ||
OnPlaylistEndedEvent="StateHasChanged" | ||
Delay="Delay" | ||
Repeat="Repeat"> | ||
<VideoItem Source="video/elephants2.mp4#t=3" Type="video/mp4"/> | ||
<VideoItem> | ||
<VideoSource Source="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4" Type="video/mp4" /> | ||
</VideoItem> | ||
<VideoItem Source="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/ElephantsDream.mp4" Type="video/mp4" /> | ||
<VideoItem Source="http://commondatastorage.googleapis.com/gtv-videos-bucket/sample/VolkswagenGTIReview.mp4" Type="video/mp4" /> | ||
</VideoQueue> | ||
</BlazoredVideo> | ||
|
||
|
||
@if (videoQueue != null) | ||
{ | ||
<div class="list-group"> | ||
@foreach (var videos in videoQueue.VideoItems) | ||
{ | ||
<div class="list-group-item selectable @((videos == videoQueue.CurrentItem ? "list-group-item-info" : ""))" | ||
@onclick="() => videoQueue.Play(videos)"> | ||
<span>@(videos.VideoSourceData.First().Source.Split('/').Last())</span> | ||
</div> | ||
} | ||
</div> | ||
} | ||
|
||
</div> | ||
|
||
|
||
<div class="d-flex flex-row"> | ||
<button @onclick="() => videoQueue.PlayNext()">Next</button> | ||
<button @onclick="() => videoQueue.PlayPrevious()">Previous</button> | ||
</div> | ||
|
||
<br/> | ||
<EditForm Model="this"> | ||
<div class="form-group"> | ||
<label for="repeat">Repeat: </label> | ||
|
||
<InputSelect @bind-Value="Repeat" id="repeat"> | ||
@foreach (var repeatVal in Enum.GetValues(typeof(RepeatValues))) | ||
{ | ||
<option value="@repeatVal">@repeatVal</option> | ||
} | ||
</InputSelect> | ||
</div> | ||
<div class="form-group"> | ||
<label for="repeat">Delay: </label> | ||
<InputNumber @bind-Value="Delay" id="delay"/> | ||
</div> | ||
</EditForm> | ||
|
||
@code | ||
{ | ||
VideoQueue videoQueue; | ||
|
||
public RepeatValues Repeat { get; set; } | ||
public int Delay { get; set; } | ||
|
||
protected override void OnAfterRender(bool firstRender) | ||
{ | ||
if (firstRender) | ||
{ | ||
SetupDisplay(); | ||
} | ||
} | ||
|
||
private void SetupDisplay() | ||
{ | ||
StateHasChanged(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
namespace Blazored.Video; | ||
|
||
/// <summary> | ||
/// Defines methods for a <see cref="VideoQueue"/> to behave when a video source was played to its end. | ||
/// </summary> | ||
public enum RepeatValues | ||
{ | ||
/// <summary> | ||
/// Defines no repetition after the queue reached its end. | ||
/// </summary> | ||
NoLoop, | ||
|
||
/// <summary> | ||
/// Will repeat the current loaded video forever. | ||
/// </summary> | ||
LoopOne, | ||
|
||
/// <summary> | ||
/// Loops back to the first video after the last one ended. | ||
/// </summary> | ||
LoopAll | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
using System; | ||
using System.Threading.Tasks; | ||
using Microsoft.AspNetCore.Components; | ||
using Microsoft.AspNetCore.Components.Rendering; | ||
|
||
namespace Blazored.Video; | ||
|
||
/// <summary> | ||
/// Defines a Source from which the <see cref="VideoQueue"/> will schedule playback. | ||
/// </summary> | ||
public sealed class VideoItem : ComponentBase, IDisposable | ||
{ | ||
public VideoItem() | ||
{ | ||
VideoItemData = new VideoItemData(); | ||
} | ||
|
||
/// <summary> | ||
/// The source URI from which to playback. | ||
/// </summary> | ||
[Parameter] | ||
public string Source { get; set; } | ||
|
||
/// <summary> | ||
/// The mime type of the <see cref="Source"/> URI. Optional. | ||
/// </summary> | ||
[Parameter] | ||
public string Type { get; set; } | ||
|
||
[CascadingParameter()] | ||
public VideoQueue VideoQueue { get; set; } | ||
|
||
[Parameter] | ||
public RenderFragment ChildContent { get; set; } | ||
|
||
public VideoItemData VideoItemData { get; set; } | ||
|
||
protected override void BuildRenderTree(RenderTreeBuilder builder) | ||
{ | ||
if (ChildContent == null) | ||
{ | ||
return; | ||
} | ||
|
||
builder.OpenComponent<CascadingValue<VideoItem>>(0); | ||
builder.AddAttribute(1, nameof(CascadingValue<VideoItem>.Value), this); | ||
builder.AddAttribute(2, nameof(CascadingValue<VideoItem>.IsFixed), true); | ||
builder.AddAttribute(3, nameof(CascadingValue<VideoItem>.ChildContent), (RenderFragment)((cBuilder) => | ||
{ | ||
cBuilder.AddContent(4, ChildContent); | ||
})); | ||
builder.CloseComponent(); | ||
} | ||
|
||
protected override void OnInitialized() | ||
{ | ||
if (!string.IsNullOrWhiteSpace(Source)) | ||
{ | ||
VideoItemData.VideoSourceData.Add(new VideoSourceData(Source, Type)); | ||
} | ||
|
||
VideoQueue.AddVideoItem(VideoItemData); | ||
} | ||
|
||
public void Dispose() | ||
{ | ||
VideoQueue.VideoItems.Remove(VideoItemData); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
|
||
namespace Blazored.Video; | ||
|
||
/// <summary> | ||
/// Contains the list of sources to be played back by a <see cref="VideoQueue"/>. | ||
/// </summary> | ||
public class VideoItemData | ||
{ | ||
public VideoItemData() | ||
{ | ||
VideoSourceData = new List<VideoSourceData>(); | ||
Id = Guid.NewGuid().ToString("N"); | ||
} | ||
|
||
internal string Id { get; } | ||
|
||
/// <summary> | ||
/// The <see cref="VideoSourceData"/> that can be used to playback a source. | ||
/// </summary> | ||
public IList<VideoSourceData> VideoSourceData { get; set; } | ||
} |
Oops, something went wrong.