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


Java CastSession类代码示例

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


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

示例1: playFiles

import com.google.android.gms.cast.framework.CastSession; //导入依赖的package包/类
@Override
public void playFiles(List<MediaQueueItem> mediaItems) {
    CastSession castSession =
            CastContext.getSharedInstance(this).getSessionManager().getCurrentCastSession();
    if (castSession == null) {
        Toast.makeText(this, "Not connected", Toast.LENGTH_LONG).show();
        return;
    }

    // For variety, shuffle the list.
    Collections.shuffle(mediaItems);

    Log.d(TAG, "playFiles: sending " + mediaItems.size() + " files to Chromecast");
    RemoteMediaClient mediaClient = castSession.getRemoteMediaClient();
    int startIndex = 0;
    mediaClient.queueLoad(mediaItems.toArray(new MediaQueueItem[0]), startIndex,
            MediaStatus.REPEAT_MODE_REPEAT_ALL_AND_SHUFFLE, null);
}
 
开发者ID:stephenmcgruer,项目名称:simple-upnp,代码行数:19,代码来源:MainActivity.java

示例2: onPause

import com.google.android.gms.cast.framework.CastSession; //导入依赖的package包/类
@Override
public void onPause() {
    super.onPause();

    if (castContext != null)
        castContext.getSessionManager().removeSessionManagerListener(
                sessionManagerListener, CastSession.class);

    switch (location) {
        case LOCAL:
            pauseLocalVideo();
            break;
        case REMOTE:
            break;
        default:
            break;
    }

}
 
开发者ID:SalmanTKhan,项目名称:MyAnimeViewer,代码行数:20,代码来源:VideoDetailsFragment.java

示例3: onPause

import com.google.android.gms.cast.framework.CastSession; //导入依赖的package包/类
@Override
protected void onPause() {
    super.onPause();
    Log.d(TAG, "onPause() was called");
    if (mLocation == PlaybackLocation.LOCAL) {

        if (mSeekbarTimer != null) {
            mSeekbarTimer.cancel();
            mSeekbarTimer = null;
        }
        if (mControllersTimer != null) {
            mControllersTimer.cancel();
        }
        // since we are playing locally, we need to stop the playback of
        // video (if user is not watching, pause it!)
        mVideoView.pause();
        mPlaybackState = PlaybackState.PAUSED;
        updatePlayButton(PlaybackState.PAUSED);
    }
    mCastContext.getSessionManager().removeSessionManagerListener(
            mSessionManagerListener, CastSession.class);
}
 
开发者ID:nordfalk,项目名称:EsperantoRadio,代码行数:23,代码来源:LocalPlayerActivity.java

示例4: onResume

import com.google.android.gms.cast.framework.CastSession; //导入依赖的package包/类
@Override
protected void onResume() {
    Log.d(TAG, "onResume() was called");
    mCastContext.getSessionManager().addSessionManagerListener(
            mSessionManagerListener, CastSession.class);
    if (mCastSession != null && mCastSession.isConnected()) {
        updatePlaybackLocation(PlaybackLocation.REMOTE);
    } else {
        updatePlaybackLocation(PlaybackLocation.LOCAL);
    }
    if (mQueueMenuItem != null) {
        mQueueMenuItem.setVisible(
                (mCastSession != null) && mCastSession.isConnected());
    }
    super.onResume();
}
 
开发者ID:nordfalk,项目名称:EsperantoRadio,代码行数:17,代码来源:LocalPlayerActivity.java

示例5: updatePlayPauseButtonImageResource

import com.google.android.gms.cast.framework.CastSession; //导入依赖的package包/类
private void updatePlayPauseButtonImageResource(ImageButton button) {
    CastSession castSession = CastContext.getSharedInstance(mAppContext)
            .getSessionManager().getCurrentCastSession();
    RemoteMediaClient remoteMediaClient =
            (castSession == null) ? null : castSession.getRemoteMediaClient();
    if (remoteMediaClient == null) {
        button.setVisibility(View.GONE);
        return;
    }
    int status = remoteMediaClient.getPlayerState();
    switch (status) {
        case MediaStatus.PLAYER_STATE_PLAYING:
            button.setImageResource(PAUSE_RESOURCE);
            break;
        case MediaStatus.PLAYER_STATE_PAUSED:
            button.setImageResource(PLAY_RESOURCE);
            break;
        default:
            button.setVisibility(View.GONE);
    }
}
 
