use of com.google.android.gms.cast.TextTrackStyle in project Shuttle by timusus.
the class TracksPreferenceManager method getTextTrackStyle.
public TextTrackStyle getTextTrackStyle() {
final TextTrackStyle textTrackStyle = TextTrackStyle.fromSystemSettings(mContext);
if (Utils.IS_KITKAT_OR_ABOVE) {
return textTrackStyle;
} else {
// we need to populate all the fields ourselves
textTrackStyle.setFontGenericFamily(FONT_FAMILY_MAPPING.get(getFontFamily()));
textTrackStyle.setBackgroundColor(Color.parseColor(getBackgroundColor()));
textTrackStyle.setEdgeType(EDGE_TYPE_MAPPING.get(getEdgeType()));
textTrackStyle.setFontScale(getFontScale());
boolean isBold = Typeface.DEFAULT.isBold();
boolean isItalic = Typeface.DEFAULT.isItalic();
int fontStyle = TextTrackStyle.FONT_STYLE_NORMAL;
if (isBold && isItalic) {
fontStyle = TextTrackStyle.FONT_STYLE_BOLD_ITALIC;
} else if (!isBold && !isItalic) {
fontStyle = TextTrackStyle.FONT_STYLE_NORMAL;
} else if (isBold) {
fontStyle = TextTrackStyle.FONT_STYLE_BOLD;
}
textTrackStyle.setFontStyle(fontStyle);
textTrackStyle.setForegroundColor(combineColorAndOpacity(getTextColor(), getTextOpacity()));
LOGD(TAG, "Edge is: " + getEdgeType());
textTrackStyle.setBackgroundColor(combineColorAndOpacity(getBackgroundColor(), getBackgroundOpacity()));
}
return textTrackStyle;
}
use of com.google.android.gms.cast.TextTrackStyle in project butter-android by butterproject.
the class CastService method playMedia.
private void playMedia(final com.google.android.gms.cast.MediaInfo mediaInformation, final String mediaAppId, final LaunchListener listener) {
final ApplicationConnectionResultCallback webAppLaunchCallback = new ApplicationConnectionResultCallback(new LaunchWebAppListener() {
@Override
public void onSuccess(final WebAppSession webAppSession) {
ConnectionListener connectionListener = new ConnectionListener() {
@Override
public void onConnected() {
try {
mMediaPlayer.load(mApiClient, mediaInformation, true).setResultCallback(new ResultCallback<RemoteMediaPlayer.MediaChannelResult>() {
@Override
public void onResult(MediaChannelResult result) {
Status status = result.getStatus();
if (status.isSuccess()) {
webAppSession.launchSession.setSessionType(LaunchSessionType.Media);
// White text, black outline, no background
TextTrackStyle textTrackStyle = new TextTrackStyle();
textTrackStyle.setForegroundColor(Color.parseColor("#FFFFFFFF"));
textTrackStyle.setBackgroundColor(Color.parseColor("#01000000"));
textTrackStyle.setWindowType(TextTrackStyle.WINDOW_TYPE_NONE);
textTrackStyle.setEdgeType(TextTrackStyle.EDGE_TYPE_OUTLINE);
textTrackStyle.setEdgeColor(Color.BLACK);
textTrackStyle.setFontGenericFamily(TextTrackStyle.FONT_FAMILY_SANS_SERIF);
mMediaPlayer.setTextTrackStyle(mApiClient, textTrackStyle);
mMediaPlayer.setActiveMediaTracks(mApiClient, new long[] { 1 });
Util.postSuccess(listener, new MediaLaunchObject(webAppSession.launchSession, CastService.this));
} else {
Util.postError(listener, new ServiceCommandError(status.getStatusCode(), status.getStatusMessage(), status));
}
}
});
} catch (Exception e) {
Util.postError(listener, new ServiceCommandError(0, "Unable to load", null));
}
}
};
runCommand(connectionListener);
}
@Override
public void onFailure(ServiceCommandError error) {
Util.postError(listener, error);
}
});
launchingAppId = mediaAppId;
ConnectionListener connectionListener = new ConnectionListener() {
@Override
public void onConnected() {
boolean relaunchIfRunning = false;
try {
if (Cast.CastApi.getApplicationStatus(mApiClient) == null || (!mediaAppId.equals(currentAppId))) {
relaunchIfRunning = true;
}
LaunchOptions options = new LaunchOptions();
options.setRelaunchIfRunning(relaunchIfRunning);
Cast.CastApi.launchApplication(mApiClient, mediaAppId, options).setResultCallback(webAppLaunchCallback);
} catch (Exception e) {
Util.postError(listener, new ServiceCommandError(0, "Unable to launch", null));
}
}
};
runCommand(connectionListener);
}
use of com.google.android.gms.cast.TextTrackStyle in project zype-android by zype.
the class TracksPreferenceManager method getTextTrackStyle.
public TextTrackStyle getTextTrackStyle() {
final TextTrackStyle textTrackStyle = TextTrackStyle.fromSystemSettings(mContext);
if (Utils.IS_KITKAT_OR_ABOVE) {
return textTrackStyle;
} else {
// we need to populate all the fields ourselves
textTrackStyle.setFontGenericFamily(FONT_FAMILY_MAPPING.get(getFontFamily()));
textTrackStyle.setBackgroundColor(Color.parseColor(getBackgroundColor()));
textTrackStyle.setEdgeType(EDGE_TYPE_MAPPING.get(getEdgeType()));
textTrackStyle.setFontScale(getFontScale());
boolean isBold = Typeface.DEFAULT.isBold();
boolean isItalic = Typeface.DEFAULT.isItalic();
int fontStyle = TextTrackStyle.FONT_STYLE_NORMAL;
if (isBold && isItalic) {
fontStyle = TextTrackStyle.FONT_STYLE_BOLD_ITALIC;
} else if (!isBold && !isItalic) {
fontStyle = TextTrackStyle.FONT_STYLE_NORMAL;
} else if (isBold) {
fontStyle = TextTrackStyle.FONT_STYLE_BOLD;
}
textTrackStyle.setFontStyle(fontStyle);
textTrackStyle.setForegroundColor(combineColorAndOpacity(getTextColor(), getTextOpacity()));
LOGD(TAG, "Edge is: " + getEdgeType());
textTrackStyle.setBackgroundColor(combineColorAndOpacity(getBackgroundColor(), getBackgroundOpacity()));
}
return textTrackStyle;
}
Aggregations