https://github.com/codd-tech/video-ad-sdk-web
https://github.com/codd-tech/video-ad-sdk-web
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/codd-tech/video-ad-sdk-web
- Owner: codd-tech
- License: mit
- Created: 2024-11-14T15:53:45.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2025-05-21T13:18:34.000Z (about 1 year ago)
- Last Synced: 2025-07-14T01:57:52.188Z (12 months ago)
- Language: TypeScript
- Size: 229 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# Video AD Player SDK Documentation
## Overview
The Video AD Player SDK provides a simple interface for initializing and displaying video ads in your application.
Import the SDK and use its functions to integrate video ads with customizable skip settings and callback methods for
handling the completion of ads.
## Installation
To use this SDK, first install it in your project:
```bash
npm install @teleads/tma-sdk
```
or
```bash
yarn add @teleads/tma-sdk
```
## Quick Start
Import the SDK into your file and initialize the app using the provided token.
```typescript
import TeleAdsTMA from '@teleads/tma-sdk';
// Initialize the TeleAds SDK for TMA using the SDK token
TeleAdsTMA.init('YOUR_SDK_TOKEN');
// Show advertising
TeleAdsTMA.showAD({
adUnitId: 'AD_UNIT_ID',
onVideoEnded: (status) => {
console.log(`Ad ended with status: ${status}`);
},
});
```
### Also, you can use Promises
First, ensure that you've set up the SDK as usual:
```typescript
import TeleAdsTMA from '@teleads/tma-sdk';
// Initialize the TeleAds SDK for TMA using the SDK token
TeleAdsTMA.init('YOUR_SDK_TOKEN');
// Show advertising with Promise-like API
TeleAdsTMA.showAD({
adUnitId: 'AD_UNIT_ID'
}).then(status => {
console.log(`Ad ended with status: ${status}`);
}).catch(error => {
console.error('Ad failed to show:', error);
});
```
## API Overview
### Methods
### `init(token: string): void`
Initializes the application with the provided token.
- **token** (string): Your API token for initializing the SDK.
### `showAD(options: ShowAdOptions): void`
Displays a video with the specified options.
- **options** (`ShowAdOptions`): An object containing options for displaying the video.
## Interfaces
### `ShowAdOptions`
Options for displaying the video.
- **adUnitId** (`string`): The ad unit id to be displayed.
- **onEnded** (function, optional): A callback invoked when the video ends.
- Accepts values: `'skipped'` | `'closed'`
- **onClick** (function, optional): A callback invoked when the user clicked on AD.
## Types
### `VideoPlayedStatus`
The status of the completed video.
- Values: `'skipped'`, `'closed'`