Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Kellso hp main updated from latest main #21

Merged
merged 36 commits into from
Jan 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
52ae9d1
fix error handling
KellsoHP Apr 10, 2022
308ffb2
update test
KellsoHP Apr 10, 2022
0167f18
fix tabs to spaces
KellsoHP Apr 10, 2022
e73b21c
version up
KellsoHP Apr 10, 2022
b07a3bf
Fix .NET version
SQL-MisterMagoo Dec 23, 2020
51fd471
Added Common Methods and Properties
Nov 30, 2020
b16c147
Added Check in js methods for disposed element
Dec 3, 2020
c2c6a05
Changed method accessability for better extentability
Dec 3, 2020
1b80bec
Added Missing Poster property
Dec 3, 2020
2bb3ff5
Added Method documentation
Dec 12, 2020
6271419
Removed non-dynamic setters
Dec 12, 2020
7952ed0
Fixed seekable not been readonly
Dec 12, 2020
3de9e2b
Moved blazoredVideo to be complient with standard razor component beh…
Dec 12, 2020
9dd0cfa
Changed Blazored js object name reference in method calls
Dec 12, 2020
8e143d3
Changed Blazored js object call in properties
Dec 12, 2020
3b1d746
Added TextTracks converter
Dec 12, 2020
7b711bb
Fix tests
SQL-MisterMagoo Dec 23, 2020
e3bc747
Restore original functionality wrt JavaScript, but allow for external…
SQL-MisterMagoo Dec 23, 2020
a76b5d2
Added method samples
SQL-MisterMagoo Feb 21, 2021
eb75be7
Share common razor code
SQL-MisterMagoo Dec 23, 2022
11e3030
Fix async mistake
SQL-MisterMagoo Dec 23, 2022
ee4c8ae
Properties are only for WASM, so throw if used from Server.
SQL-MisterMagoo Dec 24, 2022
7c75568
Update samples with new sample video and method calls
SQL-MisterMagoo Dec 24, 2022
345fd26
Switched to using JS module import.
SQL-MisterMagoo Dec 27, 2022
e75826a
Updated samples
SQL-MisterMagoo Dec 27, 2022
11b0256
Disposable stuff
SQL-MisterMagoo Dec 27, 2022
a254403
Update Samples
SQL-MisterMagoo Dec 27, 2022
d87382e
Add video id to the VideoState and VideoEventData
SQL-MisterMagoo Dec 28, 2022
5fd013e
Fix bug in JS by returning Promise.resolve() instead of null
SQL-MisterMagoo Dec 29, 2022
0461b84
Update samples
SQL-MisterMagoo Dec 29, 2022
136571e
Remove unwanted csproj props
SQL-MisterMagoo Jan 2, 2023
5d0ff43
Update GitHub Actions
SQL-MisterMagoo Jan 2, 2023
59e998b
2022-24-12 Version 2
SQL-MisterMagoo Jan 2, 2023
b5009c9
Fix action
SQL-MisterMagoo Jan 2, 2023
c5b552a
Accept changes from @KellsoHP that couldn't be auto merged because of…
SQL-MisterMagoo Jan 3, 2023
9c2fdee
Merge branch 'main' into KellsoHP-main
SQL-MisterMagoo Jan 3, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# To learn more about .editorconfig see https://aka.ms/editorconfigdocs
###############################
# Core EditorConfig Options #
###############################
root = true

