In Methode Swing it is possible to configure custom oembed providers.

Prepare the plugin to add custom oembed providers

In general, all the extensions of Méthode Swing are places under

{SWING-APP}/plugins

So, all the Javascript described in the following sections should be placed under

{SWING-APP}/app/plugins/{EXTENSION-FOLDER}/{EXTENSION-NAME}.js

Do not use the word libs as an extension folder. The libs folder is reserved for loading external libs. See the proper documentation to obtain further info on the topic.

DEBUG MODE: by default, all plugins are aggregated into a single plugins.js file at the Tomcat startup. When creating a plugin, it may be frustrating to restart the Tomcat Server every time a change is made.

To avoid this, set the configuration property debugEnabled to true.

Then, that extension will be loaded on every refresh of the page.

Add a custom oembed provider

In order to add a custom oembed provider to Methode Swing, it is necessary to use the following namespace:

eidosmedia.webclient.extensions.oembedProviders

The syntax is the following:

eidosmedia.webclient.extensions.oembedProviders.add((customOmbedProviders);

Where:

  • customOmbedProviders [array] is a list of custom oembed providers (oembed provider object) to add to the already available ones.

EmbedProviderObject are defined in this way:

  • name [string] is the name of the custom oembed provider.

  • type [string] [photo | video | rich ] - is the type of the oembed provider.

  • urlschemearray [array] a list of regular expression to matxh the custom url oembed provider.

  • apiendpoint [string] an endpoint url if requetsed by the custom oembed provider. It can be null.

  • extraSettings [object] extra setting needed by the custom oembed provider. It can be null.

It’s possible to configure an oembed provider to use a swing proxy. In this case the apiendpoint value must be the same of the proxy name and the attribute useSwingProxy of the extraSettings object must be set to true, the attribute dataType must be set according to the return value of the embed service that who made the extension has decided to integrate. In general it is set to the json value.

Example

eidosmedia.webclient.extensions.oembedProviders.add(
    [
        {
            name: 'scmptv',
            type: 'video',
            urlschemearray: ['widgets\\.scmp\\.com/video/.+'],
            apiendpoint: null,
            extraSettings: {
                templateRegex: /.*id=(\w+).*/,
                template: '<iframe src="http://widgets.scmp.com/video/video_iframe.php?id=$1" width="100%" allowfullscreen="true" allowscriptaccess="always"' +
                'scrolling="no" frameborder="0" style="max-height: none !important; height: 540px;"></iframe>',
                nocache: 1
            }
        },

        // custom oembed provider that use swing proxy
        {
            name: 'myvideoplace',
            type: 'video',
            urlschemearray: ["myvideoplace\\.tv/.+"],
            apiendpoint: 'mvp', // same of the proxy name
            extraSettings: {
                dataType: 'json',
                useSwingProxy: true
            }

        }
    ]
);

If the name of the custom oembed provider corresponds to an oembed provider of those released (eg facebook) then the default behavior is replaced with that of the custom oembed provider, the default behavior is overriden.