当前位置: 首页>>代码示例>>Java>>正文


Java CastStatusCodes类代码示例

本文整理汇总了Java中com.google.android.gms.cast.CastStatusCodes的典型用法代码示例。如果您正苦于以下问题:Java CastStatusCodes类的具体用法?Java CastStatusCodes怎么用?Java CastStatusCodes使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


CastStatusCodes类属于com.google.android.gms.cast包,在下文中一共展示了CastStatusCodes类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onApplicationConnectionFailed

import com.google.android.gms.cast.CastStatusCodes; //导入依赖的package包/类
@Override
public void onApplicationConnectionFailed(int errorCode) {
    if (mReconnectionStatus == RECONNECTION_STATUS_IN_PROGRESS) {
        if (errorCode == CastStatusCodes.APPLICATION_NOT_RUNNING) {
            // while trying to re-establish session, we found out that the app is not running
            // so we need to disconnect
            mReconnectionStatus = RECONNECTION_STATUS_INACTIVE;
            onDeviceSelected(null /* CastDevice */, null /* RouteInfo */);
        }
    } else {
        for (DataCastConsumer consumer : mDataConsumers) {
            consumer.onApplicationConnectionFailed(errorCode);
        }
        onDeviceSelected(null /* CastDevice */, null /* RouteInfo */);
        if (mMediaRouter != null) {
            LOGD(TAG, "onApplicationConnectionFailed(): Setting route to default");
            mMediaRouter.selectRoute(mMediaRouter.getDefaultRoute());
        }
    }
}
 
开发者ID:SebastianRask,项目名称:Pocket-Plays-for-Twitch,代码行数:21,代码来源:DataCastManager.java

示例2: onApplicationConnectionFailed

import com.google.android.gms.cast.CastStatusCodes; //导入依赖的package包/类
@Override
public void onApplicationConnectionFailed(int errorCode) {
    LOGD(TAG, "onApplicationConnectionFailed() reached with errorCode: " + errorCode);
    mApplicationErrorCode = errorCode;
    if (mReconnectionStatus == RECONNECTION_STATUS_IN_PROGRESS) {
        if (errorCode == CastStatusCodes.APPLICATION_NOT_RUNNING) {
            // while trying to re-establish session, we found out that the app is not running
            // so we need to disconnect
            mReconnectionStatus = RECONNECTION_STATUS_INACTIVE;
            onDeviceSelected(null /* CastDevice */, null /* RouteInfo */);
        }
    } else {
        for (VideoCastConsumer consumer : mVideoConsumers) {
            consumer.onApplicationConnectionFailed(errorCode);
        }
        onDeviceSelected(null /* CastDevice */, null /* RouteInfo */);
        if (mMediaRouter != null) {
            LOGD(TAG, "onApplicationConnectionFailed(): Setting route to default");
            mMediaRouter.selectRoute(mMediaRouter.getDefaultRoute());
        }
    }
}
 
开发者ID:SebastianRask,项目名称:Pocket-Plays-for-Twitch,代码行数:23,代码来源:VideoCastManager.java

示例3: onApplicationDisconnected

