# Virtual Sports Mobile Video Widget Integration

## General information

The Sportradar Virtual Sports Mobile Suite video widget is available for a dedicated integration when the bookmaker chooses to do its own odds visualization. This includes the video area with the live scores, time line and possibility to switch between the available matches.

Additionally it includes the separator bars for the odds area, in order to show the information for the upcoming 2 match days.

<figure><img src="/files/PnSAXr9DRwKNi8xAncEw" alt="" width="238"><figcaption></figcaption></figure>

The video widget is available for Virtual Football, as well as, Virtual Basketball League.

## Host page HTML requirements

Sportradar’s Virtual Sports Mobile Video Widget is a framework for a mobile web application, which integrates into an existing mobile-optimized website as a JavaScript plugin.

In order to integrate the video widget plugin, the following steps must be implemented in the host\
webpage:

### Include the vsmobile JavaScript plugin

```javascript
<script type="text/JavaScript" src="https://{domain}/ls/mobile/?/<CUSTOMER>/<LANGUAGE_CODE>/[<TIME_ZONE>/]page/vsmobile"></script>
```

The JavaScript plugin is hosted on Sportradar's servers. `{domain}` will be provided by your assigned integration manager during integration.

Configurable parts in the URL are the customer name (`<CUSTOMER>`), language code (`<LANGUAGE_CODE>`, e.g. en) and time zone (`<TIME_ZONE>`, e.g. Europe:Berlin). The time zone parameter is optional. The UI customization is based on the client name URL parameter, therefore each client is assigned a unique client name. Language should follow the localization of the host page.

The following is an example script URL:

```javascript
<script type="text/JavaScript" src="http://{domain}/ls/mobile/?/<CUSTOMER>/en/Europe:Berlin/page/vsmobile"></script>
```

### Provide container DOM elements in which the UI will be injected

A container element is typically a `div` tag or some other block element with `id` attribute set. Example\
is shown below:

```html
<div id="vsm_container"></div>
```

If you want to use optional features like the match day title components, you need to provide\
container elements for those as well:

```html
<div id="vsm-current-matchday-title" class="vsm-current-matchday-title"></div>
<div id="vsm-next-matchday-title" class="vsm-next-matchday-title"></div>
```

### Add `meta` tags to the `<HEAD>` section

Sportradar’s Virtual Sports Mobile Video Widget is a web page optimized for mobile browsing. For\
optimal mobile experience the following meta tags should be added to a section in the host\
HTML page.

```html
<meta name="viewport" content="initial-scale=1, maximum-scale=1, width=device-width, minimal-ui"/>
<meta name="mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-capable" content="yes"/>
<meta names="apple-mobile-web-app-status-bar-style" content="black-translucent"/>
```

The first `<meta>` tag is needed for setting the `viewport` to a size of the display on the device and for\
disabling zoom. It also instructs the browser to minimize the address bar and toolbars on some\
devices.

The second and third lines enable the use of full-screen mode in iOS devices under certain\
circumstances.

It is also recommended to add `<link rel="icon" />`, `<link rel="apple-touch-icon />` and `<link rel="manifest" />` tags to the head of the document in order to customize the application icon if the user adds the page to their home screen.

## Plugin initialization

The widget is initialized using the `vsmobile.init()` method. First parameter is the `CSS` selector that returns the container element and the second parameter contains initialization options. **The parameter `sport` in the initialization options must be set to** **`vflm.widget-mobile`**. Sample code of the initialization call is shown below. Note that only one application instance may be initialized on the host page at any given time:

```javascript
var vsm = vsmobile.init('#vsm-container', {
    sport: 'vflm.widget-mobile’,
    ...
});
```

### Initialization options

Initialization options are added as a second parameter in the `init` method. Example of one such\
object is shown below. Use this object just as an example that contains all the available parameters\
(usually you do not need to use them all).

```javascript
var options = {
    sport: sport,
    onLoad: onLoad,
    setEvents: setEvents,
    showUnsupportedDeviceWarning: true,
    clientId: <CLIENT_ID>,
    currentMatchdayTitleContainer: '#vsm-current-matchday-title',
    nextMatchdayTitleContainer: '#vsm-next-matchday-title'
};
```

The initialization options are documented in the table below. Callback functions are described in\
detail in the following section.

