Skip to content

Commit

Permalink
Merge pull request #20 from Blazored/feature-methods-props
Browse files Browse the repository at this point in the history
2023-01-02
- Bump dotnet version to 6.0 as 3.x and 5.x are now out of support.
- Add standard Methods and Properties (big thanks to https://github.com/JPVenson) and Async versions (for Server/WASM). (Issues #17 #9)
- Include video element id ("Id") and component object ref ("Video") in VideoState and VideoEventData (Issue #19) for identifying which component triggered an event.
  • Loading branch information
SQL-MisterMagoo committed Jan 2, 2023
2 parents e633489 + b2a5ce6 commit 4975de9
Show file tree
Hide file tree
Showing 52 changed files with 1,787 additions and 1,213 deletions.
85 changes: 29 additions & 56 deletions .github/workflows/ci-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ on:
types: [ published ]

env:
NETCORE_VERSION: '3.1.301'
NETCORE_VERSION: '6.0.x'
OUTPUT_DIR: 'net6.0'
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: true
DOTNET_CLI_TELEMETRY_OPTOUT: true
PROJECT_NAME: Video
GITHUB_FEED: https://nuget.pkg.github.com/Blazored/
GITHUB_USER: chrissainty
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NUGET_FEED: https://api.nuget.org/v3/index.json
NUGET_KEY: ${{ secrets.NUGET_KEY }}
Expand All @@ -35,76 +34,50 @@ jobs:
- name: Restore
run: dotnet restore

- name: Build
- name: Build Video
run: dotnet build -c Release --no-restore src/Blazored.$PROJECT_NAME/Blazored.$PROJECT_NAME.csproj

- name: Test
run: dotnet test -c Release
- name: Test Video
run: dotnet test -c Release --no-restore --verbosity normal tests/Blazored.$PROJECT_NAME.Tests

- name: Pack
run: dotnet pack -v normal -c Release --no-restore --include-symbols --include-source -p:PackageVersion=$GITHUB_RUN_ID src/Blazored.$PROJECT_NAME/Blazored.$PROJECT_NAME.*proj

- name: Publish Sample Site
run: dotnet publish -c Release samples/BlazorWebAssembly/BlazorWebAssembly.csproj

- name: Rewrite base href
uses: SteveSandersonMS/ghaction-rewrite-base-href@v1
with:
html_path: samples/BlazorWebAssembly/bin/Release/netstandard2.1/publish/wwwroot/index.html
base_href: /${{ env.PROJECT_NAME }}/

- name: Deploy to Github Pages
uses: JamesIves/github-pages-deploy-action@releases/v3
with:
ACCESS_TOKEN: $GITHUB_TOKEN
BASE_BRANCH: main # The branch the action should deploy from.
BRANCH: gh-pages # The branch the action should deploy to.
FOLDER: samples/BlazorWebAssembly/bin/Release/netstandard2.1/publish/wwwroot # The folder the action should deploy.
SINGLE_COMMIT: true

- name: Upload Artifact
uses: actions/upload-artifact@v2
with:
name: nupkg
path: ./src/Blazored.${{ env.PROJECT_NAME }}/bin/Release/*.nupkg
prerelease:
needs: build
if: github.event_name != 'release'
runs-on: ubuntu-latest
steps:
- name: Download Artifact
uses: actions/download-artifact@v1
with:
name: nupkg
- name: Push to GitHub Feed
run: |
for f in ./nupkg/*.nupkg
do
curl -vX PUT -u "$GITHUB_USER:$GITHUB_TOKEN" -F package=@$f $GITHUB_FEED
done
deploy:
needs: build
if: github.event_name == 'release'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Setup .NET Core
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.NETCORE_VERSION }}

- name: Create Release NuGet package
run: |
arrTag=(${GITHUB_REF//\// })
VERSION="${arrTag[2]}"
echo Version: $VERSION
VERSION="${VERSION//v}"
VERSION="${VERSION:1}"
echo Clean Version: $VERSION
dotnet pack -v normal -c Release --include-symbols --include-source -p:PackageVersion=$VERSION -o nupkg src/Blazored.$PROJECT_NAME/Blazored.$PROJECT_NAME.*proj
- name: Push to GitHub Feed
run: |
for f in ./nupkg/*.nupkg
do
curl -vX PUT -u "$GITHUB_USER:$GITHUB_TOKEN" -F package=@$f $GITHUB_FEED
done
dotnet pack -v normal -c Release --include-symbols --include-source -p:PackageVersion=$VERSION -o nupkg src/Blazored.$PROJECT_NAME/Blazored.$PROJECT_NAME.csproj
- name: Push to NuGet Feed
run: dotnet nuget push ./nupkg/*.nupkg --source $NUGET_FEED --skip-duplicate --api-key $NUGET_KEY
run: dotnet nuget push ./nupkg/*.nupkg --source $NUGET_FEED --api-key $NUGET_KEY --skip-duplicate

- name: Publish Sample Site
run: dotnet publish -c Release samples/BlazorWebAssembly/BlazorWebAssembly.csproj

- name: Rewrite base href
uses: SteveSandersonMS/ghaction-rewrite-base-href@v1
with:
html_path: samples/BlazorWebAssembly/bin/Release/$OUTPUT_DIR/publish/wwwroot/index.html
base_href: /${{ env.PROJECT_NAME }}/

- name: Deploy to Github Pages
uses: JamesIves/github-pages-deploy-action@releases/v3
with:
ACCESS_TOKEN: $GITHUB_TOKEN
BASE_BRANCH: main # The branch the action should deploy from.
BRANCH: gh-pages # The branch the action should deploy to.
FOLDER: samples/BlazorWebAssembly/bin/Release/$OUTPUT_DIR/publish/wwwroot # The folder the action should deploy.
SINGLE_COMMIT: true
8 changes: 4 additions & 4 deletions .github/workflows/ci-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:

env:
PROJECT_NAME: Blazored.Video
NETCORE_VERSION: '3.1.301'
NETCORE_VERSION: '6.0.x'

jobs:
build:
Expand All @@ -15,7 +15,7 @@ jobs:
steps:
- uses: actions/checkout@v2

- name: Setting up .NET Core SDK ${{ env.NETCORE_VERSION }}...
- name: Setting up .NET SDK ${{ env.NETCORE_VERSION }}...
uses: actions/setup-dotnet@v1
with:
dotnet-version: ${{ env.NETCORE_VERSION }}
Expand All @@ -26,5 +26,5 @@ jobs:
- name: Building project...
run: dotnet build --configuration Release --no-restore src/$PROJECT_NAME/$PROJECT_NAME.csproj

- name: Testing...
run: dotnet test --no-restore --verbosity normal
- name: Test Video
run: dotnet test -c Release --no-restore --verbosity normal tests/$PROJECT_NAME.Tests
14 changes: 10 additions & 4 deletions Blazored.Video.sln
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30223.230
# Visual Studio Version 17
VisualStudioVersion = 17.5.33209.295
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{2658C500-CD32-4A3B-89D8-CA59C18DC891}"
ProjectSection(SolutionItems) = preProject
docs\BlazorVideo.webm = docs\BlazorVideo.webm
global.json = global.json
README.md = README.md
screenshot.png = screenshot.png
Expand All @@ -21,7 +20,9 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Blazored.Video", "src\Blazo
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorServer", "samples\BlazorServer\BlazorServer.csproj", "{ADF25F83-3102-4E94-9635-77752622C0E5}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BlazorWebAssembly", "samples\BlazorWebAssembly\BlazorWebAssembly.csproj", "{237424CD-14E6-4184-8374-074416E6ADAD}"
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "BlazorWebAssembly", "samples\BlazorWebAssembly\BlazorWebAssembly.csproj", "{237424CD-14E6-4184-8374-074416E6ADAD}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "SharedRCL", "samples\SharedRCL\SharedRCL.csproj", "{0B23AC32-39E7-4008-8043-345DBE2D0252}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Expand All @@ -45,6 +46,10 @@ Global
{237424CD-14E6-4184-8374-074416E6ADAD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{237424CD-14E6-4184-8374-074416E6ADAD}.Release|Any CPU.ActiveCfg = Release|Any CPU
{237424CD-14E6-4184-8374-074416E6ADAD}.Release|Any CPU.Build.0 = Release|Any CPU
{0B23AC32-39E7-4008-8043-345DBE2D0252}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{0B23AC32-39E7-4008-8043-345DBE2D0252}.Debug|Any CPU.Build.0 = Debug|Any CPU
{0B23AC32-39E7-4008-8043-345DBE2D0252}.Release|Any CPU.ActiveCfg = Release|Any CPU
{0B23AC32-39E7-4008-8043-345DBE2D0252}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand All @@ -53,6 +58,7 @@ Global
{29D8FFA6-2366-4599-97BA-1F7CF01674F0} = {FB98CF00-92F4-4B10-A4AB-3FDF93D7573B}
{ADF25F83-3102-4E94-9635-77752622C0E5} = {577BC42A-6B87-4B9B-AB8B-F2273094C31E}
{237424CD-14E6-4184-8374-074416E6ADAD} = {577BC42A-6B87-4B9B-AB8B-F2273094C31E}
{0B23AC32-39E7-4008-8043-345DBE2D0252} = {577BC42A-6B87-4B9B-AB8B-F2273094C31E}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E2DEE6E5-3CB4-4A7D-9FD9-8E5DB96BE454}
Expand Down
47 changes: 41 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ The easiest html5 `video` implementation for [Blazor](https://blazor.net) applic

![Screenshot of the component in action](screenshot.png)

## Changelog
### 2022-24-12 Version 1.1
- Bump dotnet version to 6.0 as 3.x and 5.x are now out of support.
- Add standard Methods and Properties (big thanks to https://github.com/JPVenson) and Async versions (for Server/WASM). (Issues #17 #9)
- Include video element id ("Id") and component object ref ("Video") in VideoState and VideoEventData (Issue #19) for identifying which component triggered an event.

## Getting Setup

You can install the package via the nuget package manager - just search for *Blazored.Video*. You can also install via powershell using the following command.
Expand All @@ -23,6 +29,7 @@ dotnet add package Blazored.Video
```

#### Internet Explorer 11

This package can be used with Internet Explorer 11, but some special care should to be taken.

- Only Blazor Server works with IE11. Blazor WebAssembly does not work with any IE version. See [this](https://docs.microsoft.com/en-us/aspnet/core/blazor/supported-platforms?view=aspnetcore-3.1)
Expand All @@ -31,6 +38,9 @@ This package can be used with Internet Explorer 11, but some special care should
Taking these things into account, `Blazored.Video` will work on IE11.

_Note: The [sample projects](https://github.com/Blazored/Video/tree/main/samples) in this repo have IE11 support baked in._

_Note: This package is no longer tested on IE 11 - as IE support has been dropped - it may work - it's up to you to test it._

### Add Imports

Add the following to your *_Imports.razor*
Expand All @@ -52,14 +62,14 @@ Just use BlazoredVideo in place of any `video` tags.
class="w-100"
style="max-width:800px;"
controls="controls">
<source src="https://res.cloudinary.com/blazoredgitter/video/upload/v1557015491/samples/elephants.mp4" type="video/mp4" />
<source src="videos/elephants.mp4" type="video/mp4" />
</BlazoredVideo>
```

This will render the html
This will render the html (id is auto-generated by default but you can supply your own)
``` html
<video class="w-100" id="361044add13e438cb3de299cd74272a6" style="max-width: 800px;" controls="controls" _bl_796fa517-712e-4cf5-b8d6-7a4d940f2947=""><!--!-->
<source src="https://res.cloudinary.com/blazoredgitter/video/upload/v1557015491/samples/elephants.mp4" type="video/mp4">
<video class="w-100" id="361044add13e438cb3de299cd74272a6" controls="controls" _bl_796fa517-712e-4cf5-b8d6-7a4d940f2947=""><!--!-->
<source src="videos/elephants.mp4" type="video/mp4">
</video>
```
### Media Events
Expand Down Expand Up @@ -176,15 +186,15 @@ Now, we can pass that to the `BlazoredVideo` component.
class="w-100"
style="max-width:800px;"
controls="controls">
<source src="https://res.cloudinary.com/blazoredgitter/video/upload/v1557015491/samples/elephants.mp4" type="video/mp4" />
<source src="videos/elephants.mp4" type="video/mp4" />
</BlazoredVideo>
```
_Notice: I have use an EventCallback for the `play` event and an action for the `timeupdate` event - because in this case I don't want a re-render every time the `timeupdate` fires_

This will render the html
``` html
<video class="w-100" id="361044add13e438cb3de299cd74272a6" style="max-width: 800px;" controls="controls" _bl_796fa517-712e-4cf5-b8d6-7a4d940f2947=""><!--!-->
<source src="https://res.cloudinary.com/blazoredgitter/video/upload/v1557015491/samples/elephants.mp4" type="video/mp4">
<source src="videos/elephants.mp4" type="video/mp4">
</video>
```

Expand All @@ -208,6 +218,31 @@ void OnTimeUpdate(VideoState state)
}
```

## Calling Standard Methods
** Added 2022-12-24 **

The component now supports four standard methods

| Method | Description | Notes |
| --- | --- | --- |
| StartPlayback | Start playback from C# code | `await videoRef.StartPlayback()`
| PausePlayback | Pause playback from C# code | `await videoRef.PausePlayback()`
| ReloadControl | Reload media from C# code | `await videoRef.ReloadControl()`
| CanPlayMediaType | Check media type from C# code | `bool isSupported = await videoRef.CanPlayMediaType("video/webm")`

## Get/Set Standard Properties
** Added 2022-12-24 **

The component now supports most standard properties directly from C# code.

Example - WASM only
`int duration = videoRef.Duration`

_Note: Attempting to read/write Properties from Blazor Server will throw a runtime exception telling you to use the Async versions instead. I would advise always using the async Get/Set methods as they are able to use Asynchronous or Synchronous (under WebAssembly) calls at runtime automatically, while the Properties are Synchronous only._

Example - Remote JS (Server) and WASM
`int duration = await videoRef.GetDurationAsync()`

### Customising the html

The Video can be customised using standard CSS techniques.
Expand Down
5 changes: 5 additions & 0 deletions global.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"sdk": {
"version": "6.0.404"
}
}
4 changes: 2 additions & 2 deletions samples/BlazorServer/BlazorServer.csproj
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
</PropertyGroup>

<ItemGroup>
<ProjectReference Include="..\..\src\Blazored.Video\Blazored.Video.csproj" />
<ProjectReference Include="..\SharedRCL\SharedRCL.csproj" />
</ItemGroup>

</Project>
Loading

0 comments on commit 4975de9

Please sign in to comment.