本文整理汇总了Java中com.google.cast.CastContext类的典型用法代码示例。如果您正苦于以下问题:Java CastContext类的具体用法?Java CastContext怎么用?Java CastContext使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CastContext类属于com.google.cast包,在下文中一共展示了CastContext类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onStart
import com.google.cast.CastContext; //导入依赖的package包/类
@Override
protected void onStart() {
super.onStart();
checkPlayerName();
awesomePointsView.setText(awesomePoints+"");
CastDevice selectedDevice = CastCAHApplication.getInstance().getDevice();
CastContext castContext = CastCAHApplication.getInstance().getCastContext();
mSession = new ApplicationSession(castContext, selectedDevice);
mSession.setListener(mSessionListener);
try {
mSession.startSession(API_KEY);
} catch (IOException e) {
Log.e(TAG, "Failed to open a session", e);
}
}
示例2: onStart
import com.google.cast.CastContext; //导入依赖的package包/类
/**
* Called on application start. Using the previously selected Cast device, attempts to begin a
* session using the application name TicTacToe.
*/
@Override
protected void onStart() {
super.onStart();
CastDevice selectedDevice = TicTacToeApplication.getInstance().getDevice();
CastContext castContext =
TicTacToeApplication.getInstance().getCastContext();
mSession = new ApplicationSession(castContext, selectedDevice);
mSession.setListener(mSessionListener);
try {
mSession.startSession("TicTacToe");
} catch (IOException e) {
Log.e(TAG, "Failed to open a session", e);
}
}
示例3: initialize
import com.google.cast.CastContext; //导入依赖的package包/类
public void initialize(CordovaInterface cordova, CordovaWebView webView) {
super.initialize(cordova, webView);
//Logger.setDebugEnabledByDefault(true);
receiverCallback = null;
statusCallback = null;
castContext = new CastContext(cordova.getActivity().getApplicationContext());
MediaRouteHelper.registerMinimalMediaRouteProvider(castContext, this);
mediaRouter = MediaRouter.getInstance(cordova.getActivity().getApplicationContext());
mediaRouteSelector = MediaRouteHelper.buildMediaRouteSelector(MediaRouteHelper.CATEGORY_CAST, APP_ID, null);
mediaRouterCallback = new MediaRouterCallback();
mediaRouter.addCallback(mediaRouteSelector, mediaRouterCallback, MediaRouter.CALLBACK_FLAG_REQUEST_DISCOVERY);
Runnable runnable = new StatusRunner();
new Thread(runnable).start();
}
示例4: onCreate
import com.google.cast.CastContext; //导入依赖的package包/类
/**
* Initializes MediaRouter information and prepares for Cast device detection upon creating
* this activity.
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
logVIfEnabled(TAG, "onCreate called");
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cast_sample);
mCastContext = new CastContext(getApplicationContext());
mMedia = new CastMedia(null, null);
mMetaData = new ContentMetadata();
mDialogFactory = new SampleMediaRouteDialogFactory();
MediaRouteHelper.registerMinimalMediaRouteProvider(mCastContext, this);
mMediaRouter = MediaRouter.getInstance(getApplicationContext());
mMediaRouteSelector = MediaRouteHelper
.buildMediaRouteSelector(MediaRouteHelper.CATEGORY_CAST);
mMediaRouteButton = (MediaRouteButton) findViewById(R.id.media_route_button);
mMediaRouteButton.setRouteSelector(mMediaRouteSelector);
mMediaRouteButton.setDialogFactory(mDialogFactory);
mMediaRouterCallback = new MyMediaRouterCallback();
mStatusText = (TextView) findViewById(R.id.play_status_text);
mCurrentlyPlaying = (TextView) findViewById(R.id.currently_playing);
mCurrentlyPlaying.setText(getString(R.string.tap_to_select));
mMediaSelectionDialog = new MediaSelectionDialog(this);
mPlayPauseButton = (ImageButton) findViewById(R.id.play_pause_button);
mStopButton = (ImageButton) findViewById(R.id.stop_button);
initButtons();
Thread myThread = null;
Runnable runnable = new StatusRunner();
myThread = new Thread(runnable);
logVIfEnabled(TAG, "Starting statusRunner thread");
myThread.start();
}
示例5: startSession
import com.google.cast.CastContext; //导入依赖的package包/类
public void startSession(CastContext castContext) {
mKillingSession = false;
mSession = new ApplicationSession(castContext, getDevice());
mSession.setListener(new SessionListener());
try {
mSession.startSession(castContext.getApplicationContext()
.getString(R.string.app_id));
} catch (IOException e) {
System.err.println(e);
}
}
示例6: onCreate
import com.google.cast.CastContext; //导入依赖的package包/类
@Override
public void onCreate() {
mCastContext = new CastContext(getApplicationContext());
mInstance = this;
showNotification();
}
示例7: initMediaRouter
import com.google.cast.CastContext; //导入依赖的package包/类
private void initMediaRouter() {
mSessionListener = new SessionListener();
mMessageStream = new CustomHipstaCasterStream();
mCastContext = new CastContext(getApplicationContext());
MediaRouteHelper.registerMinimalMediaRouteProvider(mCastContext, this);
mMediaRouter = MediaRouter.getInstance(getApplicationContext());
mMediaRouteSelector = MediaRouteHelper.buildMediaRouteSelector(
MediaRouteHelper.CATEGORY_CAST, APP_NAME, null);
mMediaRouterCallback = new MediaRouterCallback();
}
示例8: onCreate
import com.google.cast.CastContext; //导入依赖的package包/类
/**
* Initializes MediaRouter information and prepares for Cast device detection upon creating
* this activity.
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
logVIfEnabled(TAG, "onCreate called");
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cast_sample);
mCastContext = new CastContext(getApplicationContext());
mMedia = new CastMedia(null, null);
mMetaData = new ContentMetadata();
mDialogFactory = new SampleMediaRouteDialogFactory();
MediaRouteHelper.registerMinimalMediaRouteProvider(mCastContext, this);
mMediaRouter = MediaRouter.getInstance(getApplicationContext());
mMediaRouteSelector = MediaRouteHelper
.buildMediaRouteSelector(MediaRouteHelper.CATEGORY_CAST,
getResources().getString(R.string.app_name), null);
mMediaRouteButton = (MediaRouteButton) findViewById(R.id.media_route_button);
mMediaRouteButton.setRouteSelector(mMediaRouteSelector);
mMediaRouteButton.setDialogFactory(mDialogFactory);
mMediaRouterCallback = new MyMediaRouterCallback();
mStatusText = (TextView) findViewById(R.id.play_status_text);
mCurrentlyPlaying = (TextView) findViewById(R.id.currently_playing);
mCurrentlyPlaying.setText(getString(R.string.tap_to_select));
mMediaSelectionDialog = new MediaSelectionDialog(this);
mPlayPauseButton = (ImageButton) findViewById(R.id.play_pause_button);
mStopButton = (ImageButton) findViewById(R.id.stop_button);
initButtons();
Thread myThread = null;
Runnable runnable = new StatusRunner();
myThread = new Thread(runnable);
logVIfEnabled(TAG, "Starting statusRunner thread");
myThread.start();
}
示例9: onCreate
import com.google.cast.CastContext; //导入依赖的package包/类
/**
* Initializes the CastContext associated with this application's context, upon application
* creation.
*/
@Override
public final void onCreate() {
super.onCreate();
singleton = this;
try {
mCastContext = new CastContext(getApplicationContext());
} catch (IllegalArgumentException e) {
sLog.e(e, "Unable to create CastContext");
}
}
示例10: getCastContext
import com.google.cast.CastContext; //导入依赖的package包/类
/**
* Returns the CastContext associated with this application's context.
*/
public CastContext getCastContext() {
return mCastContext;
}
示例11: onCreate
import com.google.cast.CastContext; //导入依赖的package包/类
/**
* Initializes MediaRouter information and prepares for Cast device
* detection upon creating this activity.
*/
@Override
protected void onCreate(Bundle savedInstanceState) {
logVIfEnabled(TAG, "onCreate called");
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_cast);
mCastContext = new CastContext(getApplicationContext());
mMedia = new CastMedia(null, null);
mMetaData = new ContentMetadata();
mDialogFactory = new SampleMediaRouteDialogFactory();
MediaRouteHelper.registerMinimalMediaRouteProvider(mCastContext, this);
mMediaRouter = MediaRouter.getInstance(getApplicationContext());
mMediaRouteSelector = MediaRouteHelper
.buildMediaRouteSelector(MediaRouteHelper.CATEGORY_CAST);
mMediaRouteButton = (MediaRouteButton) findViewById(R.id.media_route_button);
mMediaRouteButton.setRouteSelector(mMediaRouteSelector);
mMediaRouteButton.setDialogFactory(mDialogFactory);
mMediaRouterCallback = new MyMediaRouterCallback();
mStatusText = (TextView) findViewById(R.id.play_status_text);
mCurrentlyPlaying = (TextView) findViewById(R.id.currently_playing);
mCurrentlyPlaying.setText(getString(R.string.tap_to_select));
mPlayPauseButton = (ImageButton) findViewById(R.id.play_pause_button);
mStopButton = (ImageButton) findViewById(R.id.stop_button);
initButtons();
myThread = null;
Runnable runnable = new StatusRunner();
myThread = new Thread(runnable);
logVIfEnabled(TAG, "Starting statusRunner thread");
myThread.start();
Intent intent = getIntent();
String url = intent.getStringExtra("MEDIA_URL");
urls = intent.getStringArrayListExtra("MEDIA_URL_LIST");
if (urls == null || urls.size() == 0) {
urls = new ArrayList<String>();
urls.add(url);
}
title = intent.getStringExtra("MEDIA_TITLE");
if (title == null || title.isEmpty())
title = urls.get(0);
this.mediaSelected(new CastMedia(title, urls.get(0)));
nextUrl++;
}