Skip to content

Repository files navigation

Android Core SDK

Setup

Step 1. Add the JitPack repository to your build file

Add it in your build.gradle (root) at the end of repositories:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

Step 2. Add the dependency

Add it in your build.gradle (app):

dependencies {
    implementation 'com.github.visionplus-development:android-core-sdk:$latest_version'
}

Step 3. Usage

Config

// init sdk on .Application
VisionPlusCore.init(this) // required

// enable debug
if (BuildConfig.DEBUG) {
    VisionPlusCore.enableDebugMode()
}

// Global config
VisionPlusCore.setGlobalConfig(
    GlobalConfig(
        deviceId = "DEVICE ID", // required
        token = "USER TOKEN", // we can define token later
    )
)

// Module config: Device Limit
VisionPlusCore.setCoreModuleConfig(
    CoreModuleConfig.Device(
        heartbeatIntervalMs = 5000, // in milliss
        url = "URL" // full url
    )
)

// Update token
VisionPlusCore.updateToken("USER TOKEN") // we can update token like this

Preparation

val coreDeviceManager = VisionPlusCore.getDeviceManager()

coreDeviceManager.setOnFirstHeartbeatCallback { state ->
    when (state) {
        is ConcurrentPlayState.Ok -> {
            // Concurrent Play Ok, user can proceed or play the video
        }
        is ConcurrentPlayState.DeviceLimitExceeded -> {
            // Concurrent Play exceeded, may prompt user about that
            // and call coreDeviceManager?.stop() if needed
        }
        is ConcurrentPlayState.Exception -> {
            if (state.exception is SocketException) {
                // socket exception happen, please do something or leave it empty to do nothing
            }

            // another exception checking, or just leave it empty to do nothing
        }
    }
}

coreDeviceManager.setOnContinuousHeartbeatCallback { state ->
    when (state) {
        is ConcurrentPlayState.Ok -> {
            // Concurrent Play Ok, user can proceed or continue playing the video, or leave it empty to do nothing
        }
        is ConcurrentPlayState.DeviceLimitExceeded -> {
            // Concurrent Play exceeded, may prompt user about that
            // and call coreDeviceManager?.stop() if needed
        }
        is ConcurrentPlayState.Exception -> {
            if (state.exception is SocketException) {
                // socket exception happen, please do something or leave it empty to do nothing
            }

            // another exception checking, or just leave it empty to do nothing
        }
    }
}

coreDeviceManager.setOnStopHeartbeatCallback {
    // stop player here
}

Start/Stop

// start the heartbeat
coreDeviceManager.start()

// stop the heartbeat
coreDeviceManager.stop()

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages