Table of Contents

Method Activate

Namespace
DotNetBrowser.Engine
Assembly
DotNetBrowser.dll

Activate()

Activates the Widevine component and updates it to the latest version if it is available.

Task<WidevineActivationStatus> Activate()

Returns

Task<WidevineActivationStatus>

The task that completes with the status of the Widevine activation.

Remarks

The Widevine component files are stored in the user data directory of the engine.

On Windows and macOS, you can activate Widevine without specifying a custom user data directory. There's no need to restart the engine after first activation or update, as the changes are applied automatically.

On Linux, you must specify a custom user data directory to activate Widevine. It is required due to the way Widevine is implemented on Linux. When the component is activated for the first time, or it is updated to the latest version during activation, the engine must be restarted to apply the changes.

Here is an example of how to specify a custom user data directory and restart the engine if it is required:

var options = new EngineOptions.Builder()
{
    // Specify a custom user data directory.
    UserDataDirectory = "path/to/user/data/dir"
}.Build();
var engine = EngineFactory.Create(options);
// Activate Widevine and restart the engine if necessary.
var status = engine.Widevine.Activate().Result;
if (status == WidevineActivationStatus.RestartRequired)
{
    // Restart the engine with the same options.
    engine.Dispose();
    engine = EngineFactory.Create(options);
}
var browser = engine.CreateBrowser();

Exceptions

ObjectDisposedException

The IEngine has already been disposed.

ConnectionClosedException

The connection to the Chromium engine is closed.

See Also