public final class StraasMediaCore extends Object
MediaBrowserCompat
for you to connect to the Straas MediaBrowserServiceCompat
,
also handles the video and ad rendering layers.
Don't forget to fill the SDK credential and the member Identity
.
Modifier and Type | Class and Description |
---|---|
static interface |
StraasMediaCore.DisplayMode |
static class |
StraasMediaCore.ErrorReason |
static class |
StraasMediaCore.ImaHelperBase |
static class |
StraasMediaCore.MediaCoreConfig
Configuration for the
StraasMediaCore |
static interface |
StraasMediaCore.PlaneProjectionMode |
static interface |
StraasMediaCore.UiContainer |
Modifier and Type | Field and Description |
---|---|
static int |
AD_PLAYBACK_ID
One of the id in
PlaybackStateCompat.getActiveQueueItemId() , means it is playing an ad now. |
static String |
COMMAND_DISABLE_AUDIO
Command to disable/re-enable audio output immediately and all future media playback.
|
static String |
COMMAND_FOREGROUND
Enable foreground flag, this will make the Straas
MediaBrowserServiceCompat run in
foreground when player state is not PlaybackStateCompat.STATE_PAUSED ,
PlaybackStateCompat.STATE_STOPPED , or PlaybackStateCompat.STATE_NONE . |
static String |
COMMAND_GET_LOCATION
Command to get the current
Location which is set by COMMAND_SET_LOCATION . |
static String |
COMMAND_GET_PLAYBACK_SPEED
Command for getting playback speed.
|
static String |
COMMAND_GET_VIDEO_FORMATS
Command for getting all video tracks formats.
|
static String |
COMMAND_PLAY_AT_LIVE_EDGE
Command to seek the current playback position to the real-time coverage of live (live edge)
and play automatically.
|
static String |
COMMAND_PLAYER_RETRY
Command to try again to play the last played media.
|
static String |
COMMAND_SET_FORMAT_INDEX
Action command for set new video format index.
|
static String |
COMMAND_SET_LOCATION
Action command to set the location information when a Straas media is playing.
|
static String |
COMMAND_SET_PLAYBACK_SPEED
Action command for set playback speed.
|
static String |
COMMAND_STOP_FOREGROUND
Remove the Straas
MediaBrowserServiceCompat from foreground state and clear the
Notification . |
static int |
DISPLAY_MODE_CARDBOARD
video frame is divided into two windows for left and right eye respectively,
useful when user put device into cardboard.
|
static int |
DISPLAY_MODE_NORMAL
video frame window is displayed normally.
|
static String |
DRM_KEY_REQUEST_PROPERTIES |
static String |
DRM_LICENSE_URL |
static String |
DRM_SCHEME_UUID_EXTRA |
static String |
EVENT_MEDIA_BROWSER_SERVICE_ERROR |
static String |
EVENT_PLAYER_ERROR_MESSAGE |
static String |
EVENT_TYPE |
static String |
EXTRA_CONTENT_TYPE
Extra Bundle key only if you want to use
playFromUri to
play content outside of Straas server storage without explicit filename extension (e.g. *.mp4, *.m3u8). |
static String |
EXTRA_IS_AUDIO_DISABLED
Deprecated.
use
VideoCustomMetadata.IS_AUDIO_DISABLED instead |
static String |
EXTRA_SERVICE_FOREGROUND_IS_ENABLED
Deprecated.
|
static String |
EXTRA_TEXT_TRACKS_INFO
Extra Bundle key .
|
static String |
ITEM_ID_PLAYLIST_PREFIX
Item id prefix to query a playlist info using
getItem . |
static String |
KEY_ALL_VIDEO_FORMATS
Bundle key in the result of
ResultReceiver.onReceiveResult(int, Bundle) to get all video tracks formats. |
static String |
KEY_CURRENT_PLAYBACK_SPEED
Bundle key in the result of
ResultReceiver.onReceiveResult(int, Bundle) to get and set playback speed. |
static String |
KEY_CURRENT_VIDEO_FORMAT_INDEX
Use this Bundle key to get and set current format index.
|
static String |
KEY_DISABLE_AUDIO
Use this Bundle key to set whether the audio output should be disabled or not to the Straas
MediaBrowserServiceCompat . |
static String |
KEY_EXTRA_TEXT_TRACKS
Deprecated.
use
VideoCustomMetadata.KEY_TEXT_TRACKS instead |
static String |
KEY_LOCATION
The Bundle key to set or get the
Location . |
static String |
KEY_MEDIA_BROWSER_ERROR_MESSAGE |
static String |
KEY_MEDIA_BROWSER_ERROR_REASON |
static String |
KEY_NOTIFICATION_OPTIONS
Use this Bundle key to set a
NotificationOptions to the Straas MediaBrowserServiceCompat . |
static String |
KEY_PAGE_TOKEN
Bundle key we put in the last
MediaBrowserCompat.MediaItem of a list to indicate what next parent id is. |
static String |
KEY_VIDEO_RENDER_TYPE
Extra Bundle key only if you want to use
playFromUri to
play content outside of Straas server storage and want to control different render type. |
static String |
LIVE_EXTRA_BROADCAST_START_TIME
Deprecated.
use
VideoCustomMetadata.LIVE_BROADCAST_START_TIME instead |
static String |
LIVE_EXTRA_BROADCAST_STATE
Deprecated.
use
VideoCustomMetadata.LIVE_BROADCAST_STATE_V2 instead |
static String |
LIVE_EXTRA_BROADCAST_STATE_LIVE
Bundle value for indicate that the broadcast status of the live event is on LIVE now.
|
static String |
LIVE_EXTRA_BROADCAST_STATE_V2
Deprecated.
use
VideoCustomMetadata.LIVE_BROADCAST_STATE_V2 instead |
static String |
LIVE_EXTRA_BROADCAST_STATE_WAIT_STREAM
Bundle value for indicate that the live event meets a trouble now, our server is waiting for
the streaming.
|
static String |
LIVE_EXTRA_CURRENT_DATE_TIME
Bundle key in
PlaybackStateCompat extra to indicate the current live date time from HLS EXT-X-PROGRAM-DATE-TIME tag. |
static String |
LIVE_EXTRA_EVENT_STATE
Deprecated.
use
VideoCustomMetadata.LIVE_BROADCAST_STATE_V2 instead |
static String |
LIVE_EXTRA_EVENT_STATE_ENDED
Bundle value for indicate that the live event is ended.
|
static String |
LIVE_EXTRA_EVENT_STATE_READY
Bundle value for indicate that the live event is ready to broadcast.
|
static String |
LIVE_EXTRA_EVENT_STATE_STARTED
Bundle value for indicate that the live event is on LIVE now, while the the broadcast status
may be
LIVE_EXTRA_BROADCAST_STATE_LIVE or LIVE_EXTRA_BROADCAST_STATE_WAIT_STREAM . |
static String |
LIVE_EXTRA_STATISTICS_CCU
Deprecated.
use
VideoCustomMetadata.LIVE_STATISTICS_CCU instead |
static String |
LIVE_EXTRA_STATISTICS_HIT_COUNT
Deprecated.
|
static String |
LIVE_ID_PREFIX
Item id prefix to query or play a live event info.
|
static String |
PARENT_ID_LIVES
Parent id to subscribe all available public live event list.
|
static String |
PARENT_ID_VODS
Parent id to subscribe all available public VOD (video on demand) list.
|
static int |
PLANE_PROJECTION_MODE_CROP
video frame is scaled to fill the size of the view by
maintaining the aspect ratio.
|
static int |
PLANE_PROJECTION_MODE_FIT
video frame is scaled to fit the size of the view by
maintaining the aspect ratio (black borders may be displayed).
|
static int |
PLANE_PROJECTION_MODE_FULL
The specified aspect ratio is ignored.
|
static String |
PLAY_OPTION_HLS_LIVE_SYNC_INTERVAL_COUNT
Extra Bundle key in
playFromMediaId . |
static String |
PLAY_OPTION_LIVE_LOW_LATENCY
Extra Bundle key in
playFromMediaId
which could significantly reduce the latency between broadcaster and viewers
if set the Bundle value to true, but the adaptive bitrate will be disabled. |
static String |
PLAY_OPTION_SEEK_TIME
Extra Bundle key only if you need to seek to the specific timestamp at start.
|
static String |
SUBSCRIBE_CHILDREN_OPTIONS_CATEGORY_IDS
Bundle key when
subscribing
to a parent id with an optional Bundle. |
static String |
SUBSCRIBE_CHILDREN_OPTIONS_OWNER_MEMBER_ID
Bundle key when
subscribing
to a parent id with an optional Bundle. |
static String |
SUBSCRIBE_CHILDREN_OPTIONS_SORT
Bundle key when
subscribing
to a parent id with an optional Bundle. |
static String |
SUBSCRIBE_CHILDREN_OPTIONS_STATUS
Bundle key when
subscribing
to a parent id with an optional Bundle. |
static String |
SUBSCRIBE_CHILDREN_OPTIONS_TYPES
Bundle key when
subscribing
to a parent id with an optional Bundle. |
static int |
VIDEO_RENDER_TYPE_360 |
static int |
VIDEO_RENDER_TYPE_NONE |
static int |
VIDEO_RENDER_TYPE_PLAIN |
Constructor and Description |
---|
StraasMediaCore(Identity identity,
MediaBrowserCompat.ConnectionCallback callback)
Create a
MediaBrowserCompat which could get through getMediaBrowser() . |
StraasMediaCore(StraasMediaCore.MediaCoreConfig config)
Create a
MediaBrowserCompat which could get through getMediaBrowser() . |
StraasMediaCore(StraasMediaCore.UiContainer uiContainer,
Identity identity,
MediaBrowserCompat.ConnectionCallback callback)
Create a
MediaBrowserCompat which could get through getMediaBrowser() . |
Modifier and Type | Method and Description |
---|---|
int |
getDisplayMode() |
MediaBrowserCompat |
getMediaBrowser()
This instance reference MAY change any time, DO-NOT keep this reference.
|
MediaControllerCompat |
getMediaController() |
int |
getPlaneProjectionMode() |
void |
setDisplayMode(int displayMode)
Set how video frame window is displayed.
|
void |
setIdentity(Identity identity)
Set a new identity after MediaBrowser is connected.
|
StraasMediaCore |
setImaHelper(StraasMediaCore.ImaHelperBase imaHelper)
Optional API only if you need Interactive Media Ad integration.
|
void |
setPlaneProjectionMode(int planeProjectionMode)
Set projection mode when render type is
VIDEO_RENDER_TYPE_PLAIN which is a plain instead of sphere. |
StraasMediaCore |
setUiContainer(StraasMediaCore.UiContainer uiContainer)
Optional API only if you didn't put it at constructor, or you want to change the container target.
|
public static final String KEY_ALL_VIDEO_FORMATS
ResultReceiver.onReceiveResult(int, Bundle)
to get all video tracks formats.public static final String KEY_CURRENT_VIDEO_FORMAT_INDEX
public static final String COMMAND_SET_FORMAT_INDEX
public static final String COMMAND_GET_VIDEO_FORMATS
public static void getVideoQualityInfo(MediaControllerCompat controller) {
controller.sendCommand(COMMAND_GET_VIDEO_FORMATS, null,
new ResultReceiver(new Handler()) {
@Override
protected void onReceiveResult(int resultCode, Bundle resultData) {
resultData.setClassLoader(Format.class.getClassLoader());
if (resultData.containsKey(KEY_CURRENT_VIDEO_FORMAT_INDEX)) {
// all video tracks formats
ArrayList<Format>
formats = resultData
.getParcelableArrayList(KEY_ALL_VIDEO_FORMATS);
// current format index of formats
int selectedIndex = resultData.getInt(KEY_CURRENT_VIDEO_FORMAT_INDEX);
}
}
});
}
public static final String KEY_CURRENT_PLAYBACK_SPEED
ResultReceiver.onReceiveResult(int, Bundle)
to get and set playback speed.public static final String COMMAND_GET_PLAYBACK_SPEED
public static final String COMMAND_SET_PLAYBACK_SPEED
public static final String KEY_NOTIFICATION_OPTIONS
NotificationOptions
to the Straas MediaBrowserServiceCompat
.public static final String COMMAND_FOREGROUND
MediaBrowserServiceCompat
run in
foreground when player state is not PlaybackStateCompat.STATE_PAUSED
,
PlaybackStateCompat.STATE_STOPPED
, or PlaybackStateCompat.STATE_NONE
.
You can use KEY_NOTIFICATION_OPTIONS
and NotificationOptions
to set some
options of the Notification
.public static final String COMMAND_STOP_FOREGROUND
MediaBrowserServiceCompat
from foreground state and clear the
Notification
.public static final String COMMAND_DISABLE_AUDIO
There are some important things you should notice when using this command:
MediaBrowserServiceCompat
run in foreground by using COMMAND_FOREGROUND
while
the audio output is disabled, we will force re-enable the audio output.MediaBrowserServiceCompat
runs in foreground will be no-op.
A warning message will show up in the logcat instead.
public static void disableAudio(MediaControllerCompat controller, boolean disable) {
Bundle bundle = new Bundle();
bundle.putBoolean(KEY_DISABLE_AUDIO, disable);
controller.getTransportControls().sendCustomAction(COMMAND_DISABLE_AUDIO, bundle);
}
public static final String COMMAND_PLAY_AT_LIVE_EDGE
This command won't work under the following conditions:
VideoCustomMetadata.LIVE_DVR_ENABLED
is false VideoCustomMetadata.CUSTOM_METADATA_IS_LIVE_LOW_LATENCY
is true public static final String COMMAND_PLAYER_RETRY
NOTE: This command is in BETA stage and might be deprecated in the later version.
public static final String COMMAND_SET_LOCATION
KEY_LOCATION
as the Bundle key to set the Location
.public static final String COMMAND_GET_LOCATION
Location
which is set by COMMAND_SET_LOCATION
.
Use KEY_LOCATION
as the Bundle key to get the Location
.public static final String KEY_LOCATION
@Deprecated public static final String EXTRA_IS_AUDIO_DISABLED
VideoCustomMetadata.IS_AUDIO_DISABLED
insteadMediaSessionCompat
extra to indicate whether the audio output is disabled.
Bundle value is boolean
type, the default value is false
.
For client side, use MediaControllerCompat.getExtras()
or register callback via
MediaControllerCompat.registerCallback(Callback)
to get extras.
public static final String KEY_DISABLE_AUDIO
MediaBrowserServiceCompat
.
Bundle value is boolean
type, true
means the audio output will be disabled.@Deprecated public static final String EXTRA_SERVICE_FOREGROUND_IS_ENABLED
VideoCustomMetadata.SERVICE_FOREGROUND_IS_ENABLED
insteadMediaSessionCompat
extra to get the boolean value that indicates the
foreground mode is enabled or not. If foreground mode is enabled, the Straas
MediaBrowserServiceCompat
will run in foreground when player state is not
PlaybackStateCompat.STATE_PAUSED
, PlaybackStateCompat.STATE_STOPPED
, or
PlaybackStateCompat.STATE_NONE
.
For client side, use MediaControllerCompat.getExtras()
or register callback via
MediaControllerCompat.registerCallback(Callback)
to get extras.
public static final String EXTRA_CONTENT_TYPE
playFromUri
to
play content outside of Straas server storage without explicit filename extension (e.g. *.mp4, *.m3u8).
The content type value mapping is the same as ExoPlayer:
public static void playContentType(MediaControllerCompat controller, Uri uri, int type) {
Bundle bundle = new Bundle();
switch (type) {
case C.TYPE_HLS:
case C.TYPE_DASH:
case C.TYPE_SS:
case C.TYPE_OTHER:
bundle.putInt(EXTRA_CONTENT_TYPE, type);
break;
default:
throw new IllegalArgumentException("Must be one of TYPE_HLS, TYPE_DASH, TYPE_SS, TYPE_OTHER");
}
controller.getTransportControls().playFromUri(uri, bundle);
}
public static final String EXTRA_TEXT_TRACKS_INFO
public static final String KEY_PAGE_TOKEN
MediaBrowserCompat.MediaItem
of a list to indicate what next parent id is.
Use the value to subscribe
and you will get the next page content.
public static String extractPageToken(@NonNull List<MediaItem> items) {
return items.get(items.size() - 1)
.getDescription().getExtras().getString(KEY_PAGE_TOKEN);
}
public void onLoadMore() {
String pageToken = extractPageToken(mAdapter.getMediaItems());
if (!TextUtils.isEmpty(pageToken)) {
getMediaBrowser().subscribe(pageToken, mSubscriptionCallback);
}
}
public static final String PLAY_OPTION_SEEK_TIME
During the playback you could use MediaControllerCompat.TransportControls.seekTo(long)
.
public static void playAndSeekFromMediaId(MediaControllerCompat controller, String mediaId, long positionMs) {
Bundle bundle = new Bundle();
bundle.putLong(PLAY_OPTION_SEEK_TIME, positionMs);
controller.getTransportControls().playFromMediaId(mediaId, bundle);
}
public static final String PLAY_OPTION_LIVE_LOW_LATENCY
playFromMediaId
which could significantly reduce the latency between broadcaster and viewers
if set the Bundle value to true, but the adaptive bitrate will be disabled.public static final String PLAY_OPTION_HLS_LIVE_SYNC_INTERVAL_COUNT
playFromMediaId
.
The value type is int. It decides which ts file in a m3u8 of HLS spec to play in the beginning.
The value 0 means to play the latest ts file, and the value 3 means to play the 3rd one.
You can only set this to 2 or 3, and the default value is 3.
This only works when the media type is live and the Bundle value of PLAY_OPTION_LIVE_LOW_LATENCY
is false.public static final int AD_PLAYBACK_ID
PlaybackStateCompat.getActiveQueueItemId()
, means it is playing an ad now.public static final String EVENT_TYPE
public static final String EVENT_PLAYER_ERROR_MESSAGE
public static final String EVENT_MEDIA_BROWSER_SERVICE_ERROR
public static final String KEY_MEDIA_BROWSER_ERROR_REASON
public static final String KEY_MEDIA_BROWSER_ERROR_MESSAGE
public static final String KEY_VIDEO_RENDER_TYPE
playFromUri
to
play content outside of Straas server storage and want to control different render type.
public static void playWithRenderType(MediaControllerCompat controller, Uri uri, int type) {
Bundle bundle = new Bundle();
switch (type) {
case VIDEO_RENDER_TYPE_360:
case VIDEO_RENDER_TYPE_PLAIN:
bundle.putInt(KEY_VIDEO_RENDER_TYPE, type);
break;
default:
bundle.putInt(KEY_VIDEO_RENDER_TYPE, VIDEO_RENDER_TYPE_PLAIN);
break;
}
controller.getTransportControls().playFromUri(uri, bundle);
}
public static final int VIDEO_RENDER_TYPE_NONE
KEY_VIDEO_RENDER_TYPE
,
Constant Field Valuespublic static final int VIDEO_RENDER_TYPE_PLAIN
public static final int VIDEO_RENDER_TYPE_360
public static final String ITEM_ID_PLAYLIST_PREFIX
getItem
.public static final String LIVE_ID_PREFIX
public static final String PARENT_ID_LIVES
MediaBrowserCompat.MediaItem.getDescription()
with
VideoCustomMetadata.LIVE_BROADCAST_STATE_V2
key.
If you subscribe live event list without given sort
option, the default
sorting type will be "-start_time
".public static final String PARENT_ID_VODS
sort
option, the default
sorting type will be "-created_at
".public static final String SUBSCRIBE_CHILDREN_OPTIONS_SORT
subscribing
to a parent id with an optional Bundle. You must use putString
to set the sorting type
depends on what kinds of parent id you want to subscribe. This value denote how to sort the children list data.
e.g. "-created_at
"public static final String SUBSCRIBE_CHILDREN_OPTIONS_OWNER_MEMBER_ID
subscribing
to a parent id with an optional Bundle. You must use putString
to set the owner member id filter
to query partial children list data belonging to the specific owner only.
Empty value denotes disabling this filter.public static final String SUBSCRIBE_CHILDREN_OPTIONS_CATEGORY_IDS
subscribing
to a parent id with an optional Bundle. You must use putString
to set the category ids filter to query partial children list data belonging to the specific
categories.
Empty value denotes disabling this filter.
e.g. "1,3,5
"public static final String SUBSCRIBE_CHILDREN_OPTIONS_TYPES
subscribing
to a parent id with an optional Bundle. You must use putString
to set the types filter to query partial live list data belonging to the specific types.
Empty value denotes disabling this filter.
This option is only for live events
.
e.g. "event,channel
" for live eventpublic static final String SUBSCRIBE_CHILDREN_OPTIONS_STATUS
subscribing
to a parent id with an optional Bundle. You must use putString
to set the status filter to query partial live list data belonging to the specific status.
Empty value denotes disabling this filter.
This option is only for live events
.
e.g. "ready,ended
"@Deprecated public static final String LIVE_EXTRA_BROADCAST_START_TIME
VideoCustomMetadata.LIVE_BROADCAST_START_TIME
insteadLIVE_EXTRA_BROADCAST_STATE
,
Constant Field Values@Deprecated public static final String LIVE_EXTRA_BROADCAST_STATE
VideoCustomMetadata.LIVE_BROADCAST_STATE_V2
insteadMediaSessionCompat
extra to indicate the broadcast status of the live event.
For client side, use MediaControllerCompat.getExtras()
or register callback via
MediaControllerCompat.registerCallback(Callback)
to get extras.
If extra Bundle don't have this key, of the value is empty, means that the live event is offline,
otherwise, the value will be either LIVE_EXTRA_BROADCAST_STATE_LIVE
or
LIVE_EXTRA_BROADCAST_STATE_WAIT_STREAM
.
@Deprecated public static final String LIVE_EXTRA_BROADCAST_STATE_V2
VideoCustomMetadata.LIVE_BROADCAST_STATE_V2
insteadMediaSessionCompat
extra to indicate the broadcast status of the
live event(v2).
For client side, use MediaControllerCompat.getExtras()
or register callback via
MediaControllerCompat.registerCallback(Callback)
to get extras.
The value must be one of the following:
public static final String LIVE_EXTRA_BROADCAST_STATE_LIVE
public static final String LIVE_EXTRA_BROADCAST_STATE_WAIT_STREAM
LIVE_EXTRA_BROADCAST_STATE_LIVE
or offline.@Deprecated public static final String LIVE_EXTRA_EVENT_STATE
VideoCustomMetadata.LIVE_BROADCAST_STATE_V2
insteadMediaControllerCompat.getExtras()
or register callback via
MediaControllerCompat.registerCallback(Callback)
to get extras.
The state value must be one of the following:
public static final String LIVE_EXTRA_EVENT_STATE_ENDED
public static final String LIVE_EXTRA_EVENT_STATE_READY
public static final String LIVE_EXTRA_EVENT_STATE_STARTED
LIVE_EXTRA_BROADCAST_STATE_LIVE
or LIVE_EXTRA_BROADCAST_STATE_WAIT_STREAM
.@Deprecated public static final String LIVE_EXTRA_STATISTICS_CCU
VideoCustomMetadata.LIVE_STATISTICS_CCU
insteadMediaSessionCompat
extra to indicate the concurrent users of the live event.
For client side, use MediaControllerCompat.getExtras()
or register callback via
registerCallback(...)
and listen either
onSessionEvent
or onExtrasChanged
to get real-time value change. Both the event name and the Bundle
key is this constant, value is an integer.@Deprecated public static final String LIVE_EXTRA_STATISTICS_HIT_COUNT
MediaSessionCompat
extra to indicate the media hit count of the live event.
For client side, use MediaControllerCompat.getExtras()
or register callback via
registerCallback(...)
and listen either
onSessionEvent
or onExtrasChanged
to get real-time value change. Both the event name and the Bundle
key is this constant, value is an integer.@Deprecated public static final String KEY_EXTRA_TEXT_TRACKS
VideoCustomMetadata.KEY_TEXT_TRACKS
insteadMediaSessionCompat
extra to indicate the subtitle list.
For client side, use MediaControllerCompat.getExtras()
or register callback via
registerCallback(...)
and listen
onExtrasChanged
to get real-time value change. Both the event name and the Bundle
key is this constant, value is string which can convert to subtitle list.public static final String LIVE_EXTRA_CURRENT_DATE_TIME
PlaybackStateCompat
extra to indicate the current live date time from HLS EXT-X-PROGRAM-DATE-TIME tag.
For client side, use PlaybackStateCompat.getExtras()
to inference live date time according to current position.public static final String DRM_SCHEME_UUID_EXTRA
public static final String DRM_LICENSE_URL
public static final String DRM_KEY_REQUEST_PROPERTIES
public static final int DISPLAY_MODE_NORMAL
public static final int DISPLAY_MODE_CARDBOARD
public static final int PLANE_PROJECTION_MODE_FIT
public static final int PLANE_PROJECTION_MODE_CROP
public static final int PLANE_PROJECTION_MODE_FULL
public StraasMediaCore(@NonNull StraasMediaCore.MediaCoreConfig config)
MediaBrowserCompat
which could get through getMediaBrowser()
.config
- configuration of the StraasMediaCorepublic StraasMediaCore(@NonNull Identity identity, @NonNull MediaBrowserCompat.ConnectionCallback callback)
MediaBrowserCompat
which could get through getMediaBrowser()
.identity
- The user who connecting to the Straas MediaBrowserServiceCompat
.
If you want to change the identity later, use setIdentity(Identity)
after
MediaBrowserCompat
is connected.callback
- The callback which will tell you whether the MediaBrowserCompat
is connected
or not. If you get MediaBrowserCompat.ConnectionCallback.onConnectionFailed()
, normally
causing by getting the CredentialFailException
, checkout logcat first.public StraasMediaCore(@NonNull StraasMediaCore.UiContainer uiContainer, @NonNull Identity identity, @NonNull MediaBrowserCompat.ConnectionCallback callback)
MediaBrowserCompat
which could get through getMediaBrowser()
.
Use this constructor, you don't have to call setUiContainer(UiContainer)
again
unless you want to reset the container target.
uiContainer
- The container which renders the video track. Normally just put the StraasPlayerView.
You could reset the container target later using setUiContainer(UiContainer)
.identity
- The user who connecting to the Straas MediaBrowserServiceCompat
.
If you want to change the identity later, use setIdentity(Identity)
after
MediaBrowserCompat
is connected.callback
- The callback which will tell you whether the MediaBrowserCompat
is connected
or not. If you get MediaBrowserCompat.ConnectionCallback.onConnectionFailed()
, normally
causing by getting the CredentialFailException
, checkout logcat first.public void setDisplayMode(int displayMode)
displayMode
- when put device into cardboard, set to {DISPLAY_MODE_CARDBOARD
}public int getPlaneProjectionMode()
public int getDisplayMode()
public void setPlaneProjectionMode(int planeProjectionMode)
VIDEO_RENDER_TYPE_PLAIN
which is a plain instead of sphere.planeProjectionMode
- default is PLANE_PROJECTION_MODE_FIT
public void setIdentity(Identity identity)
getMediaBrowser()
is connected, or you will receive IllegalStateException
.identity
- The new identity.Identity
,
#StraasMediaCore(UiContainer, Identity, ConnectionCallback)
,
#StraasMediaCore(Identity, ConnectionCallback)
@Nullable public MediaControllerCompat getMediaController()
MediaBrowserCompat.ConnectionCallback.onConnected()
, you could get a non-null MediaControllerCompat
,
or build your own MediaControllerCompat
through MediaBrowserCompat.getSessionToken()
.public StraasMediaCore setUiContainer(@Nullable StraasMediaCore.UiContainer uiContainer)
uiContainer
- The player view which video and ad will render within it.
Use StraasPlayerView is the best choice or you want to implement your self.#StraasMediaCore(UiContainer, Identity, ConnectionCallback)
public StraasMediaCore setImaHelper(@NonNull StraasMediaCore.ImaHelperBase imaHelper)
Include extension-ima library and give us the ImaHelper.newInstance().
imaHelper
- ImaHelper.newInstance()@NonNull public MediaBrowserCompat getMediaBrowser()
getMediaBrowser()
.MediaBrowserCompat
. Use it to connect to the Straas
MediaBrowserServiceCompat
.