package com.yidianling.fm.router

import android.app.Activity
import android.content.Intent
import com.ydl.media.audio.AudioPlayer
import com.ydl.media.view.PlayerFloatHelper
import com.yidianling.fm.FMDetailActivity
import com.yidianling.router.fm.IFMRouter

class FmRouterImp : IFMRouter{

    override fun fmDetailIntent(activity: Activity, id: Int): Intent {
        return FMDetailActivity.newIntent(activity, id)
    }

    override fun fmDetailIntent(activity: Activity, id: Int, isSplash: Boolean): Intent {
        return FMDetailActivity.newIntent(activity, id, isSplash)
    }

    override fun getFmId(): Int {
        return PlayerFloatHelper.getFmId()
    }

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

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

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

    override fun replay() {}
}