Package com.brightcove.player.controller
Class DefaultSourceSelectionController
- java.lang.Object
-
- com.brightcove.player.event.AbstractComponent
-
- com.brightcove.player.controller.DefaultSourceSelectionController
-
- All Implemented Interfaces:
SourceSelector
,Component
- Direct Known Subclasses:
ExoPlayerSourceSelectionController
@ListensFor(events="selectSource") @Emits(events="sourceNotFound") public class DefaultSourceSelectionController extends AbstractComponent implements Component, SourceSelector
DefaultSourceSelector
controller responsible to react to theEventType.SELECT_SOURCE
event and callSourceSelector.selectSource(Video)
of theSourceSelector
set. By default,BrightcoveSourceSelector
is used.The selected
Source
will be added to theEventType.SELECT_SOURCE
event properties with theAbstractEvent.SOURCE
key.
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
TAG
-
Fields inherited from class com.brightcove.player.event.AbstractComponent
eventEmitter, listenerTokens
-
-
Constructor Summary
Constructors Constructor Description DefaultSourceSelectionController(EventEmitter eventEmitter)
Initializes this controller with the given EventEmitter using the defaultBrightcoveSourceSelector
.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static DefaultSourceSelectionController
create(EventEmitter eventEmitter)
Creates the Default Source Selection Controller using the defaultBrightcoveSourceSelector
.static DefaultSourceSelectionController
createWithSourceSelector(EventEmitter eventEmitter, SourceSelector sourceSelector)
Creates the Default Source Selection Controller with a customSourceSelector
.Source
findBestSourceByBitRate(SourceCollection sourceCollection, java.lang.Integer bitRate)
Given a SourceCollection, finds the Source with the closest bit rate to the given value.SourceSelector
getSourceSelector()
protected void
initializeListeners()
Source
selectSource(Video video)
Determines best appropriate Source within given Video object based on logic implemented.protected Source
selectSource(java.util.Set<Source> sources)
Attempts to select the HTTPS source included in the source Set, if available.void
setSourceSelector(SourceSelector sourceSelector)
-
Methods inherited from class com.brightcove.player.event.AbstractComponent
addListener, addOnceListener, getEventEmitter, removeListener, removeListeners
-
-
-
-
Constructor Detail
-
DefaultSourceSelectionController
public DefaultSourceSelectionController(@NonNull EventEmitter eventEmitter)
Initializes this controller with the given EventEmitter using the defaultBrightcoveSourceSelector
.- Parameters:
eventEmitter
- the EventEmitter through which this controller will interact
-
-
Method Detail
-
create
public static DefaultSourceSelectionController create(@NonNull EventEmitter eventEmitter)
Creates the Default Source Selection Controller using the defaultBrightcoveSourceSelector
.- Parameters:
eventEmitter
- the event emitter- Returns:
- the default source selection controller
-
createWithSourceSelector
public static DefaultSourceSelectionController createWithSourceSelector(@NonNull EventEmitter eventEmitter, @NonNull SourceSelector sourceSelector)
Creates the Default Source Selection Controller with a customSourceSelector
.- Parameters:
eventEmitter
- the event emittersourceSelector
- the source selector- Returns:
- the default source selection controller
-
setSourceSelector
public void setSourceSelector(@NonNull SourceSelector sourceSelector)
-
getSourceSelector
@NonNull public SourceSelector getSourceSelector()
-
selectSource
@NonNull public Source selectSource(@NonNull Video video) throws NoSourceFoundException
Description copied from interface:SourceSelector
Determines best appropriate Source within given Video object based on logic implemented.- Specified by:
selectSource
in interfaceSourceSelector
- Parameters:
video
- Video in which to find the most appropriate Source- Returns:
- the best matched Source based on the currently implemented selection logic
- Throws:
NoSourceFoundException
- when no validSource
is found- See Also:
SourceSelector.selectSource(com.brightcove.player.model.Video)
-
selectSource
@Nullable protected Source selectSource(@Nullable java.util.Set<Source> sources)
Attempts to select the HTTPS source included in the source Set, if available. Otherwise, it will select the first source given by the Set Iterator.It will return null if the sources Set is null or empty.
- Parameters:
sources
- the source Set.- Returns:
- the selected source
-
findBestSourceByBitRate
public Source findBestSourceByBitRate(SourceCollection sourceCollection, java.lang.Integer bitRate)
Given a SourceCollection, finds the Source with the closest bit rate to the given value.- Parameters:
sourceCollection
- the collection of Sources in which the match should be foundbitRate
- the target bit rate desired for the chosen Source- Returns:
- the Source that most closely matches the given bit rate, or any Source, if no match can be found
-
initializeListeners
protected void initializeListeners()
-
-