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


Java Cast.ApplicationConnectionResult方法代码示例

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


在下文中一共展示了Cast.ApplicationConnectionResult方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onResult

import com.google.android.gms.cast.Cast; //导入方法依赖的package包/类
@Override
public void onResult(Cast.ApplicationConnectionResult result) {
    if (mState != STATE_LAUNCHING_APPLICATION
            && mState != STATE_API_CONNECTION_SUSPENDED) {
        throwInvalidState();
    }

    Status status = result.getStatus();
    if (!status.isSuccess()) {
        Log.e(TAG, "Launch application failed with status: %s, %d, %s",
                mSource.getApplicationId(), status.getStatusCode(), status.getStatusMessage());
        reportError();
    }

    mState = STATE_LAUNCH_SUCCEEDED;
    reportSuccess(result);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:18,代码来源:CreateRouteRequest.java

示例2: reportSuccess

import com.google.android.gms.cast.Cast; //导入方法依赖的package包/类
private void reportSuccess(Cast.ApplicationConnectionResult result) {
    if (mState != STATE_LAUNCH_SUCCEEDED) throwInvalidState();

    CastSession session = new CastSessionImpl(
            mApiClient,
            result.getSessionId(),
            result.getApplicationMetadata(),
            result.getApplicationStatus(),
            mSink.getDevice(),
            mOrigin,
            mTabId,
            mIsIncognito,
            mSource,
            mRouteProvider);
    mCastListener.setSession(session);
    mRouteProvider.onSessionCreated(session);

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

示例3: onResult

import com.google.android.gms.cast.Cast; //导入方法依赖的package包/类
@Override
public void onResult(Cast.ApplicationConnectionResult result) {
    if (mState != STATE_LAUNCHING_APPLICATION) throwInvalidState();

    Status status = result.getStatus();
    if (!status.isSuccess()) {
        reportError(String.format(
                ERROR_NEW_ROUTE_LAUNCH_APPLICATION_FAILED_STATUS,
                mMediaSource.getApplicationId(),
                status.getStatusCode(),
                status.getStatusMessage()));
    }

    mState = STATE_LAUNCH_SUCCEEDED;
    reportSuccess(result.getSessionId(), result.getWasLaunched());
}
 
开发者ID:Smalinuxer,项目名称:Vafrinn,代码行数:17,代码来源:CreateRouteRequest.java

示例4: onResult

import com.google.android.gms.cast.Cast; //导入方法依赖的package包/类
@Override
public void onResult(Cast.ApplicationConnectionResult result) {
    if (mState != STATE_LAUNCHING_APPLICATION
            && mState != STATE_API_CONNECTION_SUSPENDED) {
        throwInvalidState();
    }

    Status status = result.getStatus();
    if (!status.isSuccess()) {
        Log.e(TAG, "Launch application failed with status: %s, %d, %s",
                mSource.getApplicationId(), status.getStatusCode(), status.getStatusMessage());
        reportError();
        return;
    }

    mState = STATE_LAUNCH_SUCCEEDED;
    reportSuccess(result);
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:19,代码来源:CreateRouteRequest.java

示例5: ConnectionCallbacks

import com.google.android.gms.cast.Cast; //导入方法依赖的package包/类
ConnectionCallbacks(boolean isPlaying, int position) {
	this.isPlaying = isPlaying;
	this.position = position;

	resultCallback = new ResultCallback<Cast.ApplicationConnectionResult>() {
		@Override
		public void onResult(Cast.ApplicationConnectionResult result) {
			Status status = result.getStatus();
			if (status.isSuccess()) {
				ApplicationMetadata applicationMetadata = result.getApplicationMetadata();
				sessionId = result.getSessionId();
				String applicationStatus = result.getApplicationStatus();
				boolean wasLaunched = result.getWasLaunched();

				applicationStarted = true;
				setupChannel();
			} else {
				shutdownInternal();
			}
		}
	};
}
 
开发者ID:popeen,项目名称:Popeens-DSub,代码行数:23,代码来源:ChromeCastController.java

示例6: verifyPlayMedia

import com.google.android.gms.cast.Cast; //导入方法依赖的package包/类
private com.google.android.gms.cast.MediaInfo verifyPlayMedia(MediaInfo mediaInfo) throws CastService.CastClientException {
    setServiceConnected();
    MediaPlayer.LaunchListener listener = Mockito.mock(MediaPlayer.LaunchListener.class);
    PendingResult<Cast.ApplicationConnectionResult> pendingResult
            = Mockito.mock(PendingResult.class);
    Mockito.when(castClient.launchApplication(Mockito.any(GoogleApiClient.class),
                    Mockito.anyString(), Mockito.any(LaunchOptions.class)))
            .thenReturn(pendingResult);


    // playMedia
    service.playMedia(mediaInfo, false, listener);
    Robolectric.runUiThreadTasksIncludingDelayedTasks();

    // CastApi.launchApplication
    Mockito.verify(castClient).launchApplication(Mockito.same(googleApiClient), Mockito.anyString(), Mockito.any(LaunchOptions.class));

    // ResultCallback.setResultCallback
    ArgumentCaptor<ResultCallback> argResultCallback =
            ArgumentCaptor.forClass(ResultCallback.class);
    Mockito.verify(pendingResult).setResultCallback(argResultCallback.capture());

    // ApplicationConnectionResultCallback.onResult
    ResultCallback resultCallback = argResultCallback.getValue();
    Cast.ApplicationConnectionResult result = Mockito.mock(Cast.ApplicationConnectionResult.class);
    Status status = Mockito.mock(Status.class);
    Mockito.when(status.isSuccess()).thenReturn(Boolean.TRUE);
    Mockito.when(result.getStatus()).thenReturn(status);
    ApplicationMetadata applicationMetadata = Mockito.mock(ApplicationMetadata.class);
    Mockito.when(result.getApplicationMetadata()).thenReturn(applicationMetadata);
    resultCallback.onResult(result);
    Robolectric.runUiThreadTasksIncludingDelayedTasks();

    // loadMedia
    ArgumentCaptor<com.google.android.gms.cast.MediaInfo> argMedia =
            ArgumentCaptor.forClass(com.google.android.gms.cast.MediaInfo.class);
    Mockito.verify(mediaPlayer).load(Mockito.same(googleApiClient), argMedia.capture(), Mockito.eq(true));
    return argMedia.getValue();
}
 
开发者ID:david-fenton,项目名称:Connect-SDK-Cordova-Plugin,代码行数:40,代码来源:CastServiceTest.java

示例7: launchApplication

import com.google.android.gms.cast.Cast; //导入方法依赖的package包/类
private PendingResult<Cast.ApplicationConnectionResult> launchApplication(
        GoogleApiClient apiClient,
        String appId,
        boolean relaunchIfRunning) {
    LaunchOptions.Builder builder = new LaunchOptions.Builder();
    return Cast.CastApi.launchApplication(apiClient, appId,
            builder.setRelaunchIfRunning(relaunchIfRunning)
                    .build());
}
 
开发者ID:mogoweb,项目名称:365browser,代码行数:10,代码来源:CreateRouteRequest.java

示例8: connectCastDevice

import com.google.android.gms.cast.Cast; //导入方法依赖的package包/类
private void connectCastDevice(boolean forceRelaunch) {
        final CastDevice selectedDevice = mCastDeviceHolder.getCastDevice();
        Timber.d("acquiring a connection to Google Play services for %s", selectedDevice);
        Cast.CastOptions.Builder apiOptionsBuilder = Cast.CastOptions.builder(selectedDevice, new CastListener())
                .setVerboseLoggingEnabled(true);
        mApiClient = new GoogleApiClient.Builder(mContext)
                .addApi(Cast.API, apiOptionsBuilder.build())
                        //XXX will deadlock, instead we repost callbacks to the handler
//                .setHandler(mCallbackHandler)
                .build();
        ConnectionResult res = mApiClient.blockingConnect();
        if (!res.isSuccess()) {
            stopWithError(res.getErrorMessage());
            return;
        }
        String applicationId = mContext.getString(R.string.cast_id);
        LaunchOptions.Builder launchOptions = new LaunchOptions.Builder()
                .setRelaunchIfRunning(forceRelaunch);
        Cast.ApplicationConnectionResult castRes;
        int retries = 0;
        do {
            Timber.d("launching cast application try %d", retries);
            castRes = Cast.CastApi.launchApplication(mApiClient, applicationId,
                    launchOptions.build()).await(30, TimeUnit.SECONDS);
            launchOptions.setRelaunchIfRunning(false);
        } while (!castRes.getStatus().isSuccess() && retries++ < 3);
        if (!castRes.getStatus().isSuccess()) {
            stopWithError(castRes.getStatus().getStatusMessage());
            mSessionId = null;
            return;
        }
        mSessionId = castRes.getSessionId();
        attachMediaChannel();
    }
 
开发者ID:OpenSilk,项目名称:Orpheus,代码行数:35,代码来源:CastRendererService.java

示例9: launchApplication

import com.google.android.gms.cast.Cast; //导入方法依赖的package包/类
private PendingResult<Cast.ApplicationConnectionResult> launchApplication(
        GoogleApiClient apiClient,
        String appId,
        boolean relaunchIfRunning) {
    return Cast.CastApi.launchApplication(apiClient, appId, relaunchIfRunning);
}
 
开发者ID:rkshuai,项目名称:chromium-for-android-56-debug-video,代码行数:7,代码来源:CreateRouteRequest.java

示例10: joinApplication

import com.google.android.gms.cast.Cast; //导入方法依赖的package包/类
@Override
public PendingResult<Cast.ApplicationConnectionResult> joinApplication(GoogleApiClient client) {
    return null;
}
 
开发者ID:microg,项目名称:android_external_GmsLib,代码行数:5,代码来源:CastApiImpl.java

示例11: launchApplication

import com.google.android.gms.cast.Cast; //导入方法依赖的package包/类
@Override
public PendingResult<Cast.ApplicationConnectionResult> launchApplication(GoogleApiClient client, String applicationId, LaunchOptions launchOptions) {
    return null;
}
 
开发者ID:microg,项目名称:android_external_GmsLib,代码行数:5,代码来源:CastApiImpl.java


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