# Code files
[*.{cs,csx,vb,vbx}]
indent_style = tab
17 changes: 17 additions & 0 deletions src/Blazored.Video/Support/MediaErrorState.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
namespace Blazored.Video.Support
{
/// <summary>
/// Presents media error object.
/// </summary>
public class MediaErrorState
{
public MediaErrorType Code { get; set; }

public string Message { get; set; }

public override string ToString()
{
return this.Code.ToString();
}
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
namespace Blazored.Video.Support
{
public enum MediaError
public enum MediaErrorType
{
MEDIA_ERR_ABORTED = 1, // fetching process aborted by user
MEDIA_ERR_NETWORK = 2, // error occurred when downloading
MEDIA_ERR_DECODE = 3, // error occurred when decoding
MEDIA_ERR_SRC_NOT_SUPPORTED = 4, // audio/video not supported
}
}
}
8 changes: 4 additions & 4 deletions src/Blazored.Video/Support/VideoState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class VideoState
/// <summary>
/// Returns a List&lt;<see cref="AudioTrack"/>&gt; object representing available audio tracks
/// </summary>
[Obsolete("This is not exactly obsolete, but not yet implemented, sorry",false)]
[Obsolete("This is not exactly obsolete, but not yet implemented, sorry", false)]
public List<AudioTrack> AudioTracks { get; set; }
/// <summary>
/// Returns whether the audio/video should start playing as soon as it is loaded
Expand Down Expand Up @@ -56,9 +56,9 @@ public class VideoState
/// </summary>
public bool Ended { get; set; }
/// <summary>
/// Returns a <see cref="MediaError"/> object representing the error state of the audio/video
/// Returns a <see cref="MediaErrorState"/> object representing the error state of the audio/video
/// </summary>
public MediaError Error { get; set; }
public MediaErrorState Error { get; set; }
/// <summary>
/// Returns whether the audio/video should start over again when finished
/// </summary>
Expand Down Expand Up @@ -134,4 +134,4 @@ public class VideoState
/// </summary>
public BlazoredVideo Video { get; set; }
}
}
}
31 changes: 22 additions & 9 deletions src/Blazored.Video/wwwroot/blazoredVideo.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,22 +85,35 @@ export function registerCustomEventHandler(el, eventName, payload) {

// Craft a bespoke json string to serve as a payload for the event
function getJSON(el, eventName, payload) {
let data = { id: el.id };
if (payload && payload.length > 0) {
// this syntax copies just the properties we request from the source element
// IE 11 compatible
let data = {};
for (var obj in payload) {
var item = payload[obj];
if (el[item]) {
data[item] = el[item];
var itemValue = el[item];
if (itemValue) {
if (typeof itemValue === 'object') {
data[item] = {}
for (var inhProp in itemValue) {
data[item][inhProp] = itemValue[inhProp]
}
}
else {
data[item] = itemValue
}
}
}
}

// this stringify overload eliminates undefined/null/empty values
return JSON.stringify(
{ id: el.id, name: eventName, state: data },
function (k, v) { return (v === undefined || v == null || v.length === 0) ? undefined : v }
);
// this stringify overload eliminates undefined/null/empty values
return JSON.stringify(
{ name: eventName, state: data }
, function (k, v) { return (v === undefined || v == null || v.length === 0) ? undefined : v }
)
} else {
return JSON.stringify(
{ name: eventName }
)
}
}
}
6 changes: 4 additions & 2 deletions tests/Blazored.Video.Tests/VideoDataInflateDeflateTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public void CanBeInflatedFromEmptyData()
public void CanBeInflatedFromAllData()
{

var data = @"{""id"":""video1"",""name"":""Pause"",""state"":{""id"":""video1"",""Autoplay"":false,""Controls"":true,
var data = @"{""id"":""video1"",""name"":""Pause"",""state"":{""id"":""video1"",""Autoplay"":false,""Controls"":true,""error"":{""code"":2,""message"":""some message""},
""CurrentSrc"":""https://res.cloudinary.com/blazoredgitter/video/upload/v1557015491/samples/elephants.mp4"",
""CurrentTime"":5.25375,""DefaultMuted"":false,""DefaultPlaybackRate"":1,""Duration"":48.516,""Ended"":false,
""Loop"":false,""Muted"":false,""NetworkState"":1,""Paused"":true,""PlaybackRate"":1,
Expand Down Expand Up @@ -64,7 +64,9 @@ public void CanBeInflatedFromAllData()
Assert.Null(result.State.Seekable);
Assert.False(result.State.Seeking);
Assert.Equal(1, result.State.Volume);

Assert.NotNull(result.State.Error);
Assert.Equal(MediaErrorType.MEDIA_ERR_NETWORK, result.State.Error.Code);
Assert.Equal("some message", result.State.Error.Message);
}

}
Expand Down