开发者ID:nordfalk,项目名称:EsperantoRadio,代码行数:22,代码来源:QueueListAdapter.java

示例6: onResume

import com.google.android.gms.cast.framework.CastSession; //导入依赖的package包/类
@Override
protected void onResume() {
    mCastContext.getSessionManager().addSessionManagerListener(
            mSessionManagerListener, CastSession.class);
    if (mRemoteMediaClient == null) {
        mRemoteMediaClient = getRemoteMediaClient();
    }
    if (mRemoteMediaClient != null) {
        mRemoteMediaClient.addListener(mRemoteMediaClientListener);
        MediaStatus mediaStatus = mRemoteMediaClient.getMediaStatus();
        List<MediaQueueItem> queueItems =
                (mediaStatus == null) ? null : mediaStatus.getQueueItems();
        if (queueItems != null && !queueItems.isEmpty()) {
            mEmptyView.setVisibility(View.GONE);
        }
    }
    super.onResume();
}
 
开发者ID:nordfalk,项目名称:EsperantoRadio,代码行数:19,代码来源:QueueListViewActivity.java

示例7: onSessionStarted

import com.google.android.gms.cast.framework.CastSession; //导入依赖的package包/类
@Override
public void onSessionStarted(CastSession castSession, String sessionId) {
    Log.v(TAG, "Session started");
    mCastSession = castSession;
    invalidateOptionsMenu();
    startCustomMessageChannel();

    sendCredentials();
    dashboard.setOnDataRefreshListener(new OnCompleteCallback() {
        @Override
        public void onComplete() {
            sendAllOptions();
            (new CastCommunicator(mCastSession)).sendAllWidgets(getApplicationContext(), getDashboard());
        }

        @Override
        public void onError(Exception e) {
            Bundle bundle = new Bundle();
            bundle.putString("ERROR", e.toString());
            mFirebaseAnalytics.logEvent("ON_CONNECTED_REFRESH_ON_ERROR", bundle);
        }
    });

}
 
开发者ID:dan-silver,项目名称:cast-dashboard-android-app,代码行数:25,代码来源:MainActivity.java

示例8: onDestroy

import com.google.android.gms.cast.framework.CastSession; //导入依赖的package包/类
/**
 * (non-Javadoc)
 * @see android.app.Service#onDestroy()
 */
@Override
public void onDestroy() {
    LogHelper.d(TAG, "onDestroy");
    unregisterCarConnectionReceiver();
    // Service is being killed, so make sure we release our resources
    mPlaybackManager.handleStopRequest(null);
    mMediaNotificationManager.stopNotification();

    if (mCastSessionManager != null) {
        mCastSessionManager.removeSessionManagerListener(mCastSessionManagerListener,
                CastSession.class);
    }

    mDelayedStopHandler.removeCallbacksAndMessages(null);
    mSession.release();
}
 
开发者ID:googlesamples,项目名称:android-UniversalMusicPlayer,代码行数:21,代码来源:MusicService.java

示例9: onPause

import com.google.android.gms.cast.framework.CastSession; //导入依赖的package包/类
@Override
public void onPause() {
    super.onPause();

    castContext.getSessionManager().removeSessionManagerListener(
            sessionManagerListener, CastSession.class);

    switch (location) {
        case LOCAL:
            pauseLocalVideo();
            break;
        case REMOTE:
            break;
        default:
            break;
    }

}
 
开发者ID:lawloretienne,项目名称:Loop,代码行数:19,代码来源:VideoDetailsFragment.java

示例10: onResume

