package com.yidianling.course.modular_service

import android.app.Activity
import android.content.Context
import com.ydl.media.audio.AudioPlayer
import com.ydl.media.view.PlayerFloatHelper
import com.yidianling.course.api.service.ICourseService
import com.yidianling.course.courseNew.CourseTopicActivity
import com.yidianling.course.flutterPlugin.CourseSendPlugin

/**
 * @author jiucheng
 * @描述:
 * @Copyright Copyright (c) 2018
 * @Company 壹点灵
 * @date 2019/11/12
 */
class CourseServiceImp :ICourseService {
    override fun courseTopic(activity: Activity, id: String) {
        CourseTopicActivity.start(activity, id)
    }

    override fun closePlayer() {
        if (AudioPlayer.get().isPlaying){
            AudioPlayer.get().stopPlayer()
        }
    }

    override fun isPlaying(): Boolean {
        return AudioPlayer.get().isPlaying
    }

    override fun startCoursePlayPage(activity: Activity, from: Int) {
        PlayerFloatHelper.startCoursePlayActivity(activity,from)
    }

    override fun play() {
        AudioPlayer.get().play()
    }

    override fun pause() {
        AudioPlayer.get().playPause()
    }

    override fun sendLoginStatusToFlutter() {
        CourseSendPlugin.sendLoginSuccess()
    }

    override fun init(context: Context?) {
    }
}