Java Code Examples for android.support.v7.media.MediaRouter#RouteInfo

The following examples show how to use android.support.v7.media.MediaRouter#RouteInfo . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MainActivity.java    From android-MediaRouter with Apache License 2.0 6 votes vote down vote up
private void updateButtons() {
    MediaRouter.RouteInfo route = mMediaRouter.getSelectedRoute();
    // show pause or resume icon depending on current state
    mPauseResumeButton.setImageResource(
            mPaused ? R.drawable.ic_action_play : R.drawable.ic_action_pause);
    // disable pause/resume/stop if no session
    mPauseResumeButton.setEnabled(mSessionManager.hasSession());
    mStopButton.setEnabled(mSessionManager.hasSession());
    // only enable seek bar when duration is known
    PlaylistItem item = getCheckedPlaylistItem();
    mSeekBar.setEnabled(item != null && item.getDuration() > 0);
    if (mRemoteControlClient != null) {
        mRemoteControlClient.setPlaybackState(mPaused ? RemoteControlClient.PLAYSTATE_PAUSED :
                RemoteControlClient.PLAYSTATE_PLAYING);
    }
}
 
Example 2
Source File: DiscoveryCallback.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void onRouteChanged(MediaRouter router, MediaRouter.RouteInfo route) {
    // Sometimes onRouteAdded is not called for the route as it doesn't yet match the selector.
    // onRouteChanged() will be called later when the matching category is added.
    if (route == null) return;

    if (route.matchesSelector(mRouteSelector)) {
        onRouteAdded(router, route);
    } else {
        onRouteRemoved(router, route);
    }
}
 
Example 3
Source File: GoogleCompat.java    From Popeens-DSub with GNU General Public License v3.0 5 votes vote down vote up
public static RemoteController getController(DownloadService downloadService, MediaRouter.RouteInfo info) {
    CastDevice device = CastDevice.getFromBundle(info.getExtras());
    if(device != null) {
        return new ChromeCastController(downloadService, device);
    } else {
        return null;
    }
}
 
Example 4
Source File: DiscoveryCallback.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void onRouteChanged(MediaRouter router, MediaRouter.RouteInfo route) {
    // Sometimes onRouteAdded is not called for the route as it doesn't yet match the selector.
    // onRouteChanged() will be called later when the matching category is added.
    if (route == null) return;

    if (route.matchesSelector(mRouteSelector)) {
        onRouteAdded(router, route);
    } else {
        onRouteRemoved(router, route);
    }
}
 
Example 5
Source File: DiscoveryCallback.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public void onRouteRemoved(MediaRouter router, MediaRouter.RouteInfo route) {
    MediaSink sink = MediaSink.fromRoute(route);
    if (!mSinks.contains(sink)) return;
    mSinks.remove(sink);
    updateChromeMediaRouter();
}
 
Example 6
Source File: MediaSink.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * @param route The route information provided by Android.
 * @return A new MediaSink instance corresponding to the specified {@link RouteInfo}.
 */
public static MediaSink fromRoute(MediaRouter.RouteInfo route) {
    return new MediaSink(
        route.getId(),
        route.getName(),
        CastDevice.getFromBundle(route.getExtras()));
}
 
Example 7
Source File: MediaSink.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * @param route The route information provided by Android.
 * @return A new MediaSink instance corresponding to the specified {@link RouteInfo}.
 */
public static MediaSink fromRoute(MediaRouter.RouteInfo route) {
    return new MediaSink(
        route.getId(),
        route.getName(),
        CastDevice.getFromBundle(route.getExtras()));
}
 
Example 8
Source File: DiscoveryCallback.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void onRouteRemoved(MediaRouter router, MediaRouter.RouteInfo route) {
    MediaSink sink = MediaSink.fromRoute(route);
    if (!mSinks.contains(sink)) return;
    mSinks.remove(sink);
    updateChromeMediaRouter();
}
 
Example 9
Source File: DiscoveryCallback.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public void onRouteAdded(MediaRouter router, MediaRouter.RouteInfo route) {
    if (route == null || !route.matchesSelector(mRouteSelector)) return;

    MediaSink sink = MediaSink.fromRoute(route);
    if (mSinks.contains(sink)) return;
    mSinks.add(sink);
    updateChromeMediaRouter();
}
 
Example 10
Source File: MediaSink.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * @param sinkId The id of the sink to find among known media routes.
 * @param router The instance of {@link MediaRouter} to enumerate the routes with.
 * @return A {@link MediaSink} corresponding to the {@link RouteInfo} with the specified id if
 * found, null otherwise.
 */
@Nullable
public static MediaSink fromSinkId(String sinkId, MediaRouter router) {
    for (MediaRouter.RouteInfo route : router.getRoutes()) {
        MediaSink sink = MediaSink.fromRoute(route);
        if (sink.getId().equals(sinkId)) return sink;
    }
    return null;
}
 
Example 11
Source File: MediaSink.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * @param route The route information provided by Android.
 * @return A new MediaSink instance corresponding to the specified {@link RouteInfo}.
 */
public static MediaSink fromRoute(MediaRouter.RouteInfo route) {
    return new MediaSink(
        route.getId(),
        route.getName(),
        CastDevice.getFromBundle(route.getExtras()));
}
 
Example 12
Source File: DiscoveryCallback.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void onRouteChanged(MediaRouter router, MediaRouter.RouteInfo route) {
    // Sometimes onRouteAdded is not called for the route as it doesn't yet match the selector.
    // onRouteChanged() will be called later when the matching category is added.
    if (route == null) return;

    if (route.matchesSelector(mRouteSelector)) {
        onRouteAdded(router, route);
    } else {
        onRouteRemoved(router, route);
    }
}
 
