Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix/focus #6

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified radioplayer/libs/startrek-player.aar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,11 @@ class Player(private var url: String = "", private val listener: RadioPlayerCall
}
}

fun setVolume(volume: Double) {
mPlayback.setVolume(volume)
}

fun getVolume() = mPlayback.volume()

fun release() {
mPlayback.stop()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,106 +1,106 @@
package com.likhanov.radioplayer.playback
import android.support.v4.media.session.PlaybackStateCompat
import android.util.Log
class RadioPlayback(url: String) : Playback {
private var state = PlaybackStateCompat.STATE_NONE
private var playOnFocusGain: Boolean = false
private var callback: Playback.Callback? = null
private val playerCallback: RadioPlayerCallback = object : RadioPlayerCallback() {
override fun daastError(message: String?) {
callback?.onDaastError()
}
override fun isPlayingChanged(isPlaying: Boolean) {
if(isPlaying) callback?.onPlaybackStatusChanged(PlaybackStateCompat.STATE_PLAYING)
else callback?.onPlaybackStatusChanged(PlaybackStateCompat.STATE_PAUSED)
}
override fun daastStarted(meta: String?, imageUrl: String?, clickUrl: String?) {
callback?.onDaastStart(imageUrl, clickUrl)
}
override fun daastEnded() {
callback?.onDaastEnd()
}
override fun error(message: String?) {
callback?.onError("Player error $message")
}
}
private var player = Player(url, playerCallback)
override fun start() {
}
override fun stop(notifyListeners: Boolean) {
releaseResources()
}
override fun setState(state: Int) {
this.state = state
}
override fun getState(): Int {
return state
}
override fun isConnected(): Boolean = true
override fun isPlaying(): Boolean = playOnFocusGain
override fun getCurrentStreamPosition(): Long = 0
override fun updateLastKnownStreamPosition() {
}
override fun play() {
player.play()
playOnFocusGain = true
}
override fun pause() {
player.pause()
playOnFocusGain = false
}
fun updateUrl(url: String, masterStream: Boolean) = player.updateUrl(url, masterStream)
fun playing() = player.isPlaying()
fun isPaused() = player.isPaused()
fun isRestarted() = player.isRestarted()
fun setAd(url: String) = player.setAd(url)
fun daastClicked() = player.daastClicked()
override fun seekTo(position: Long) {
}
override fun setVolume(volume: Float) {
}
override fun getVolume(): Float {
return 0f
}
override fun setCurrentMediaId(mediaId: String?) {
}
override fun getCurrentMediaId(): String = ""
override fun setCallback(callback: Playback.Callback?) {
this.callback = callback
}
private fun releaseResources() {
player.release()
}
package com.likhanov.radioplayer.playback

import android.support.v4.media.session.PlaybackStateCompat
import android.util.Log

class RadioPlayback(url: String) : Playback {

private var state = PlaybackStateCompat.STATE_NONE
private var playOnFocusGain: Boolean = false
private var callback: Playback.Callback? = null

private val playerCallback: RadioPlayerCallback = object : RadioPlayerCallback() {

override fun daastError(message: String?) {
callback?.onDaastError()
}

override fun isPlayingChanged(isPlaying: Boolean) {
if(isPlaying) callback?.onPlaybackStatusChanged(PlaybackStateCompat.STATE_PLAYING)
else callback?.onPlaybackStatusChanged(PlaybackStateCompat.STATE_PAUSED)
}

override fun daastStarted(meta: String?, imageUrl: String?, clickUrl: String?) {
callback?.onDaastStart(imageUrl, clickUrl)
}

override fun daastEnded() {
callback?.onDaastEnd()
}

override fun error(message: String?) {
callback?.onError("Player error $message")
}
}
private var player = Player(url, playerCallback)

override fun start() {
}

override fun stop(notifyListeners: Boolean) {
releaseResources()
}

override fun setState(state: Int) {
this.state = state
}

override fun getState(): Int {
return state
}

override fun isConnected(): Boolean = true

override fun isPlaying(): Boolean = playOnFocusGain

override fun getCurrentStreamPosition(): Long = 0

override fun updateLastKnownStreamPosition() {
}

override fun play() {
player.play()
playOnFocusGain = true
}

override fun pause() {
player.pause()
playOnFocusGain = false
}

fun updateUrl(url: String, masterStream: Boolean) = player.updateUrl(url, masterStream)

fun playing() = player.isPlaying()

fun isPaused() = player.isPaused()

fun isRestarted() = player.isRestarted()

fun setAd(url: String) = player.setAd(url)

fun daastClicked() = player.daastClicked()

override fun seekTo(position: Long) {

}

override fun setVolume(volume: Float) {
player.setVolume(volume.toDouble())
}

override fun getVolume(): Float {
return player.getVolume().toFloat()
}
override fun setCurrentMediaId(mediaId: String?) {
}

override fun getCurrentMediaId(): String = ""

override fun setCallback(callback: Playback.Callback?) {
this.callback = callback
}

private fun releaseResources() {
player.release()
}
}
Loading