本文整理汇总了Java中su.litvak.chromecast.api.v2.Status类的典型用法代码示例。如果您正苦于以下问题:Java Status类的具体用法?Java Status怎么用?Java Status使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Status类属于su.litvak.chromecast.api.v2包,在下文中一共展示了Status类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: processStatusUpdate
import su.litvak.chromecast.api.v2.Status; //导入依赖的package包/类
public void processStatusUpdate(final Status status) {
if (status == null) {
updateStatus(ThingStatus.OFFLINE);
updateAppStatus(null);
updateVolumeStatus(null);
return;
}
if (status.applications == null) {
this.appSessionId = null;
}
updateStatus(ThingStatus.ONLINE);
updateAppStatus(status.getRunningApp());
updateVolumeStatus(status.volume);
}
示例2: spontaneousEventReceived
import su.litvak.chromecast.api.v2.Status; //导入依赖的package包/类
@Override
public void spontaneousEventReceived(final ChromeCastSpontaneousEvent event) {
switch (event.getType()) {
case MEDIA_STATUS:
statusUpdater.updateMediaStatus(event.getData(MediaStatus.class));
break;
case STATUS:
statusUpdater.processStatusUpdate(event.getData(Status.class));
break;
case UNKNOWN:
logger.debug("Received an 'UNKNOWN' event (class={})", event.getType().getDataClass());
break;
default:
logger.debug("Unhandled event type: {}", event.getData());
break;
}
}
示例3: startPoll
import su.litvak.chromecast.api.v2.Status; //导入依赖的package包/类
public void startPoll() {
Runnable r = new Runnable() {
@Override
public void run() {
for(;;) {
try {
Thread.sleep(1000);
Status s1 = api.getStatus();
if (s1 == null || !s1.isAppRunning(MediaPlayer)) {
continue;
}
MediaStatus status = api.getMediaStatus();
if (status == null) {
continue;
}
state.playback = translateState(status.playerState);
Media m = status.media;
if (m != null) {
if (m.url != null) {
state.uri = status.media.url;
}
if(m.duration != null) {
state.duration = StringUtil.convertTimeToString(status.media.duration, "%02d:%02d:%02.0f");
}
}
state.position = StringUtil.convertTimeToString(status.currentTime, "%02d:%02d:%02.0f");
if (status.volume != null) {
state.volume = status.volume.level.intValue();
state.mute = status.volume.muted;
}
alert();
} catch (InterruptedException | IOException e) {
LOGGER.debug("Bad chromecast mediastate " + e);
}
}
}
};
poller = new Thread(r);
poller.start();
}
示例4: serve
import su.litvak.chromecast.api.v2.Status; //导入依赖的package包/类
@Override
@SuppressWarnings({"ConstantConditions"})
public synchronized Response serve(IHTTPSession session) {
// Acquire a wakelock while serving the file
mCpuWakeLock.acquire(45000L);
// We only allow request coming from the ChromeCast device we bound to
if (!isAuthorized(session.getRemoteIpAddress())) {
return createFailureResponse(Response.Status.UNAUTHORIZED);
}
// Check we received a valid request before serve it
final Map<String, List<String>> params = session.getParameters();
if (!params.containsKey(HASH_KEY)) {
return createFailureResponse(Response.Status.BAD_REQUEST);
}
final String hash = params.isEmpty() ? null : params.get(HASH_KEY).get(0);
if (TextUtils.isEmpty(hash)) {
return createFailureResponse(Response.Status.BAD_REQUEST);
}
if (!mRequests.containsKey(hash)) {
return createFailureResponse(Response.Status.FORBIDDEN);
}
File f = new File(mRequests.get(hash));
String mimeType = CastUtils.getTrackMimeType(f);
if (TextUtils.isEmpty(mimeType)) {
return createFailureResponse(Response.Status.FORBIDDEN);
}
// Full quality or compressed?
try {
if (PreferencesProvider.Preferences.Cast.isFullQuality(mContext)) {
// Full quality
Log.d(TAG, "Sent success response " + f);
return newChunkedResponse(
Response.Status.OK,
mimeType,
new BufferedInputStream(new FileInputStream(f), 4096));
} else {
// Compress to webp format
long start = System.currentTimeMillis();
Rect r = BitmapUtils.getBitmapDimensions(f);
BitmapUtils.adjustRectToMinimumSize(r, BitmapUtils.calculateMaxAvailableSize(mContext));
Bitmap src = BitmapUtils.createUnscaledBitmap(f, r.width(), r.height(), 1);
try {
ByteArrayOutputStream out = new ByteArrayOutputStream();
src.compress(Bitmap.CompressFormat.WEBP, 60, out);
long end = System.currentTimeMillis();
Log.d(TAG, "Compressed " + f + " to webp in " + (end - start) + "ms"
+ "; dimensions " + src.getWidth() + "x" + src.getHeight()
+ "; size: " + out.size() + "; original: " + BitmapUtils.byteSizeOf(src));
Log.d(TAG, "Sent success response" + f);
return newChunkedResponse(
Response.Status.OK,
mimeType,
new BufferedInputStream(
new ByteArrayInputStream(out.toByteArray()), 4096));
} finally {
src.recycle();
}
}
} catch (Exception ex) {
Log.e(TAG, "Failed to response request: " + f, ex);
return createFailureResponse(Response.Status.INTERNAL_ERROR);
} finally {
// Release the wakelock
if (mCpuWakeLock.isHeld()) {
mCpuWakeLock.release();
}
}
}
示例5: createFailureResponse
import su.litvak.chromecast.api.v2.Status; //导入依赖的package包/类
private Response createFailureResponse(Response.Status status) {
return newFixedLengthResponse(status, NanoHTTPD.MIME_HTML,
"<html><body><b>" + status.getDescription() + "</b></body></html>");
}