Skip to main content

Quick start

TikCDN solution makes full use of idle terminal bandwidth resources, complements traditional CDN, and builds a cost-effective new generation of content distribution network. Developers can quickly integrate with their own applications through the simple interface in the SDK to achieve P2P acceleration on Android devices.

Precondition

Demo Running Guide

1、Download demo

2、Configuration develops information

Prj-Android/app/src/main/java/org/anyrtc/tiktracker/Config.kt

Enter your appId in the above class

object Config {
val appId = "your appId"
}

3、Change the package name to ensure that it is the same as the value entered when creating the application, otherwise the acceleration service will not be used. (If the application is published, make sure that SHA1 is the same as when creating the application, otherwise the acceleration service will not be used.)

4、After running through, you need to run through the example on another machine to see the P2P acceleration effect

Integrated SDK

Integration via MavenCenter

In the project's /app/build.gradle file, add the following line:

...
dependencies {
...
// a.b.c Enter the version number, for example, 4.2.2
// The latest version number can be obtained through the SDK release instructions
implementation 'xxxxxxx'
}

Please click on Release Notes for the latest version number.

Manual integration

1、Manually integrate copy xxxxx.aar to your project path.

2、The path is as follows:

File or folderProject Path
rtc-release file/app/libs/

3、Add the following code to the build.gradle file in the Mould directory

implementation fileTree(dir: 'libs', include: ['*.aar'])

Implementation step

Initialization engine

val engine = X2TikTrackerEngine(context, "your_app_id")

Register listening event

engine.registerListener(object : X2HlsShareEngineEventHandler {
override fun onShareResult(code: TKT_CODE?) {
println("Share result: $code")
}
// Implement other callback methods...
})

Start playing and speed up

val result = engine.startPlay("http://example.com/video.m3u8", true)

Get the p2p acceleration URL

var exUrl =  engine.getExUrl()

Playback acceleration URL

val dataSourceFactory: DataSource.Factory = DefaultHttpDataSource.Factory()
val hlsMediaSource =
HlsMediaSource.Factory(dataSourceFactory).createMediaSource(MediaItem.fromUri(Uri.parse(exUrl)))

Stop accelerating

engine.stopShare()

Release engine

engine.release()