use of org.powerbot.script.rt4.Player in project ExoPlayer by google.
the class MainActivity method initializePlayer.
private void initializePlayer() {
Intent intent = getIntent();
String action = intent.getAction();
Uri uri = ACTION_VIEW.equals(action) ? Assertions.checkNotNull(intent.getData()) : Uri.parse(DEFAULT_MEDIA_URI);
DrmSessionManager drmSessionManager;
if (intent.hasExtra(DRM_SCHEME_EXTRA)) {
String drmScheme = Assertions.checkNotNull(intent.getStringExtra(DRM_SCHEME_EXTRA));
String drmLicenseUrl = Assertions.checkNotNull(intent.getStringExtra(DRM_LICENSE_URL_EXTRA));
UUID drmSchemeUuid = Assertions.checkNotNull(Util.getDrmUuid(drmScheme));
HttpDataSource.Factory licenseDataSourceFactory = new DefaultHttpDataSource.Factory();
HttpMediaDrmCallback drmCallback = new HttpMediaDrmCallback(drmLicenseUrl, licenseDataSourceFactory);
drmSessionManager = new DefaultDrmSessionManager.Builder().setUuidAndExoMediaDrmProvider(drmSchemeUuid, FrameworkMediaDrm.DEFAULT_PROVIDER).build(drmCallback);
} else {
drmSessionManager = DrmSessionManager.DRM_UNSUPPORTED;
}
DataSource.Factory dataSourceFactory = new DefaultDataSource.Factory(this);
MediaSource mediaSource;
@C.ContentType int type = Util.inferContentType(uri, intent.getStringExtra(EXTENSION_EXTRA));
if (type == C.TYPE_DASH) {
mediaSource = new DashMediaSource.Factory(dataSourceFactory).setDrmSessionManagerProvider(unusedMediaItem -> drmSessionManager).createMediaSource(MediaItem.fromUri(uri));
} else if (type == C.TYPE_OTHER) {
mediaSource = new ProgressiveMediaSource.Factory(dataSourceFactory).setDrmSessionManagerProvider(unusedMediaItem -> drmSessionManager).createMediaSource(MediaItem.fromUri(uri));
} else {
throw new IllegalStateException();
}
ExoPlayer player = new ExoPlayer.Builder(getApplicationContext()).build();
player.setMediaSource(mediaSource);
player.prepare();
player.play();
player.setRepeatMode(Player.REPEAT_MODE_ALL);
surfaceControl = new SurfaceControl.Builder().setName(SURFACE_CONTROL_NAME).setBufferSize(/* width= */
0, /* height= */
0).build();
videoSurface = new Surface(surfaceControl);
player.setVideoSurface(videoSurface);
MainActivity.player = player;
}
use of org.powerbot.script.rt4.Player in project ExoPlayer by google.
the class AdTagLoader method onPlaybackStateChanged.
@Override
public void onPlaybackStateChanged(@Player.State int playbackState) {
@Nullable Player player = this.player;
if (adsManager == null || player == null) {
return;
}
if (playbackState == Player.STATE_BUFFERING && !player.isPlayingAd() && isWaitingForAdToLoad()) {
waitingForPreloadElapsedRealtimeMs = SystemClock.elapsedRealtime();
} else if (playbackState == Player.STATE_READY) {
waitingForPreloadElapsedRealtimeMs = C.TIME_UNSET;
}
handlePlayerStateChanged(player.getPlayWhenReady(), playbackState);
}
use of org.powerbot.script.rt4.Player in project ExoPlayer by google.
the class AdTagLoader method isWaitingForAdToLoad.
/**
* Returns whether this instance is expecting the first ad in an the upcoming ad group to load
* within the {@link ImaUtil.Configuration#adPreloadTimeoutMs preload timeout}.
*/
private boolean isWaitingForAdToLoad() {
@Nullable Player player = this.player;
if (player == null) {
return false;
}
int adGroupIndex = getLoadingAdGroupIndex();
if (adGroupIndex == C.INDEX_UNSET) {
return false;
}
AdPlaybackState.AdGroup adGroup = adPlaybackState.getAdGroup(adGroupIndex);
if (adGroup.count != C.LENGTH_UNSET && adGroup.count != 0 && adGroup.states[0] != AdPlaybackState.AD_STATE_UNAVAILABLE) {
// An ad is available already.
return false;
}
long adGroupTimeMs = Util.usToMs(adGroup.timeUs);
long contentPositionMs = getContentPeriodPositionMs(player, timeline, period);
long timeUntilAdMs = adGroupTimeMs - contentPositionMs;
return timeUntilAdMs < configuration.adPreloadTimeoutMs;
}
use of org.powerbot.script.rt4.Player in project powerbot by powerbot.
the class DrawGroundItems method repaint.
public void repaint(final Graphics render) {
if (!ctx.game.loggedIn()) {
return;
}
final Player player = ctx.players.local();
if (player == null) {
return;
}
final Tile tile = player.tile();
if (tile == null) {
return;
}
final FontMetrics metrics = render.getFontMetrics();
final int tHeight = metrics.getHeight();
final int plane = ctx.game.floor();
final List<GroundItem> check = new ArrayList<GroundItem>();
ctx.groundItems.select(10).addTo(check);
for (int x = tile.x() - 10; x <= tile.x() + 10; x++) {
n: for (int y = tile.y() - 10; y <= tile.y() + 10; y++) {
int d = 0;
final Tile loc = new Tile(x, y, plane);
for (final GroundItem groundItem : ctx.groundItems.select(check).at(loc)) {
final Point screen = new TileMatrix(ctx, loc).centerPoint();
if (screen.x == -1 || screen.y == -1) {
continue n;
}
final String name = groundItem.name();
String s = "";
s += groundItem.id();
if (!name.isEmpty()) {
s += " " + name;
}
final int stack = groundItem.stackSize();
if (stack > 1) {
s += " (" + groundItem.stackSize() + ")";
}
final int ty = screen.y - tHeight * (++d) + tHeight / 2;
final int tx = screen.x - metrics.stringWidth(s) / 2;
render.setColor(Color.green);
render.drawString(s, tx, ty);
}
}
}
}
use of org.powerbot.script.rt4.Player in project powerbot by powerbot.
the class DrawObjects method repaint.
@Override
public void repaint(final Graphics render) {
if (!ctx.game.loggedIn()) {
return;
}
final Player player = ctx.players.local();
if (player == null) {
return;
}
final FontMetrics metrics = render.getFontMetrics();
final int textHeight = metrics.getHeight();
final Map<Tile, AtomicInteger> counts = new HashMap<Tile, AtomicInteger>();
for (final GameObject object : ctx.objects.select(15)) {
final Tile t = object.tile();
if (!counts.containsKey(t)) {
counts.put(t, new AtomicInteger(0));
}
final Point p = object.centerPoint();
if (p.x == -1) {
continue;
}
render.setColor(Color.black);
render.fillRect(p.x - 1, p.y - 1, 2, 2);
final int mainId = object.mainId();
final int animation = object.animation();
final String n = object.name();
String s = (n.isEmpty() ? "" : n + " - ") + object.id();
if (animation != -1) {
s = s + " (A: " + animation + ")";
}
if (mainId != -1) {
if (animation != -1) {
s = s.replace(')', ',') + " MID: " + mainId + ")";
} else {
s = s + " (MID: " + mainId + ")";
}
}
final int ty = p.y - textHeight / 2;
final int tx = p.x - metrics.stringWidth(s) / 2;
render.setColor(C[object.type().ordinal()]);
render.drawString(s, tx, ty - textHeight * counts.get(t).getAndIncrement());
}
}
Aggregations