import com.google.android.gms.cast.CastStatusCodes; //导入依赖的package包/类
@Override
// TODO(crbug.com/635567): Fix this properly.
@SuppressLint("DefaultLocale")
public void onApplicationDisconnected(int errorCode) {
    if (errorCode != CastStatusCodes.SUCCESS) {
        Log.e(TAG, String.format(
                "Application disconnected with: %d", errorCode));
    }

    // This callback can be called more than once if the application is stopped from Chrome.
    if (mSession == null) return;

    mSession.stopApplication();
    mSession = null;
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:16,代码来源:CreateRouteRequest.java

示例4: onMediaLoadResult

import com.google.android.gms.cast.CastStatusCodes; //导入依赖的package包/类
@Override
public void onMediaLoadResult(int statusCode) {
    if (CastStatusCodes.SUCCESS != statusCode) {
        LOGD(TAG, "onMediaLoadResult(): Failed to load media with status code: "
                + statusCode);
        Utils.showToast(getActivity(), R.string.ccl_failed_to_load_media);
        mCastController.closeActivity();
    }
}
 
开发者ID:SebastianRask,项目名称:Pocket-Plays-for-Twitch,代码行数:10,代码来源:VideoCastControllerFragment.java

示例5: createRoute

import com.google.android.gms.cast.CastStatusCodes; //导入依赖的package包/类
/**
 * Initiates route creation with the given parameters. Notifies the native client of success
 * and failure.
 * @param sourceId the id of the {@link MediaSource} to route to the sink.
 * @param sinkId the id of the {@link MediaSink} to route the source to.
 * @param presentationId the id of the presentation to be used by the page.
 * @param requestId the id of the route creation request tracked by the native side.
 */
@CalledByNative
public void createRoute(
        final String sourceId,
        final String sinkId,
        final String presentationId,
        int requestId) {
    if (mAndroidMediaRouter == null) {
        nativeOnRouteCreationError(mNativeMediaRouterAndroid, "Not supported", requestId);
        return;
    }

    new CreateRouteRequest(sourceId, sinkId, presentationId, requestId, this).start(
            mAndroidMediaRouter,
            mApplicationContext,
            // TODO(avayvod): handle application disconnect and report back to the native side.
            // Part of https://crbug.com/517100.
            new Cast.Listener() {
                @Override
                public void onApplicationDisconnected(int errorCode) {
                    if (errorCode != CastStatusCodes.SUCCESS) {
                        Log.e(TAG, String.format(
                                "Application disconnected with: %d", errorCode));
                    }
                    closeRoute(createMediaRouteId(presentationId, sinkId, sourceId));
                }
            });
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:36,代码来源:ChromeMediaRouter.java

示例6: onApplicationDisconnected

import com.google.android.gms.cast.CastStatusCodes; //导入依赖的package包/类
@Override
public void onApplicationDisconnected(int statusCode) {
    Log.d(TAG, "onApplicationDisconnected: statusCode=" + statusCode);
    mAppMetadata = null;
    detachMediaPlayer();
    clearMediaState();
    updateButtonStates();
    if (statusCode != CastStatusCodes.SUCCESS) {
        // This is an unexpected disconnect.
        setApplicationStatus(getString(R.string.status_app_disconnected));
    }
}
 
开发者ID:TerribleDev,项目名称:XamarinAdmobTutorial,代码行数:13,代码来源:SdkCastPlayerActivity.java

示例7: disconnectDevice

import com.google.android.gms.cast.CastStatusCodes; //导入依赖的package包/类
/**
 * Disconnects from the connected device.
 *
 * @param stopAppOnExit If {@code true}, the application running on the cast device will be
 * stopped when disconnected.
 * @param clearPersistedConnectionData If {@code true}, the persisted connection information
 * will be cleared as part of this call.
 * @param setDefaultRoute If {@code true}, after disconnection, the selected route will be set
 * to the Default Route.
 */
public final void disconnectDevice(boolean stopAppOnExit, boolean clearPersistedConnectionData,
        boolean setDefaultRoute) {
    LOGD(TAG, "disconnectDevice(" + clearPersistedConnectionData + "," + setDefaultRoute + ")");
    if (mSelectedCastDevice == null) {
        return;
    }
    mSelectedCastDevice = null;
    mDeviceName = null;

    String message = "disconnectDevice() Disconnect Reason: ";
    int reason;
    if (mConnectionSuspended) {
        message += "Connectivity lost";
        reason = DISCONNECT_REASON_CONNECTIVITY;
    } else {
        switch (mApplicationErrorCode) {
            case CastStatusCodes.APPLICATION_NOT_RUNNING:
                message += "App was taken over or not available anymore";
                reason = DISCONNECT_REASON_APP_NOT_RUNNING;
                break;
            case NO_APPLICATION_ERROR:
                message += "Intentional disconnect";
                reason = DISCONNECT_REASON_EXPLICIT;
                break;
            default:
                message += "Other";
                reason = DISCONNECT_REASON_OTHER;
        }
    }
    LOGD(TAG, message);
    for (BaseCastConsumer consumer : mBaseCastConsumers) {
        consumer.onDisconnectionReason(reason);
    }

    LOGD(TAG, "mConnectionSuspended: " + mConnectionSuspended);
    if (!mConnectionSuspended && clearPersistedConnectionData) {
        clearPersistedConnectionInfo(CLEAR_ALL);
        stopReconnectionService();
    }
    try {
        if ((isConnected() || isConnecting()) && stopAppOnExit) {
            LOGD(TAG, "Calling stopApplication");
            stopApplication();
        }
    } catch (NoConnectionException | TransientNetworkDisconnectionException e) {
        LOGE(TAG, "Failed to stop the application after disconnecting route", e);
    }
    onDeviceUnselected();
    if (mApiClient != null) {
        // the following check is currently required, without including a check for
        // isConnecting() due to a bug in the current play services library and will be removed
        // when that bug is addressed; calling disconnect() while we are in "connecting" state
        // will throw an exception
        if (mApiClient.isConnected()) {
            LOGD(TAG, "Trying to disconnect");
            mApiClient.disconnect();
        }
        if ((mMediaRouter != null) && setDefaultRoute) {
            LOGD(TAG, "disconnectDevice(): Setting route to default");
            mMediaRouter.selectRoute(mMediaRouter.getDefaultRoute());
        }
        mApiClient = null;
    }
    mSessionId = null;
    onDisconnected(stopAppOnExit, clearPersistedConnectionData, setDefaultRoute);
}
 
开发者ID:SebastianRask,项目名称:Pocket-Plays-for-Twitch,代码行数:77,代码来源:BaseCastManager.java

示例8: onApplicationConnectionFailed

import com.google.android.gms.cast.CastStatusCodes; //导入依赖的package包/类
@Override
public void onApplicationConnectionFailed(int errorCode) {
    LOGD(TAG, "onApplicationConnectionFailed() reached with errorCode: " + errorCode);
    if (mReconnectionStatus == ReconnectionStatus.IN_PROGRESS) {
        if (errorCode == CastStatusCodes.APPLICATION_NOT_RUNNING) {
            // while trying to re-establish session, we
            // found out that the app is not running so we need
            // to disconnect
            mReconnectionStatus = ReconnectionStatus.INACTIVE;
            onDeviceSelected(null);
        }
        return;
    } else {
        boolean showError = false;
        synchronized (mVideoConsumers) {
            for (IVideoCastConsumer consumer : mVideoConsumers) {
                try {
                    showError = showError || consumer.onApplicationConnectionFailed(errorCode);
                } catch (Exception e) {
                    LOGE(TAG, "onApplicationConnectionFailed(): Failed to inform " + consumer, e);
                }
            }
        }
        if (showError) {
            switch (errorCode) {
                case CastStatusCodes.APPLICATION_NOT_FOUND:
                    LOGD(TAG, "onApplicationConnectionFailed(): failed due to: " +
                            "ERROR_APPLICATION_NOT_FOUND");
                    Utils.showErrorDialog(mContext, R.string.failed_to_find_app);
                    break;
                case CastStatusCodes.TIMEOUT:
                    LOGD(TAG, "onApplicationConnectionFailed(): failed due to: ERROR_TIMEOUT");
                    Utils.showErrorDialog(mContext, R.string.failed_app_launch_timeout);
                    break;
                default:
                    LOGD(TAG, "onApplicationConnectionFailed(): failed due to: errorcode="
                            + errorCode);
                    Utils.showErrorDialog(mContext, R.string.failed_to_launch_app);
                    break;
            }
        }

        onDeviceSelected(null);
        if (null != mMediaRouter) {
            LOGD(TAG, "onApplicationConnectionFailed(): Setting route to default");
            mMediaRouter.selectRoute(mMediaRouter.getDefaultRoute());
        }
    }
}
 
开发者ID:BruGTUG,项目名称:codelab-chromecast,代码行数:50,代码来源:VideoCastManager.java

示例9: handleMessage

import com.google.android.gms.cast.CastStatusCodes; //导入依赖的package包/类
@Override
public void handleMessage(Message msg) {
    BaseActivity activity = reference.get();
    if (activity == null) {
        Timber.e("CastManagerCallbackHandler: activity was null");
        return;
    }

    switch (msg.what) {
        case CAST_APPLICATION_CONNECTION_FAILED:
            final String errorMsg;
            switch (msg.arg1) {
                case CastStatusCodes.APPLICATION_NOT_FOUND:
                    errorMsg = "ERROR_APPLICATION_NOT_FOUND";
                    break;
                case CastStatusCodes.TIMEOUT:
                    errorMsg = "ERROR_TIMEOUT";
                    break;
                default:
                    errorMsg = "UNKNOWN ERROR: " + msg.arg1;
                    break;
            }
            Timber.d("onApplicationConnectionFailed(): failed due to: " + errorMsg);
            resetDefaultMediaRoute(activity);
            // notify if possible
            if (activity.mIsResumed) {
                new AlertDialog.Builder(activity)
                        .setTitle(R.string.cast_error)
                        .setMessage(String.format(Locale.getDefault(),
                                activity.getString(R.string.cast_failed_to_connect), errorMsg))
                        .setPositiveButton(android.R.string.ok, null)
                        .show();
            }
            break;
        case CAST_APPLICATION_DISCONNECTED:
            // This is just in case
            resetDefaultMediaRoute(activity);
            break;
        case CAST_CONNECTION_SUSPENDED:
            activity.mTransientNetworkDisconnection = true;
            break;
        case CAST_CONNECTIVITY_RECOVERED:
            activity.mTransientNetworkDisconnection = false;
            break;
        case CAST_DISCONNECTED:
            activity.mTransientNetworkDisconnection = false;
            break;
        case CAST_FAILED:
            // notify if possible
            if (activity.mIsResumed) {
                switch (msg.arg1) {
                    case (R.string.failed_load):
                        new AlertDialog.Builder(activity)
                                .setTitle(R.string.cast_error)
                                .setMessage(R.string.failed_load)
                                .setPositiveButton(android.R.string.ok, null)
                                .show();
                        break;
                }
            }
            break;
    }
}
 
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:64,代码来源:BaseActivity.java

示例10: onApplicationConnectionFailed

import com.google.android.gms.cast.CastStatusCodes; //导入依赖的package包/类
@Override
public void onApplicationConnectionFailed(int errorCode) {
  CastUtils.LOGD(TAG, "onApplicationConnectionFailed() reached with errorCode: " + errorCode);
  if (mReconnectionStatus == ReconnectionStatus.IN_PROGRESS) {
    if (errorCode == CastStatusCodes.APPLICATION_NOT_RUNNING) {
      // while trying to re-establish session, we
      // found out that the app is not running so we need
      // to disconnect
      mReconnectionStatus = ReconnectionStatus.INACTIVE;
      onDeviceSelected(null);
    }
  } else {
    boolean showError = false;
    for (IVideoCastConsumer consumer : mVideoConsumers) {
      try {
        showError = showError || consumer.onApplicationConnectionFailed(errorCode);
      } catch (Exception e) {
        CastUtils.LOGE(TAG, "onApplicationLaunchFailed(): Failed to inform " + consumer, e);
      }
    }
    if (showError) {
      switch (errorCode) {
        case CastStatusCodes.APPLICATION_NOT_FOUND:
          CastUtils.LOGD(TAG, "onApplicationConnectionFailed(): failed due to: " + "ERROR_APPLICATION_NOT_FOUND");
          CastUtils.showErrorDialog(mContext, R.string.failed_to_find_app);
          break;
        case CastStatusCodes.TIMEOUT:
          CastUtils.LOGD(TAG, "onApplicationConnectionFailed(): failed due to: ERROR_TIMEOUT");
          CastUtils.showErrorDialog(mContext, R.string.failed_app_launch_timeout);
          break;
        default:
          CastUtils.LOGD(TAG, "onApplicationConnectionFailed(): failed due to: errorcode=" + errorCode);
          CastUtils.showErrorDialog(mContext, R.string.failed_to_launch_app);
          break;
      }
    }

    onDeviceSelected(null);
    if (null != mMediaRouter) {
      mMediaRouter.selectRoute(mMediaRouter.getDefaultRoute());
    }
  }
}
 
开发者ID:sgehrman,项目名称:UTubeTV,代码行数:44,代码来源:VideoCastManager.java

示例11: onApplicationConnectionFailed

import com.google.android.gms.cast.CastStatusCodes; //导入依赖的package包/类
@Override
public void onApplicationConnectionFailed(int errorCode) {
    LOGD(TAG, "onApplicationConnectionFailed() reached with errorCode: " + errorCode);
    if (mReconnectionStatus == ReconnectionStatus.IN_PROGRESS) {
        if (errorCode == CastStatusCodes.APPLICATION_NOT_RUNNING) {
            // while trying to re-establish session, we
            // found out that the app is not running so we need
            // to disconnect
            mReconnectionStatus = ReconnectionStatus.INACTIVE;
            onDeviceSelected(null);
        }
        return;
    } else {
        boolean showError = false;
        synchronized (mVideoConsumers) {
            for (IVideoCastConsumer consumer : mVideoConsumers) {
                try {
                    showError = showError || consumer.onApplicationConnectionFailed(errorCode);
                } catch (Exception e) {
                    LOGE(TAG, "onApplicationLaunchFailed(): Failed to inform " + consumer, e);
                }
            }
        }
        if (showError) {
            switch (errorCode) {
                case CastStatusCodes.APPLICATION_NOT_FOUND:
                    LOGD(TAG, "onApplicationConnectionFailed(): failed due to: " +
                            "ERROR_APPLICATION_NOT_FOUND");
                    Utils.showErrorDialog(mContext, R.string.failed_to_find_app);
                    break;
                case CastStatusCodes.TIMEOUT:
                    LOGD(TAG, "onApplicationConnectionFailed(): failed due to: ERROR_TIMEOUT");
                    Utils.showErrorDialog(mContext, R.string.failed_app_launch_timeout);
                    break;
                default:
                    LOGD(TAG, "onApplicationConnectionFailed(): failed due to: errorcode="
                            + errorCode);
                    Utils.showErrorDialog(mContext, R.string.failed_to_launch_app);
                    break;
            }
        }

        onDeviceSelected(null);
        if (null != mMediaRouter) {
            mMediaRouter.selectRoute(mMediaRouter.getDefaultRoute());
        }
    }
}
 
开发者ID:TByron,项目名称:Jupiter-Broadcasting-Holo,代码行数:49,代码来源:VideoCastManager.java

示例12: doInBackground

import com.google.android.gms.cast.CastStatusCodes; //导入依赖的package包/类
@Override
protected MetadataBuffer doInBackground(Void... params) {
    // Check connection
    if (!mClient.isConnected()) {
        errorString = NetpowerctrlApplication.getAppString(R.string.gDrive_error_lost_connection);
        return null;
    }

    try {
        // Request sync
        com.google.android.gms.common.api.Status resultRequestSync;
        resultRequestSync = Drive.DriveApi.requestSync(mClient).await(5, TimeUnit.SECONDS);
        if (!resultRequestSync.getStatus().isSuccess()) {
            if (resultRequestSync.getStatusCode() == CastStatusCodes.TIMEOUT) {
                errorString = NetpowerctrlApplication.getAppString(R.string.gDrive_error_timeout);
            } else
                errorString = NetpowerctrlApplication.getAppString(R.string.gDrive_error_retrieve_files,
                        resultRequestSync.getStatus().toString());
            // We failed, stop the task and return.
            return null;
        }

        // Enter dir
        DriveFolder PluginServiceDir = GDrive.getAppFolder(mClient);

        // Get childs
        DriveApi.MetadataBufferResult result = PluginServiceDir.listChildren(mClient).await(5, TimeUnit.SECONDS);
        if (!result.getStatus().isSuccess()) {
            if (resultRequestSync.getStatusCode() == CastStatusCodes.TIMEOUT) {
                errorString = NetpowerctrlApplication.getAppString(R.string.gDrive_error_timeout);
            } else
                errorString = NetpowerctrlApplication.getAppString(R.string.gDrive_error_retrieve_files, result.getStatus().toString());
            // We failed, stop the task and return.
            return null;
        }

        return result.getMetadataBuffer();
    } catch (Exception e) {
        errorString = e.getMessage();
    }

    return null;
}
 
开发者ID:davidgraeff,项目名称:Android-NetPowerctrl,代码行数:44,代码来源:GDriveRefreshBackupListTask.java


注:本文中的com.google.android.gms.cast.CastStatusCodes类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。