Snapping Games
Obtaining live sporting event information by 'snapping'
Integration
The following section deals primarily with the code used in capture of live game information for SnapOdds Operator. If your use case requires game odds to be presented, the information captured by SnapOdds Operator is fed into SnapOdds Sports Media to correlate the game odds information, as described in Game Odds.
Description
With this configuration, the web component is able to "snap" an image of a live TV stream and retrieve information on the currently playing sporting event shown. It is expected that the customer's web application will use the response from the SDK to render more detailed information about the sporting event.
First, ensure both the JavaScript and CSS resource are correctly loaded and that the access token manager is correctly implemented.
To render the SnapOdds SDK component, a DOM element must be provided, to which the component will be attached to as a child. In most cases, the document.body
component works best, as the SDK is then added as the last child, which helps with styling as the SDK overlays the full viewport.
Next, it is necessary to configure the SDK and add it as a child to the DOM element of your choice. This can be done by using SnapoddsSdk.snapBuilder()
.
Show SDK immediately
The following configuration is the simplest one and will show the SDK immediately after appendTo()
is called.
Show SDK only if sportEvents are live
The SDK can provide you with the information if there is at least one sportsEvent live, based on your channel's configuration.
Instead of appending the SDK to the document.body
, you need to configure the onLiveEventsStatusChangedCallback()
first. Therefore, you have to call build()
instead of appendTo()
at the end of the SDK's initialisation in order for it to work.
The callback you provide will be executed after initialisation and will return either true
or false,
indicating that there is at least one live sportsEvent available or not.
After that, it will automatically check every 5 minutes for upcoming sportEvents. If one is found the callback will be invoked as soon as the sportsEvent starts..
The following parameters are used in the SnapoddsSdk.operatorsBuilder()
:
SDK Configuration Options
Method | Parameter | Default Value | Description |
---|---|---|---|
setLanguage | string | en | Set the language of the SDK. |
setAutoSnap | boolean | false | Turns on the auto snap functionality. |
setVibrate | boolean | false | Uses the phones vibrate functionality, when the snap was successful. |
setAccessTokenProvider | function | function that throws an error if not set | A function that takes no parameters and returns the Promise of the access token See access token implementation for more information. |
onLiveEventsStatusChangedCallback | function( | no operation | Callback function executed after initialisation and when an upcoming sportsEvent becomes live |
onResults | function( | no operation | Callback function executed when sports events are detected. |
onClose | function(): void | no operation | Callback function to handle SDK close events. |
appendTo | DOM Element | none | This call will finish the web component configuration and appends it to the given DOM element as child node. |
build | none | none | Returns an intermeediate instance of the SdkBuilder. Needs to be used in combination with |
setSnapBackHidden | boolean | false | Hide the "back" button in the Snap view |
Result format
tvSearchResult
has the following format:
Last updated