Umbraco integration

Last Updated about a month ago

It is possible to extend Umbraco oembed integration by creating a new provider that would accept Screen9 oembed URLs. You would need to create two files and add them to the Umbraco installation.

First, create a Screen9EmbedProvider class that will accept Screen9 oembed URLs:

using System.Collections.Generic;
using Umbraco.Cms.Core.Media.EmbedProviders;
using Umbraco.Cms.Core.Serialization;

namespace MyCustomUmbracoSolution
{
    public class Screen9EmbedProvider : EmbedProviderBase
    {
        public Screen9EmbedProvider(IJsonSerializer jsonSerializer) : base(jsonSerializer)
        {
        }

        public override string ApiEndpoint => "https://api.screen9.com/oembed";

        public override string[] UrlSchemeRegex => new string[]
        {
            @"console.screen9.com\/*",
            @"\w+\.screen9.tv\/*",
        };

        public override Dictionary<string, string> RequestParams => new Dictionary<string, string>();

        public override string GetMarkup(string url, int maxWidth = 0, int maxHeight = 0)
        {
            var requestUrl = base.GetEmbedProviderUrl(url, maxWidth, maxHeight);
            var oembed = base.GetJsonResponse<OEmbedResponse>(requestUrl);
            return oembed.GetHtml();
        }
    }
}

Then, create RegisterEmbedProvidersComposer class that will append Screen9EmbedProvider to the EmbedProvidersCollection:

using Umbraco.Cms.Core.Composing;
using Umbraco.Cms.Core.DependencyInjection;

namespace MyCustomUmbracoSolution
{
    public class RegisterEmbedProvidersComposer : IUserComposer
    {
        public void Compose(IUmbracoBuilder builder) => builder.OEmbedProviders().Append<Screen9EmbedProvider>();
    }
}

Once this is completed, you can use the Embed icon in Rich Text Editor to add a new embed code:

image

Enter any of the allowed URLs (remember the video must be approved):

image

The video is rendered in the webpage:

image
This website relies on cookies to function, but no personal data is ever stored in the cookies.
OK

Loading ...