P
- subClasspublic abstract class APlayerBinding<P extends APlayerBinding> extends java.lang.Object implements IPlayer<P>
PlayerBinding
Modifier and Type | Class and Description |
---|---|
static interface |
APlayerBinding.BindingListener |
static interface |
APlayerBinding.BindPlayer |
IPlayer.Listener
Modifier and Type | Field and Description |
---|---|
private APlayerBinding.BindingListener |
mBindingListener |
private APlayerBinding.BindPlayer |
mBindPlayer |
private boolean |
mBound |
private android.content.ServiceConnection |
mConnection |
protected android.content.Context |
mContext |
private android.content.Intent |
mIntent |
private PlayerService |
mService |
STATE_BUFFERING, STATE_ENDED, STATE_GOT_SOURCE, STATE_IDLE, STATE_READY
Constructor and Description |
---|
APlayerBinding(android.content.Context context,
java.lang.Class<PService> playerServiceClass,
APlayerBinding.BindPlayer bindPlayer) |
APlayerBinding(android.content.Context context,
java.lang.Class<PService> playerServiceClass,
APlayerBinding.BindPlayer bindPlayer,
APlayerBinding.BindingListener serviceConnected) |
Modifier and Type | Method and Description |
---|---|
void |
addListener(IPlayer.Listener listener) |
int |
calibrateCurrentPositionUnitIndex(long position)
generally not use(player inside Will automatically maintain current [position unit] index
calibrate)
|
void |
clearAB()
Clear A-B all tag Tips: setClearAB(false) also don't manual invoke clearAB(), will save
all tag.
|
void |
clearVideo() |
boolean |
fastForwardRewind(long ms) |
AudioMgrHelper |
getAudioMgrHelper() |
java.lang.String |
getCurrentMediaId()
Returns current media id (custom or default[string representation of this play uri])
|
long |
getCurrentPosition() |
int |
getCurrentPositionUnitIndex() |
long |
getDuration() |
IMediaQueue |
getMediaQueue()
get a media queue, if not
IPlayer.setMediaQueue(IMediaQueue) , it return default media queue |
float |
getPlaybackSpeed() |
int |
getPlaybackState() |
float |
getVolume()
Returns the volume, with 0 being silence and 1 being unity gain.
|
P |
init(IMediaPlayer mediaPlayer)
Init internal media player
|
IMediaPlayer |
internalPlayer()
Get a internal mediaPlayer
|
protected boolean |
isBound() |
boolean |
isPlayable()
Playback state !=
IPlayerBase.STATE_IDLE != IPlayerBase.STATE_GOT_SOURCE != IPlayerBase.STATE_BUFFERING |
boolean |
isPlaying() |
void |
onDestroy() |
boolean |
pause() |
boolean |
play() |
boolean |
play(IMediaItem mediaItem) |
boolean |
play(android.net.Uri uri) |
IPlayer |
player() |
boolean |
playMediaId(java.lang.String mediaId) |
boolean |
prepare(IMediaItem mediaItem) |
boolean |
prepare(android.net.Uri uri) |
boolean |
prepareMediaId(java.lang.String mediaId) |
void |
release() |
void |
removeListener(IPlayer.Listener listener) |
void |
reset() |
protected abstract P |
returnThis()
Sub Class Override
|
boolean |
seekTo(long ms)
internal call
IPlayer.seekTo(long, int) Max processing level |
boolean |
seekTo(long ms,
int processingLevel)
Support custom processing level of seekTo
|
void |
seekToPending(long ms)
set a pending seekTo in before start() dispose
|
long |
seekToPositionUnitIndex(int posUnitIndex)
Seeks to specified PositionUnitIndex
|
long |
seekToProgress(int progress,
int progressMax)
Seeks to specified progress
|
protected PlayerService |
service() |
P |
setAB(long startPos,
long endPos)
Set A-B start position and end position with reset ab all tag
|
P |
setAB(long startPos,
long endPos,
int loopMode,
int loopInterval)
Set A-B internal call
IPlayer.setAB(long, long) , IPlayer.setABLoop(int, int)
*param loopMode,loopInterval can use C.PARAM_ORIGINAL keeping the original values
*param loopMode,loopInterval can use C.PARAM_UNSET /C.PARAM_RESET
unset/reset values |
P |
setABLoop(int loopMode,
int loopInterval)
Set A-B loop *param loopMode,loopInterval can use
C.PARAM_ORIGINAL keeping the
original values *param loopMode,loopInterval can use C.PARAM_UNSET /C.PARAM_RESET unset/reset values |
P |
setClearAB(boolean autoClear)
Set auto clear A-B all tag(when A-B finish) WARNING: If for special reasons cause A-B is
not finish, will don't auto clear.
|
void |
setCurrentPositionUnitIndex(int posUnitIndex)
generally not use(player inside Will automatically maintain current [position unit] index)
|
P |
setEnabledAudioFocusManage(boolean enabled) |
P |
setEnabledPositionUnitLoop(boolean enabled,
int loopMode,
int loopInterval)
Set the enabled,loopMode,loopInterval of this position unit loop, with reset position unit
looped count tag *param loopMode,loopInterval can use
C.PARAM_ORIGINAL keeping
the original values *param loopMode,loopInterval can use C.PARAM_UNSET /C.PARAM_RESET unset/reset values |
P |
setEnabledWifiLock(boolean enabled)
Set enabled wifi lock, to hold a Wifi lock, which prevents the player from going to sleep while
the media is playing.
|
void |
setMediaQueue(IMediaQueue mediaQueue)
set a new media queue for player
|
boolean |
setPlaybackSpeed(float speed) |
P |
setPositionUnitList(IPositionUnitList posUnitList)
WARNING: must ensure
IPositionUnitList.getMediaId() equals IPlayer.getCurrentMediaId()
can work normally |
P |
setPositionUnitLoopIndexList(java.util.ArrayList<java.lang.Integer> posUnitLoopIndexList)
WARNING: media source change with specify to loop of [position unit] index list will be reset
|
P |
setUpdatePlayProgressDelayMs(long updatePlayProgressDelayMs)
Sets the updatePlayProgress delay.
|
void |
setVideo(android.view.SurfaceView surfaceView) |
void |
setVideo(android.view.TextureView textureView) |
void |
setVolume(float volume)
Sets the volume, with 0 being silence and 1 being unity gain.
|
P |
shouldAutoPlayWhenSeekComplete(boolean shouldAutoPlayWhenSeekComplete)
Generally used in front of the seekTo...(.) to ensure that seek complete to auto play
immediately after
|
void |
shutdown()
Shut down player (release all resources)
|
boolean |
start() |
void |
stop() |
private PlayerService mService
private boolean mBound
private android.content.ServiceConnection mConnection
private final APlayerBinding.BindPlayer mBindPlayer
private APlayerBinding.BindingListener mBindingListener
protected final android.content.Context mContext
private final android.content.Intent mIntent
public APlayerBinding(android.content.Context context, java.lang.Class<PService> playerServiceClass, APlayerBinding.BindPlayer bindPlayer)
playerServiceClass
- *.class[extends PlayerService]bindPlayer
- new BindPlayer(){onBindPlayer()-> return Object[extends IPlayer]public APlayerBinding(android.content.Context context, java.lang.Class<PService> playerServiceClass, APlayerBinding.BindPlayer bindPlayer, APlayerBinding.BindingListener serviceConnected)
protected abstract P returnThis()
public class PlayerBinding extends APlayerBinding<PlayerBinding> { @Override protected PlayerBinding returnThis() { return this; } }
protected PlayerService service()
protected boolean isBound()
public void onDestroy()
public IPlayer player()
public boolean start()
start
in interface IPlayerBase
public boolean pause()
pause
in interface IPlayerBase
public boolean seekTo(long ms, int processingLevel)
IPlayer
seekTo
in interface IPlayer<P extends APlayerBinding>
processingLevel
- The greater the level with processing the more thingspublic boolean seekTo(long ms)
IPlayer
IPlayer.seekTo(long, int)
Max processing levelseekTo
in interface IPlayer<P extends APlayerBinding>
seekTo
in interface IPlayerBase
public boolean fastForwardRewind(long ms)
fastForwardRewind
in interface IPlayer<P extends APlayerBinding>
ms
- fastForwardMs/RewindMs public void stop()
stop
in interface IPlayerBase
public void reset()
reset
in interface IPlayerBase
public void release()
release
in interface IPlayerBase
public void setVideo(android.view.SurfaceView surfaceView)
setVideo
in interface IPlayerBase
public void setVideo(android.view.TextureView textureView)
setVideo
in interface IPlayerBase
public void clearVideo()
clearVideo
in interface IPlayerBase
public void setVolume(float volume)
IPlayerBase
setVolume
in interface IPlayerBase
public float getVolume()
IPlayerBase
getVolume
in interface IPlayerBase
public long getCurrentPosition()
getCurrentPosition
in interface IPlayerBase
public long getDuration()
getDuration
in interface IPlayerBase
public boolean isPlaying()
isPlaying
in interface IPlayerBase
public float getPlaybackSpeed()
getPlaybackSpeed
in interface IPlayerBase
public boolean setPlaybackSpeed(float speed)
setPlaybackSpeed
in interface IPlayerBase
public int getPlaybackState()
getPlaybackState
in interface IPlayerBase
STATE
constants defined public boolean isPlayable()
IPlayerBase
isPlayable
in interface IPlayerBase
public void addListener(IPlayer.Listener listener)
addListener
in interface IPlayer<P extends APlayerBinding>
listener
- IPlayer.Listener
PlayerListener
( ) IPlayer.Listener
public void removeListener(IPlayer.Listener listener)
removeListener
in interface IPlayer<P extends APlayerBinding>
listener
- param==null -> clear()public IMediaPlayer internalPlayer()
IPlayer
Player run core by internal maintaining mediaPlayer. In general is not recommended unless you want to operate some special functions. * note that internalPlayer and Player * at the same time operating possible when the incompatibilities
internalPlayer
in interface IPlayer<P extends APlayerBinding>
public P init(IMediaPlayer mediaPlayer)
IPlayer
init
in interface IPlayer<P extends APlayerBinding>
public boolean prepare(android.net.Uri uri)
prepare
in interface IPlayer<P extends APlayerBinding>
public boolean prepare(IMediaItem mediaItem)
prepare
in interface IPlayer<P extends APlayerBinding>
public boolean prepareMediaId(java.lang.String mediaId)
prepareMediaId
in interface IPlayer<P extends APlayerBinding>
public boolean play()
play
in interface IPlayer<P extends APlayerBinding>
public boolean play(android.net.Uri uri)
play
in interface IPlayer<P extends APlayerBinding>
public boolean play(IMediaItem mediaItem)
play
in interface IPlayer<P extends APlayerBinding>
public boolean playMediaId(java.lang.String mediaId)
playMediaId
in interface IPlayer<P extends APlayerBinding>
public void shutdown()
IPlayer
shutdown
in interface IPlayer<P extends APlayerBinding>
public P shouldAutoPlayWhenSeekComplete(boolean shouldAutoPlayWhenSeekComplete)
IPlayer
*IPlayerBase.start()
method with shouldAutoPlayWhenSeekComplete(true) *IPlayerBase.pause()
with shouldAutoPlayWhenSeekComplete(false)
shouldAutoPlayWhenSeekComplete
in interface IPlayer<P extends APlayerBinding>
public void seekToPending(long ms)
IPlayer
seekToPending
in interface IPlayer<P extends APlayerBinding>
public long seekToProgress(int progress, int progressMax)
IPlayer
seekToProgress
in interface IPlayer<P extends APlayerBinding>
progress
- current progressprogressMax
- the upper limit of this progress range.public P setUpdatePlayProgressDelayMs(long updatePlayProgressDelayMs)
IPlayer
setUpdatePlayProgressDelayMs
in interface IPlayer<P extends APlayerBinding>
updatePlayProgressDelayMs
- value>=0?value:default[1000 - (position % 1000)]public java.lang.String getCurrentMediaId()
IPlayer
getCurrentMediaId
in interface IPlayer<P extends APlayerBinding>
public P setEnabledWifiLock(boolean enabled)
IPlayer
<!--Using a WifiLock For KMedia Player--> <uses-permission android:name="android.permission.WAKE_LOCK"/>
setEnabledWifiLock
in interface IPlayer<P extends APlayerBinding>
public P setEnabledAudioFocusManage(boolean enabled)
setEnabledAudioFocusManage
in interface IPlayer<P extends APlayerBinding>
public AudioMgrHelper getAudioMgrHelper()
getAudioMgrHelper
in interface IPlayer<P extends APlayerBinding>
public P setPositionUnitList(IPositionUnitList posUnitList)
IPlayer
IPositionUnitList.getMediaId()
equals IPlayer.getCurrentMediaId()
can work normallysetPositionUnitList
in interface IPlayer<P extends APlayerBinding>
posUnitList
- [Position Unit] Listpublic int getCurrentPositionUnitIndex()
getCurrentPositionUnitIndex
in interface IPlayer<P extends APlayerBinding>
public void setCurrentPositionUnitIndex(int posUnitIndex)
IPlayer
If you want to calibrate,can call IPlayer.calibrateCurrentPositionUnitIndex(long)
setCurrentPositionUnitIndex
in interface IPlayer<P extends APlayerBinding>
public long seekToPositionUnitIndex(int posUnitIndex)
IPlayer
seekToPositionUnitIndex
in interface IPlayer<P extends APlayerBinding>
public int calibrateCurrentPositionUnitIndex(long position)
IPlayer
calibrateCurrentPositionUnitIndex
in interface IPlayer<P extends APlayerBinding>
position
- currentPosition or -1[position < 0 || position > getDuration()] (auto
getCurrentPosition())public P setEnabledPositionUnitLoop(boolean enabled, int loopMode, int loopInterval)
IPlayer
C.PARAM_ORIGINAL
keeping
the original values *param loopMode,loopInterval can use C.PARAM_UNSET
/C.PARAM_RESET
unset/reset valuessetEnabledPositionUnitLoop
in interface IPlayer<P extends APlayerBinding>
enabled
- True [position unit] loop is enabled, false otherwise.loopMode
- [Position unit] loop mode loopInterval
- [Position unit] loop intervalIPlayer.setUpdatePlayProgressDelayMs(long)
public P setPositionUnitLoopIndexList(java.util.ArrayList<java.lang.Integer> posUnitLoopIndexList)
IPlayer
setPositionUnitLoopIndexList
in interface IPlayer<P extends APlayerBinding>
posUnitLoopIndexList
- specify to loop of [position unit] index listpublic P setAB(long startPos, long endPos)
IPlayer
setAB
in interface IPlayer<P extends APlayerBinding>
startPos
- [A-B] start position (Ms)endPos
- [A-B] end position (Ms)IPlayer
!setAB but does not play. You must call play(?) to play.IPlayer.play()
,
IPlayer.play(Uri)
public P setABLoop(int loopMode, int loopInterval)
IPlayer
C.PARAM_ORIGINAL
keeping the
original values *param loopMode,loopInterval can use C.PARAM_UNSET
/C.PARAM_RESET
unset/reset valuessetABLoop
in interface IPlayer<P extends APlayerBinding>
loopMode
- [A-B] loop mode loopInterval
- [A-B] loop interval (S)IPlayer
!setAB but does not play. You must call play(?) to play.IPlayer.play()
,
IPlayer.play(Uri)
public P setAB(long startPos, long endPos, int loopMode, int loopInterval)
IPlayer
IPlayer.setAB(long, long)
, IPlayer.setABLoop(int, int)
*param loopMode,loopInterval can use C.PARAM_ORIGINAL
keeping the original values
*param loopMode,loopInterval can use C.PARAM_UNSET
/C.PARAM_RESET
unset/reset valuessetAB
in interface IPlayer<P extends APlayerBinding>
startPos
- [A-B] start position (Ms)endPos
- [A-B] end position (Ms)loopMode
- [A-B] loop mode loopInterval
- [A-B] loop interval (S)IPlayer
!setAB but does not play. You must call play(?) to play.IPlayer.play()
,
IPlayer.play(Uri)
public P setClearAB(boolean autoClear)
IPlayer
setClearAB
in interface IPlayer<P extends APlayerBinding>
IPlayer.clearAB()
public void clearAB()
IPlayer
clearAB
in interface IPlayer<P extends APlayerBinding>
IPlayer.setClearAB(boolean)
public void setMediaQueue(IMediaQueue mediaQueue)
IPlayer
setMediaQueue
in interface IPlayer<P extends APlayerBinding>
mediaQueue
- IMediaQueue
public IMediaQueue getMediaQueue()
IPlayer
IPlayer.setMediaQueue(IMediaQueue)
, it return default media queuegetMediaQueue
in interface IPlayer<P extends APlayerBinding>
IMediaQueue