Android Migration Reference (Android)
Explore JW Player's new Android SDK v4.
Configuration API
The Configuration API is largely the same between 3.x and 4.x. There are some important differences.
In SDK 4.x, all configuration classes have the following qualities:
- Immutable (for example,. thread-safe)
- Constructed using a Builder
Below is a list of the differences between each 3.x and 4.x configuration class.
AdBreak
3.x | 4.x | Notes |
---|---|---|
AdBreak(AdBreak src) | Removed constructor Use Builder() instead | |
AdBreak(java.lang.String offset, AdSource adSource, java.lang.String | Removed constructor Use Builder() instead | |
cloneList(java.util.List | Removed utility method | |
equals(java.lang.Object obj) | equals(java.lang.Object obj) | Does not currently override default equals() method |
getSource() | Removed fieldAdClient is now defined in the AdvertisingConfig object | |
hashCode() | hashCode() | Does not currently override default equals() method |
parseJson(java.lang.String jsonStr) | No longer serializes to JSON | |
parseJson(org.json.JSONObject json) | No longer serializes to JSON | |
setSource(AdSource adSource) | Removed fieldAdClient is now defined in the AdvertisingConfig object | |
toJson() | No longer serializes to JSON | |
- - - | describeContents() | Now implements Parcelable interface |
- - - | writeToParcel(android.os.Parcel dest, int flags) | Now implements Parcelable interface |
AdRules
3.x | 4.x | Notes |
---|---|---|
AdRules(AdRules src)Copy constructor | Removed constructor Use Builder() instead | |
parseJson(org.json.JSONObject json) | No longer serializes to JSON | |
parseJson(java.lang.String json) | No longer serializes to JSON | |
toJson() | No longer serializes to JSON | |
- - - | describeContents() | Now implements Parcelable interface |
- - - | writeToParcel(android.os.Parcel dest, int flags) | Now implements Parcelable interface |
AdSource
Renamed to AdClient
3.x | 4.x | Notes |
---|---|---|
AdSource | AdClient | Renamed Enum |
Advertising
Renamed to VastAdvertisingConfig
3.x | 4.x | Notes |
---|---|---|
Advertising(AdSource client, java.util.List | Removed constructor Use Builder() insteadRemoved utility method | |
Advertising(Advertising src) | Removed constructor Use Builder() insteadRemoved utility method | |
copy() | Removed utility method | |
getClient() | getAdClient() | Renamed |
setAdMessage() | Removed setters. Object is immutable. Use Builder() instead | |
setAdRules() | Removed setters. Object is immutable. Use Builder() instead | |
setClient() | Removed setters. Object is immutable. Use Builder() instead | |
setConditionalAdOptOut(java.lang.Boolean conditionalAdOptOut) | Removed setters. Object is immutable. Use Builder() instead | |
setCreativeTimeout(java.lang.Integer creativeTimeout) | Removed setters. Object is immutable. Use Builder() instead | |
setCueText() | Removed setters. Object is immutable. Use Builder() instead | |
setPodMessage(java.lang.String podMessage) | Removed setters. Object is immutable. Use Builder() instead | |
setRequestTimeout() | Removed setters. Object is immutable. Use Builder() instead | |
setSchedule(java.util.List | Removed setters. Object is immutable. Use Builder() instead | |
setSkipMessage() | Removed setters. Object is immutable. Use Builder() instead | |
setSkipOffset() | Removed setters. Object is immutable. Use Builder() instead | |
setSkipText() | Removed setters. Object is immutable. Use Builder() instead | |
setVpaidControls() | Removed setters. Object is immutable. Use Builder() instead | |
toJson() | No longer serializes to JSON |
AudioTrack
3.x | 4.x | Notes |
---|---|---|
parseJson(org.json.JSONObject audioJson) | No longer serializes to JSON | |
toJson() | No longer serializes to JSON | |
- - - | describeContents() | Now implements Parcelable interface |
- - - | writeToParcel(android.os.Parcel dest, int flags) | Now implements Parcelable interface |
Caption
3.x | 4.x | Notes |
---|---|---|
Caption(Caption source) | Removed copy constructor Use Builder() instead | |
cloneList(java.util.List | ||
Removed utility method | ||
listFromJson(java.lang.String json) | No longer serializes to JSON | |
listFromJson(org.json.JSONArray json) | No longer serializes to JSON | |
parseJson(java.lang.String json) | No longer serializes to JSON | |
parseJson(org.json.JSONObject json) | No longer serializes to JSON | |
toJson() | No longer serializes to JSON | |
- - - | describeContents() | Now implements Parcelable interface |
- - - | writeToParcel(android.os.Parcel dest, int flags) | Now implements Parcelable interface |
CaptionsConfig
3.x | 4.x | Notes |
---|---|---|
CaptionsConfig | Removed the class. Users configure caption styling at the device level instead. |
ExternalMetadata
3.x | 4.x | Notes |
---|---|---|
cloneList(java.util.List | No longer implements Jsonable interface | |
ExternalMetadata(ExternalMetadata other) | Removed copy constructor | |
parseJson(org.json.JSONObject json) | No longer implements Jsonable interface | |
toJson() | No longer implements Jsonable interface | |
- - - | describeContents() | Now implements Parcelable interface |
- - - | writeToParcel(android.os.Parcel dest, int flags) | Now implements Parcelable interface |
ImaAdvertising
Renamed to ImaAdvertisingConfig
3.x | 4.x | Notes |
---|---|---|
copy() | Removed utility method | |
getAdMessage() | Removed getter. Unused field. | |
getAdRules() | Removed getter. Unused field. | |
getClient() | getAdClient() | Renamed |
getConditionalAdOptOut() | Removed getter. Unused field. | |
getCreativeTimeout() | Removed getter. Unused field. | |
getCueText() | Removed getter. Unused field. | |
getPodMessage() | Removed getter. Unused field. | |
getSkipMessage() | Removed getter. Unused field. | |
getSkipOffset() | Removed getter. Unused field. | |
getSkipText() | Removed getter. Unused field. | |
getVpaidControls() | Removed getter. Unused field. | |
ImaAdvertising(ImaAdvertising src) | Removed copy constructor Use Builder() instead | |
ImaAdvertising(java.util.List | Removed copy constructor Use Builder() instead | |
ImaAdvertising(java.util.List | Removed copy constructor Use Builder() instead | |
setAdMessage() | Removed setter. Unused field | |
setAdRules() | Removed setter. Unused field | |
setClient() | Removed setters. Object is immutable. Use Builder() instead | |
setConditionalAdOptOut() | Removed setter. Unused field | |
setCreativeTimeout() | Removed setter. Unused field | |
setCueText() | Removed setter. Unused field | |
setImaSdkSettings(com.google.ads.interactivemedia.v3.api.ImaSdkSettings imaSdkSettings) | Removed setters. Object is immutable. Use Builder() instead | |
setPodMessage() | Removed setter. Unused field | |
setRequestTimeout() | Removed setter. Unused field | |
setSchedule() | Removed setters. Object is immutable. Use Builder() instead | |
setSkipMessage() | Removed setter. Unused field | |
setSkipOffset() | Removed setter. Unused field | |
setSkipText() | Removed setter. Unused field | |
setVpaidControls() | Removed setter. Unused field | |
toJson() | No longer serializes to JSON |
ImaDaiAdvertising
Renamed to ImaDaiAdvertisingConfig
3.x | 4.x | Notes |
---|---|---|
copy() | Removed utility method | |
getAdMessage() | Removed getter. Unused field | |
getAdRules() | Removed getter. Unused field | |
getClient() | getAdClient() | Renamed |
getCueText() | Removed getter. Unused field | |
getRequestTimeout() | Removed getter. Unused field | |
getSkipMessage() | Removed getter. Unused field | |
getSkipOffset() | Removed getter. Unused field | |
getSkipText() | Removed getter. Unused field | |
getVpaidControls() | Removed getter. Unused field | |
ImaDaiAdvertising(ImaDaiAdvertising src) | Removed constructor. Use Builder() instead | |
ImaDaiAdvertising(ImaDaiSettings imaDaiSettings) | Removed constructor. Use Builder() instead | |
setAdMessage() | Removed setter. Unused field | |
setAdRules() | Removed setter. Unused field | |
setClient() | Removed setter. Object is immutable. Use Builder() instead | |
setCueText() | Removed setter. Unused field | |
setImaDaiSettings(ImaDaiSettings settings) | Removed setter. Object is immutable. Use Builder() instead | |
setRequestTimeout() | Removed setter. Unused field | |
setSkipMessage() | Removed setter. Unused field | |
setSkipOffset() | Removed setter. Unused field | |
setSkipText() | Removed setter. Unused field | |
setVpaidControls() | Removed setter. Unused field | |
toJson() | No longer serializes to JSON |
ImaDaiSettings
3.x | 4.x | Notes |
---|---|---|
--- | setAdTagParameters(Map<String,String>) | Added |
--- | Map<String, String> getAdTagParameters | Added |
ImaVMAPAdvertising
Renamed to ImaVmapAdvertisingConfig
3.x | 4.x | Notes |
---|---|---|
copy() | Removed utility method | |
getAdMessage() | Removed getter. Unused field | |
getAdRules() | Removed getter. Unused field | |
getClient() | getAdClient() | Renamed |
getCueText() | Removed getter. Unused field | |
getRequestTimeout() | Removed getter. Unused field | |
getSkipMessage() | Removed getter. Unused field | |
getSkipOffset() | Removed getter. Unused field | |
getSkipText() | Removed getter. Unused field | |
getVpaidControls() | Removed getter. Unused field | |
ImaVMAPAdvertising(ImaVMAPAdvertising src) | Removed constructor Use Builder() instead | |
ImaVMAPAdvertising(java.lang.String tag) | Removed constructor Use Builder() instead | |
ImaVMAPAdvertising(java.lang.String tag, com.google.ads.interactivemedia.v3.api.ImaSdkSettings imaSdkSettings) | Removed constructor Use Builder() instead | |
setClient() | Removed setter. Object is immutable. Use Builder() instead | |
setAdMessage() | Removed setter. Unused field | |
setAdRules() | Removed setter. Unused field | |
setCueText() | Removed setter. Unused field | |
setImaSdkSettings(com.google.ads.interactivemedia.v3.api.ImaSdkSettings imaSdkSettings) | Removed setter. Object is immutable. Use Builder() instead | |
setRequestTimeout() | Removed setter. Unused field | |
setSkipMessage() | Removed setter. Unused field | |
setSkipOffset() | Removed setter. Unused field | |
setSkipText() | Removed setter. Unused field | |
setTag() | Removed setter. Object is immutable. Use Builder() instead | |
setVpaidControls() | Removed setter. Unused field | |
toJson() | No longer serialize to JSON |
LocalizationConfig
3.x | 4.x | Notes |
---|---|---|
toJson() | No longer serialize to JSON | |
--- | getWeakContext() | Provides a weak reference to the Context provided via the constructor |
LogoConfig
3.x | 4.x | Notes |
---|---|---|
LogoConfig(LogoConfig.Builder builder) | Removed constructor Use Builder() instead | |
LogoConfig(LogoConfig src) | Removed constructor Use Builder() instead | |
parseJson(org.json.JSONObject json) | No longer serialize to JSON | |
parseJson(java.lang.String jsonStr) | No longer serialize to JSON | |
toJson() | No longer serialize to JSON | |
--- | describeContents() | Now implements Parcelable interface |
--- | writeToParcel(android.os.Parcel dest, int flags) | Now implements Parcelable interface |
MediaDrmCallback
3.x | 4.x | Notes |
---|---|---|
MediaDrmCallback | MediaDrmCallback | Now implements Parcelable interface |
MediaSource
3.x | 4.x | Notes |
---|---|---|
cloneList(java.util.List | Remove copy list utility | |
MediaSource(MediaSource src) | Removed copy constructor | |
parseJson(org.json.JSONObject json) | No longer serializes to JSON | |
parseJson(java.lang.String json) | No longer serializes to JSON | |
parseTypeFromFile(java.lang.String file) | No longer serializes to JSON | |
toJson() | No longer serializes to JSON | |
typeAsMediaType(java.lang.String fileType) | Removed utility method | |
--- | describeContents() | Now implements Parcelable interface |
--- | writeToParcel(android.os.Parcel dest, int flags) | Now implements Parcelable interface |
Metadata
3.x | 4.x | Notes |
---|---|---|
parseJson(org.json.JSONObject json) | No longer serializes to JSON | |
toJson() | No longer serializes to JSON | |
toString() | Does not currently override default toString() method | |
--- | describeContents() | Now implements Parcelable interface |
--- | writeToParcel(android.os.Parcel dest, int flags) | Now implements Parcelable interface |
PlaybackRateConfig
3.x | 4.x | Notes |
---|---|---|
PlaybackRateConfig | Removed the class Developers can configure playback rates and playback rate controls on the PlayerConfig object | |
Builder.advertising(AdvertisingBase) | Builder.advertisingConfig(AdvertisingConfig) | Renamed |
Builder.playbackRates(PlaybackRatesConfig) | Builder.playbackRates(float[]) | Renamed, removed unnecessary PlaybackRatesConfig class |
getFile() | Removed Setting only file in the Builder creates a single item playlist accessible via getPlaylist() | |
getImage() | Removed Setting file and image in the Builder creates a single item playlist accessible via getPlaylist() | |
PlayerConfig(PlayerConfig) ctor | Removed Removed, class is immutable | |
--- | Builder.playbackRateControls(Boolean) | Added, broken out of PlaybackRatesConfig |
--- | Builder.uiConfig(UiConfig) | Added to support Native UI |
PlaylistItem
3.x | 4.x | Notes |
---|---|---|
cloneList(java.util.List | Removed copy list utility method | |
listFromJson(java.lang.String json) | No longer serializes to JSON | |
listFromJson(org.json.JSONArray json) | No longer serializes to JSON | |
listFromJson(org.json.JSONObject json) | No longer serializes to JSON | |
parseJson(java.lang.String json) | No longer serializes to JSON | |
parseJson(org.json.JSONObject json) | No longer serializes to JSON | |
PlaylistItem() | Removed empty constructor Use Builder() instead | |
PlaylistItem(java.lang.String file) | Removed empty constructor Use Builder() instead | |
PlaylistItem(java.lang.String title, java.lang.String description, java.lang.String file, java.lang.String image, java.lang.String mediaId, java.util.List | ||
Removed kitchen sink constructor Use Builder() instead | ||
PlaylistItem(PlaylistItem src) | Removed copy constructor Use Builder() instead | |
setAdSchedule(java.util.List | Removed setters. Object is immutable. Use Builder() to configure | |
setAdScheduleInternal(java.util.List | Removed setters. Object is immutable. Use Builder() to configure | |
setCaptions(java.util.List | ||
Removed setters. Object is immutable. Use Builder() to configure | ||
setDescription(java.lang.String description) | Removed setters. Object is immutable. Use Builder() to configure | |
setFile(java.lang.String file) | Removed setters. Object is immutable. Use Builder() to configure | |
setFWSettings(FwSettings mFWSettings) | Removed setters. Object is immutable. Use Builder() to configure | |
setHttpHeaders(java.util.Map<java.lang.String,java.lang.String> httpHeaders) | Removed setters. Object is immutable. Use Builder() to configure | |
setImaDaiSettings(ImaDaiSettings imaDaiSettings) | Removed setters. Object is immutable. Use Builder() to configure | |
setMediaDrmCallback(MediaDrmCallback callback) | Removed setters. Object is immutable. Use Builder() to configure | |
setMediaId(java.lang.String mediaId) | Removed setters. Object is immutable. Use Builder() to configure | |
setRecommendations(java.lang.String recommendations) | Removed setters. Object is immutable. Use Builder() to configure | |
setSources(java.util.List | Removed setters. Object is immutable. Use Builder() to configure | |
setStartTime(double startTime) | Removed setters. Object is immutable. Use Builder() to configure | |
setTitle(java.lang.String title) | Removed setters. Object is immutable. Use Builder() to configure | |
toJson() | No longer serializes to JSON | |
--- | describeContents() | Now implements Parcelable interface |
--- | hasHasPreroll() | Utility method |
--- | writeToParcel(android.os.Parcel dest, int flags) | Now implements Parcelable interface |
QualityLevel
3.x | 4.x | Notes |
---|---|---|
fromJson(org.json.JSONObject jso) | No longer serializes to JSON | |
parseJson(org.json.JSONObject qualityJson) | No longer serializes to JSON | |
toJson() | No longer serializes to JSON | |
toString() | Does not currently override default toString() method | |
--- | describeContents() | Now implements Parcelable interface |
--- | writeToParcel(android.os.Parcel dest, int flags) | Now implements Parcelable interface |
RelatedConfig
3.x | 4.x | Notes |
---|---|---|
parseJson(org.json.JSONObject json) | No longer serializes to JSON | |
parseJson(java.lang.String jsonStr) | No longer serializes to JSON | |
RelatedConfig(RelatedConfig src) | Removed copy constructor Use Builder() instead | |
setAutoPlayMessage(java.lang.String message) | Removed setters. Object is immutable. Use Builder() to configure | |
setAutoPlayTimer(java.lang.Integer timer) | Removed setters. Object is immutable. Use Builder() to configure | |
setDisplayMode(java.lang.String displayMode) | Removed setters. Object is immutable. Use Builder() to configure | |
setFile(java.lang.String file) | Removed setters. Object is immutable. Use Builder() to configure | |
setOnClick(java.lang.String onClick) | Removed setters. Object is immutable. Use Builder() to configure | |
setOnComplete(java.lang.String onComplete) | Removed setters. Object is immutable. Use Builder() to configure | |
toJson() | No longer serializes to JSON | |
--- | describeContents() | Now implements Parcelable interface |
--- | writeToParcel(android.os.Parcel dest, int flags) | Now implements Parcelable interface |
SharingConfig
3.x | 4.x | Notes |
---|---|---|
SharingConfig | Removed the class Developers should implement their own sharing functionality to best suit their needs. |
UiConfig
3.x | 4.x | Notes |
---|---|---|
--- | UiConfig(UiConfig.Builder builder) | New class to configure visible UI elements |
VMAPAdvertising
Renamed to VmapAdvertisingConfig
3.x | 4.x | Notes |
---|---|---|
copy() | Removed utility method | |
getClient() | getAdClient() | Renamed |
setAdMessage() | Removed setters. Object is immutable. Use Builder() instead | |
setTag(java.lang.String tag) | Removed setters. Object is immutable. Use Builder() instead | |
setAdRules() | Removed setters. Object is immutable. Use Builder() instead | |
setClient() | Removed setters. Object is immutable. Use Builder() instead | |
setCueText() | Removed setters. Object is immutable. Use Builder() instead | |
setRequestTimeout() | Removed setters. Object is immutable. Use Builder() instead | |
setSkipMessage() | Removed setters. Object is immutable. Use Builder() instead | |
setSkipOffset() | Removed setters. Object is immutable. Use Builder() instead | |
setSkipText() | Removed setters. Object is immutable. Use Builder() instead | |
setVpaidControls() | Removed setters. Object is immutable. Use Builder() instead | |
toJson() | No longer serialize to JSON | |
VMAPAdvertising(AdSource client, java.lang.String tag) | Removed constructor Use Builder() instead | |
VMAPAdvertising(VMAPAdvertising src) | Removed constructor Use Builder() instead | |
--- | getConditionalOptOut() | |
--- | getCreativeTimeout() |
Events API
The Events API has been updated to be more generic. Several small changes were made to Event payloads.
Event Registration / Deregistration
player.addListener(EventType.SEEK, listener);
player.removeListener(EventType.SEEK, listener);
List of events supported
public enum EventType {
CAPTIONS_LIST,
CAPTIONS_CHANGED,
META,
BUFFER_CHANGE,
CONTROLS,
CONTROLBAR_VISIBILITY,
PLAYLIST_COMPLETE,
COMPLETE,
DISPLAY_CLICK,
FIRST_FRAME,
SEEKED,
PLAYBACK_RATE_CHANGED,
VIEWABLE,
IN_PLAYLIST_TIMED_METADATA,
EVENT_MESSAGE_METADATA,
EXTERNAL_METADATA,
SHARING_CLICK,
SHARING_OPEN,
SHARING_CLOSE,
RELATED_PLAY,
RELATED_OPEN,
RELATED_CLOSE,
BEFORE_COMPLETE,
BEFORE_PLAY,
AD_BREAK_START,
AD_BREAK_END,
AD_BREAK_IGNORED,
AD_BEFORE_PLAY,
AD_BEFORE_COMPLETE,
AD_CLICK,
AD_COMPANIONS,
AD_COMPLETE,
AD_ERROR,
AD_IMPRESSION,
AD_WARNING,
AD_META,
AD_PAUSE,
AD_PLAY,
AD_REQUEST,
AD_SCHEDULE,
AD_SKIPPED,
AD_STARTED,
AD_TIME,
AD_VIEWABLE_IMPRESSION,
READY,
SETUP_ERROR,
PLAYLIST,
PLAYLIST_ITEM,
PLAY,
PAUSE,
BUFFER,
IDLE,
WARNING,
ERROR,
SEEK,
TIME,
FULLSCREEN,
LEVELS,
LEVELS_CHANGED,
VISUAL_QUALITY,
AUDIO_TRACKS,
MUTE,
AUDIO_TRACK_CHANGED
}
AdErrorEvent
3.x | 4.x | Notes |
---|---|---|
--- | int getAdErrorCode() | JWP ad error code to describe the cause of the ad error |
--- | int getCode() | VAST ad error code to describing the cause of the ad error |
AdImpressionEvent
3.x | 4.x | Notes |
---|---|---|
--- | int getPodcount() | New method to return the count of pods in the ad |
--- | int getSequence() | New method to return the sequence of the current pod in the ad |
AdMetaEvent
3.x | 4.x | Notes |
---|---|---|
getType() | getMetaType() | Renamed method |
AdScheduleFromEvent
3.x | 4.x | Notes |
---|---|---|
getmBreakId() | getBreakId() | Renamed method |
getmItem() | getBreakId() | Renamed method |
Player API
The JWP API is now decoupled from the Player View, which means that you will need to access the player API on the JWPlayer
class.
JWPlayer
3.x | 4.x | Notes |
---|---|---|
add*Listener(On*Listener) | addListener(EventType, EventListener) | Combined all event registration into one method |
addButton() | Removed Use custom native controls instead | |
closeSharingOverlay() | Removed Sharing is not supported ​ | |
getExperimentalAPI() | Removed ExperimentalAPI has been finalized into the regular API ​ | |
load( | Removed Use setup(PlayerConfig) instead ​​ | |
onStart() and onStop() | Removed Use setup(PlayerConfig) instead ​​ | |
remove*Listener(On*Listener) | removeListener(EventType, EventListener) | Combined all event registration into one method |
- - - | getViewModelForUiGroup(UiGroup) | Used to get the ViewModel for a group of UI controls (for example, center controls) |
Player API Compatibility
If you prefer to use the old style of event registration/deregistration, it is still available in the JWPlayerCompat
class. This class offers type checking against each individual listener type, but cannot use generics like the new style of event registration.
JWPlayer player = ...;
JWPlayerCompat playerCompat = new JWPlayerCompat(player);
playerCompat.addOnPlayListener(this);
Updated 12 months ago