import com.google.android.gms.cast.framework.CastSession; //导入依赖的package包/类
@Override
protected void onResume() {
    super.onResume();
    Utils.log(TAG, "--- onResume()");
    if (Utils.isGooglePlayServicesAvailable(this)) {
        try {
            mCastContext.getSessionManager().addSessionManagerListener(
                    mSessionManagerListener, CastSession.class);
        } catch (Exception e) {
            Log.e(TAG, "Cast Error - onResume", e);
        }
    }
    hideSearch();
    if (wifiLock == null) {
        wifiLock = Utils.getWifiLock();
    }
}
 
开发者ID:konir,项目名称:RadioRecPlus,代码行数:18,代码来源:RadioRecPlusActivity.java

示例11: onResume

import com.google.android.gms.cast.framework.CastSession; //导入依赖的package包/类
@Override
public void onResume() {
    super.onResume();

    if (castContext != null)
        castContext.getSessionManager().addSessionManagerListener(
                sessionManagerListener, CastSession.class);

    if (castSession != null && castSession.isConnected()) {
        location = PlaybackLocation.REMOTE;
    } else {
        location = PlaybackLocation.LOCAL;
    }

    if (!isLocalVideoPlaying() && playbackState == PlaybackState.PLAYING) {
        switch (location) {
            case LOCAL:
                resumeLocalVideo();
                break;
            case REMOTE:
                updateLocalVideoPosition(castSession.getRemoteMediaClient().getApproximateStreamPosition());
                resumeLocalVideo();
                break;
            default:
                break;
        }
    }
}
 
开发者ID:SalmanTKhan,项目名称:MyAnimeViewer,代码行数:29,代码来源:VideoDetailsFragment.java

示例12: registerCast

import com.google.android.gms.cast.framework.CastSession; //导入依赖的package包/类
private void registerCast() {
    if (TextUtils.isEmpty(getString(R.string.cast_app_id)))
        return;
    mCastContext.addCastStateListener(mCastStateListener);
    mCastContext.getSessionManager().addSessionManagerListener(
            mSessionManagerListener, CastSession.class);
    if (mCastSession == null) {
        mCastSession = CastContext.getSharedInstance(this).getSessionManager()
                .getCurrentCastSession();
    }
    if (mQueueMenuItem != null) {
        mQueueMenuItem.setVisible(
                (mCastSession != null) && mCastSession.isConnected());
    }
}
 
开发者ID:SalmanTKhan,项目名称:MyAnimeViewer,代码行数:16,代码来源:AnimeDetailsActivity.java

示例13: unregisterCast

import com.google.android.gms.cast.framework.CastSession; //导入依赖的package包/类
private void unregisterCast() {
    if (TextUtils.isEmpty(getString(R.string.cast_app_id)))
        return;
    mCastContext.removeCastStateListener(mCastStateListener);
    mCastContext.getSessionManager().removeSessionManagerListener(
            mSessionManagerListener, CastSession.class);
}
 
开发者ID:SalmanTKhan,项目名称:MyAnimeViewer,代码行数:8,代码来源:AnimeDetailsActivity.java

示例14: onSessionEnded

import com.google.android.gms.cast.framework.CastSession; //导入依赖的package包/类
@Override
public void onSessionEnded(CastSession session, int error) {
    if (session == mCastSession) {
        mCastSession = null;
    }
    invalidateOptionsMenu();
}
 
开发者ID:SalmanTKhan,项目名称:MyAnimeViewer,代码行数:8,代码来源:AnimeDetailsActivity.java

示例15: handleCurrentCastSession

import com.google.android.gms.cast.framework.CastSession; //导入依赖的package包/类
private void handleCurrentCastSession() {
    CastSession newCastSession = CastContext.getSharedInstance(activity).getSessionManager().getCurrentCastSession();
    if (castSession == null) {
        if (newCastSession != null) {
            onConnected(newCastSession);
        }
    } else {
        if (newCastSession == null) {
            onDisconnected();
        } else if (newCastSession != castSession) {
            onConnected(newCastSession);
        }
    }
}
 
开发者ID:DroidsOnRoids,项目名称:Casty,代码行数:15,代码来源:Casty.java


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