Example 13
Source File: DiscoveryCallback.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void onRouteRemoved(MediaRouter router, MediaRouter.RouteInfo route) {
    MediaSink sink = MediaSink.fromRoute(route);
    if (!mSinks.contains(sink)) return;
    mSinks.remove(sink);
    updateChromeMediaRouter();
}
 
Example 14
Source File: DiscoveryCallback.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public void onRouteAdded(MediaRouter router, MediaRouter.RouteInfo route) {
    if (route == null || !route.matchesSelector(mRouteSelector)) return;

    MediaSink sink = MediaSink.fromRoute(route);
    if (mSinks.contains(sink)) return;
    mSinks.add(sink);
    updateChromeMediaRouter();
}
 
Example 15
Source File: MediaSink.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * @param sinkId The id of the sink to find among known media routes.
 * @param router The instance of {@link MediaRouter} to enumerate the routes with.
 * @return A {@link MediaSink} corresponding to the {@link RouteInfo} with the specified id if
 * found, null otherwise.
 */
@Nullable
public static MediaSink fromSinkId(String sinkId, MediaRouter router) {
    for (MediaRouter.RouteInfo route : router.getRoutes()) {
        MediaSink sink = MediaSink.fromRoute(route);
        if (sink.getId().equals(sinkId)) return sink;
    }
    return null;
}
 
Example 16
Source File: MediaRouteControllerDialogManager.java    From AndroidChromium with Apache License 2.0 4 votes vote down vote up
@Override
public void onRouteUnselected(MediaRouter router, MediaRouter.RouteInfo route) {
    delegate().onRouteClosed(mMediaRouteId);
}
 
Example 17
Source File: MediaRouterRouteInfoAssert.java    From assertj-android with Apache License 2.0 4 votes vote down vote up
public MediaRouterRouteInfoAssert(MediaRouter.RouteInfo actual) {
  super(actual, MediaRouterRouteInfoAssert.class);
}
 
Example 18
Source File: MovieActivity.java    From android with Apache License 2.0 4 votes vote down vote up
@Override
protected void onCreate(Bundle savedInstanceState) {

    mPrefs = PreferenceManager.getDefaultSharedPreferences(this);
    setTheme(mPrefs.getString("current_theme", "holo_light").equals("holo_dark") ? R.style.AppThemeDark : R.style.AppThemeLight);

    super.onCreate(savedInstanceState);

    AppUtils.setStatusTint(this);

    Bundle extras = getIntent().getExtras();
    mTitle = extras.getString(ARG_TITLE);
    mLink = extras.getString(ARG_LINK);
    mImageUri = extras.getString(ARG_IMAGE_URI);
    mRating = extras.getInt(ARG_RATING);

    overridePendingTransition(android.R.anim.fade_in, android.R.anim.fade_out);

    setContentView(R.layout.activity_movie);

    if (savedInstanceState == null) {
        FragmentManager fm = getSupportFragmentManager();
        FragmentTransaction ft = fm.beginTransaction();
        ft.replace(R.id.fragment_container, MirrorsFragment.newInstance(mTitle, mLink, null, null, mImageUri, -1, -1, mRating));
        ft.commit();
    }

    ActionBar actionBar = getSupportActionBar();
    actionBar.setDisplayHomeAsUpEnabled(true);
    actionBar.setTitle(mTitle);

    if (AppUtils.isChromecastPluginInstalled(this)) {
        mCastManager = CastApplication.getCastManager(this.getApplicationContext());
    }
    // -- Adding MiniController
    mMini = (MiniController) findViewById(R.id.miniController1);
    if (mCastManager != null) {
        mCastManager.addMiniController(mMini);
    }

    mCastConsumer = new VideoCastConsumerImpl() {

        @Override
        public void onFailed(int resourceId, int statusCode) {

        }

        @Override
        public void onConnectionSuspended(int cause) {
            Log.d(TAG, "onConnectionSuspended() was called with cause: " + cause);
            AppUtils.showToast(MovieActivity.this, R.string.connection_temp_lost);
        }

        @Override
        public void onConnectivityRecovered() {
            AppUtils.showToast(MovieActivity.this, R.string.connection_recovered);
        }

        @Override
        public void onCastDeviceDetected(final MediaRouter.RouteInfo info) {
            if (!SettingsActivity.isFtuShown(MovieActivity.this)) {
                SettingsActivity.setFtuShown(MovieActivity.this);

                Log.d(TAG, "Route is visible: " + info);
                new Handler().postDelayed(new Runnable() {

                    @Override
                    public void run() {
                        if (mediaRouteMenuItem.isVisible()) {
                            Log.d(TAG, "Cast Icon is visible: " + info.getName());
                            showFtu();
                        }
                    }
                }, 1000);
            }
        }
    };

    if (mCastManager != null) {
        mCastManager.reconnectSessionIfPossible(this, false);
    }
}
 
Example 19
Source File: MediaRouteControllerDialogManager.java    From delion with Apache License 2.0 4 votes vote down vote up
@Override
public void onRouteUnselected(MediaRouter router, MediaRouter.RouteInfo route) {
    delegate().onRouteClosed(mMediaRouteId);
}
 
Example 20
Source File: GoogleCompat.java    From Popeens-DSub with GNU General Public License v3.0 4 votes vote down vote up
public static RemoteController getController(DownloadService downloadService, MediaRouter.RouteInfo info) {
    return null;
}