<table><thead><tr><th width="160" valign="top">Option</th><th width="110" valign="top">Required</th><th width="89" valign="top">Type</th><th width="97" valign="top">Default</th><th valign="top">Comment</th></tr></thead><tbody><tr><td valign="top"><code>sport</code></td><td valign="top">yes</td><td valign="top">string</td><td valign="top">null</td><td valign="top"><p>The sport to display on this page. The only supported options are:</p><p><br><code>vflm.widget-mobile</code><br><code>vfnc.widget-mobile</code><br><code>vfwc.widget-mobile</code><br><code>vfas.widget-mobile</code><br><code>vfc.widget-mobile</code><br><code>vfcc.widget-mobile</code><br><code>vbl.widget-mobile</code></p></td></tr><tr><td valign="top"><code>onLoad</code></td><td valign="top">no</td><td valign="top">function</td><td valign="top">/</td><td valign="top">Callback function which is called when application is loaded.</td></tr><tr><td valign="top"><code>showUnsupportedDeviceWarning</code></td><td valign="top">no</td><td valign="top">boolean</td><td valign="top">true</td><td valign="top">Set to false to disable warning for<br>unsupported devices (this warning is shown once on the first load).</td></tr><tr><td valign="top"><code>clientId</code></td><td valign="top">no</td><td valign="top">numeric</td><td valign="top">implicit</td><td valign="top">The numeric client identifier (Sportradar S4 client ID). Primarily used for internal testing purposes.</td></tr><tr><td valign="top"><code>setEvents</code></td><td valign="top">no</td><td valign="top">function</td><td valign="top">/</td><td valign="top">Callback function which is called every betstop phase. Returns information regarding the current sport (including event_ids).</td></tr><tr><td valign="top"><code>currentMatchdayTitleContainer</code></td><td valign="top">no</td><td valign="top">string</td><td valign="top">null</td><td valign="top">Id of the container element for the<br>current match day title component.</td></tr><tr><td valign="top"><code>nextMatchdayTitleContainer</code></td><td valign="top">no</td><td valign="top">string</td><td valign="top">null</td><td valign="top">Id of the container element for the next match day title component.</td></tr></tbody></table>

## Callbacks

With callbacks, you can respond to events in the video widget application. There are several\
callbacks that can be implemented on client side. The first parameter to all callbacks is the `VSM`\
instance that triggered the callback.

### `onLoad`

This callback function is called when application is loaded. API methods may safely be called only\
after the application is loaded, as signaled by this callback.

```javascript
function onLoad(vsmInstance) {
    console.log('vsm loaded');
};
```

### `setEvents`

This callback function is called whenever new events (e.g. matches or races) are available for\
betting. It is called during the `betstop` phase in league mode and in the group stage of the cup mode,\
but can vary in the knockout stage of the cup mode. Returns information regarding the current sport.

```javascript
function setEvents(vsmInstance, data) {
    console.log(data);
};
```

The data object has the following properties:

<table><thead><tr><th valign="top">Property</th><th valign="top">Description</th></tr></thead><tbody><tr><td valign="top"><code>screen_name</code></td><td valign="top">E.g. <code>mobile-cup</code> (for VFC, VFNC, ...) or <code>mobile-league</code> (for VFLM, ...).</td></tr><tr><td valign="top"><code>sport</code></td><td valign="top">VFC, VFNC, VFLM, VBL</td></tr><tr><td valign="top"><code>unique_tournament_id</code></td><td valign="top">The unique tournament id.</td></tr><tr><td valign="top"><code>chunks</code></td><td valign="top">Array containing chunk objects. This first chunk contains the next events that can be bet on, the second chunk contains the events after that, and so on. Usually 2 entries, but can only 1 during a knockout stage.</td></tr></tbody></table>

A chunk object has the following properties:

<table><thead><tr><th valign="top">Property</th><th valign="top">Description</th></tr></thead><tbody><tr><td valign="top"><code>competition_nr</code></td><td valign="top">Continuous number of the competition which this event belongs to, as displayed on-screen (positive integer).</td></tr><tr><td valign="top"><code>competition_stage_type</code></td><td valign="top">Type of the stage this event belongs to. <code>league</code> (group stage or league mode) or <code>cup</code> (knockout stage).</td></tr><tr><td valign="top"><code>eventset_nr</code></td><td valign="top">Number of the event set (round or match day; between 1 and 30)</td></tr><tr><td valign="top"><code>event_ids</code></td><td valign="top">Array containing the event_ids (matches or races) that occur at the same time (positive integer).</td></tr></tbody></table>

## Plugin instance methods

Instance methods provided by the `VSM` object that is returned at initialization.

```javascript
addVsmWidget(widgetName, container, options)
```

Adds a new widget and returns handle id which can be passed to `removeVsmWidget` to remove the\
given widget.

```javascript
removeVsmWidget(widgetHandle)
```

Removes the widget with the passed handle id.

Please not that use of these methods is only recommended with in-depth knowledge of available\
widget options.

## Optional widget components - Match list divider bar widget

The following widgets can be used within Sprotradar’s Virtual Sports Mobile Video Widget. It can show\
the current or upcoming round with corresponding betstop timer:

<figure><img src="/files/dLUKB6MVFqQAO87P2Gm2" alt="" width="331"><figcaption></figcaption></figure>

```javascript
widgetName: 'vfl.widget-matchdayTitle',
options: {
    matchday: ‘current|next’ // default is current
}
```

It is recommended you don’t add this component manually and just provide the `currentMatchdayTitleContainer` and/or `nextMatchdayTitleContainer` options.

## Initialization example

```javascript
var instance = vsmobile.init("#vsm-container", {
    sport: (options.sport || undefined),
    onLoad: function() {
        console.log( ‘Loaded’ );
    },
    currentMatchdayTitleContainer: '#vsm-current-matchday-title',
    nextMatchdayTitleContainer: '#vsm-next-matchday-title',
});
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.sportradar.com/games/virtual-sports/virtual-sports-via-unified-odds-feed-uof/frontend-integration/mobile-integration/virtual-sports-mobile-video-widget-integration.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
