MK.IO
2.1.3
dotnet add package MK.IO --version 2.1.3
NuGet\Install-Package MK.IO -Version 2.1.3
<PackageReference Include="MK.IO" Version="2.1.3" />
<PackageVersion Include="MK.IO" Version="2.1.3" />
<PackageReference Include="MK.IO" />
paket add MK.IO --version 2.1.3
#r "nuget: MK.IO, 2.1.3"
#:package MK.IO@2.1.3
#addin nuget:?package=MK.IO&version=2.1.3
#tool nuget:?package=MK.IO&version=2.1.3
A .NET client SDK for MediaKind MK.IO
This project is an open source .NET SDK for MediaKind MK.IO. For maximum compatibility, it targets .NET 8.0, .NET Standard 2.0 and .NET Framework 4.6.2.
Usage (C#, .NET)
MK.IO Personal API Token
You need to use the new MK.IO Personal Access Tokens to connect to the API. This is a Json Web Token (JWT) also called Personal API Token. You can create them in the MK.IO portal and revoke them if needed.
To create one :
- Open a web browser and log into https://app.mk.io (sign in with Microsoft SSO).
- Once you are logged in, click on your email in the drop-down menu in the top right corner. More details here.
For more information, please read this article.
This SDK also brings token management features for the MK.IO API. You can use the SDK to create, list, revoke, and get details of your personal API tokens, using client.Management.YourProfile.
Supported operations
In the current version, operations are supported for :
- Assets
- Streaming endpoints
- Streaming locators
- Storage accounts
- Content key policies
- Transforms, including with CVQ presets, converter presets and Thumbnail generation
- Jobs
- Live events
- Live outputs
- Asset filters
- Account filters
- Streaming policies
- Account (some methods were moved to Management/YourProfile)
- Management/YourProfile
End-to-end sample code
Video encoding and publishing
There is a documented end-to-end sample code available in the SampleNet8.0 project, in file SimpleEncodingAndPublishing.cs.
This sample code does the following :
- upload a mp4 file to a new asset using authentication in the browser (you need contribution role on the storage)
- create the output asset
- create/update an encoding transform
- submit an encoding job
- create a streaming locator for the encoded asset
- create and start a streaming endpoint if there is none
- list the streaming urls and test player urls.
- clean the created resources if the user accepts
Run the SampleNet8.0 project to execute this sample code.
Advanced video encoding and publishing
There is a documented end-to-end sample code available in the SampleNet8.0 project, in file AdvancedEncodingAndPublishing.cs.
This sample code does the following :
- upload a mp4 file to a new asset using authentication in the browser (you need contribution role on the storage)
- create the output encoded asset
- create/update an encoding transform
- submit an encoding job
- create/update a transform to do the transcription of the video using AI
- submit a job to generate the transcription (vtt)
- create/update a transform to insert the vtt as a text track
- submit a job to insert the vtt as a text track in the encoded asset
- create/update a transform for thumbnails
- submit a job to generate a thumbnails sprite
- create a download locator for the thumbnails sprite and thumbnails vtt and list the Urls
- create a streaming locator for the encoded asset
- create and start a streaming endpoint if there is none
- list the streaming urls and test player urls (within the Bitmovin player, go to the settings and enable subtitles to
English). - clean the created resources if the user accepts
Edit Program.cs file in SampleNet8.0 to uncomment the line await AdvancedEncodingAndPublishing.RunAsync();, comment await SimpleEncodingAndPublishing.RunAsync();, and run the SampleNet8.0 project.
Live streaming
There is a documented end-to-end sample code for live streaming, in file SimpleLiveStreaming.cs.
What the sample does :
- create a live event (with an option to enable live transcription)
- create a live output asset
- create a live output
- create a locator
- create and start a streaming endpoint if there is none
- list the streaming urls and test player urls.
- propose to the user to convert the live asset to a mp4 asset and create a download locator to download the mp4 file(s)
- clean the created resources if the user accepts
Edit Program.cs file in SampleNet8.0 to uncomment the line await SimpleLiveStreaming.RunAsync();, comment await SimpleEncodingAndPublishing.RunAsync();, and run the SampleNet8.0 project.
Other examples
Here is an example on how to use the SDK to manage assets and streaming endpoints :
using MK.IO;
using MK.IO.Models;
// **********************
// MK.IO Client creation
// **********************
var client = new MKIOClient("yourMKIOSubscriptionName", "yourMKIOPersonalAPIToken");
// get user profile info
var profile = client.Account.Management.YourProfile.GetProfile();
// Get subscription stats
var stats = client.Account.GetSubscriptionStats();
// Get monthly usage of MK.IO subscription
var monthlyUsage = client.Account.GetSubscriptionUsage();
// *****************
// asset operations
// *****************
// list assets
var mkioAssets = client.Assets.List();
// list assets with pages, 10 assets per page, sorted by creation date
var mkioAssetsResult = client.Assets.ListAsPage("properties/created desc", null, null, null, 10);
while (true)
{
// do stuff here using mkioAssetsResult.Results
if (mkioAssetsResult.NextPageLink == null) break;
mkioAssetsResult = client.Assets.ListAsPageNext(mkioAssetsResult.NextPageLink);
}
// get asset
var mkasset = client.Assets.Get("myassetname");
// create a first asset, letting MK.IO generates a container name
var newAssetName = MKIOClient.GenerateUniqueName("asset");
var newasset = client.Assets.CreateOrUpdate(newAssetName, null, "storagename", "description of my asset");
// create another asset and use labels to tag it. Container name will be the nae of the asset
var newAssetName2 = MKIOClient.GenerateUniqueName("asset");
var newasset2 = client.Assets.CreateOrUpdate(
newAssetName,
newAssetName, // container name
"storagename",
"description of asset using labels",
AssetContainerDeletionPolicyType.Retain,
null,
new Dictionary<string, string>() { { "typeAsset", "source" } }
);
// list assets using labels filtering
var sourceEncodedAssets = client.Assets.List(label: new List<string> { "typeAsset=source" });
// delete created asset
client.Assets.Delete(newsasset.Name);
// get streaming locators for asset
var locatorsAsset = client.Assets.ListStreamingLocators("asset-1b510ee166");
// Get tracks and directory of an asset
var tracksAndDir = client.Assets.ListTracksAndDirListing("asset-ef2058b692");
// ******************************
// Streaming endpoint operations
// ******************************
// get streaming endpoint
var mkse = client.StreamingEndpoints.Get("streamingendpoint1");
// list streaming endpoints
var mkses = client.StreamingEndpoints.List();
// create streaming endpoint
var newSe = client.StreamingEndpoints.Create("streamingendpoint2", client.Account.GetSubscriptionLocation()!.Name, new StreamingEndpointProperties
{
Description = "my description",
ScaleUnits = 0,
CdnEnabled = false,
Sku = new StreamingEndpointsCurrentSku
{
Name = StreamingEndpointSkuType.Standard
}
});
// start, stop, delete streaming endpoint
client.StreamingEndpoints.Start("streamingendpoint1", true);
client.StreamingEndpoints.Stop("streamingendpoint1", true);
client.StreamingEndpoints.Delete("streamingendpoint1");
Additional samples are available :
- storage operations
- transform and job operations
- account filter and asset filter operations
- content key policy and streaming locator operations
Async operations are also supported. For example :
// *****************
// asset operations
// *****************
// Retrieve assets with pages for better performances, sorted by names, with a batch of 10 assets in each page
var mkioAssetsResult = await client.Assets.ListAsPageAsync("name desc", null, null, null, 10);
while (true)
{
// do stuff here using mkioAssetsResult.Results
if (mkioAssetsResult.NextPageLink == null) break;
mkioAssetsResult = await client.Assets.ListAsPageNextAsync(mkioAssetsResult.NextPageLink);
}
// ******************************
// Streaming endpoint operations
// ******************************
// get streaming endpoint
var mkse = await client.StreamingEndpoints.GetAsync("streamingendpoint1");
// list streaming endpoints
var mkses = await client.StreamingEndpoints.ListAsync();
// create streaming endpoint
var location = await client.Account.GetSubscriptionLocationAsync();
var newSe = await client.StreamingEndpoints.CreateAsync("streamingendpoint2", location!.Name, new StreamingEndpointProperties
{
Description = "my description",
ScaleUnits = 0,
CdnEnabled = false,
Sku = new StreamingEndpointsCurrentSku
{
Name = StreamingEndpointSkuType.Standard
}
});
// start, stop, delete streaming endpoint
await client.StreamingEndpoints.StartAsync("streamingendpoint1", true);
await client.StreamingEndpoints.StopAsync("streamingendpoint1", true);
await client.StreamingEndpoints.DeleteAsync("streamingendpoint2");
Contributing
This project welcomes contributions and suggestions. Most contributions require you to agree to a Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
When you submit a pull request, a CLA bot will automatically determine whether you need to provide a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions provided by the bot. You will only need to do this once across all repos using our CLA.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.
Trademarks
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow Microsoft's Trademark & Brand Guidelines. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Any use of third-party trademarks or logos are subject to those third-party's policies.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 is compatible. |
| .NET Framework | net461 was computed. net462 is compatible. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETFramework 4.6.2
- JsonSubTypes (>= 2.0.1)
- Microsoft.CSharp (>= 4.7.0)
- Microsoft.IdentityModel.JsonWebTokens (>= 8.2.0)
- Microsoft.Net.Http (>= 2.2.29)
- Newtonsoft.Json (>= 13.0.3)
-
.NETStandard 2.0
- JsonSubTypes (>= 2.0.1)
- Microsoft.CSharp (>= 4.7.0)
- Microsoft.IdentityModel.JsonWebTokens (>= 8.2.0)
- Newtonsoft.Json (>= 13.0.3)
-
.NETStandard 2.1
- JsonSubTypes (>= 2.0.1)
- Microsoft.CSharp (>= 4.7.0)
- Microsoft.IdentityModel.JsonWebTokens (>= 8.2.0)
- Newtonsoft.Json (>= 13.0.3)
-
net8.0
- JsonSubTypes (>= 2.0.1)
- Microsoft.IdentityModel.JsonWebTokens (>= 8.2.0)
- Newtonsoft.Json (>= 13.0.3)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.1.3 | 32,022 | 11/5/2024 |
| 2.1.2 | 2,830 | 9/19/2024 |
| 2.1.1 | 660 | 9/4/2024 |
| 2.1.0 | 4,295 | 7/31/2024 |
| 2.0.1 | 5,330 | 7/10/2024 |
| 2.0.0 | 252 | 7/10/2024 |
| 1.7.2 | 40,155 | 7/1/2024 |
| 1.7.1 | 2,517 | 6/24/2024 |
| 1.7.0 | 1,837 | 6/17/2024 |
| 1.6.3 | 3,614 | 6/14/2024 |
| 1.6.2 | 16,197 | 5/31/2024 |
| 1.6.1 | 5,258 | 5/20/2024 |
| 1.6.0 | 5,172 | 5/14/2024 |
| 1.5.0 | 11,385 | 4/22/2024 |
| 1.4.0 | 1,559 | 3/25/2024 |
| 1.3.0 | 1,015 | 3/18/2024 |
| 1.2.2 | 864 | 3/8/2024 |
| 1.2.1 | 250 | 3/7/2024 |
| 1.2.0 | 240 | 3/6/2024 |
| 1.1.0 | 3,236 | 12/21/2023 |