@Override protected void onCreate(Bundle savedInstanceState) { Log.d(TAG, "StandaloneDisplayActivity.onCreate()"); super.onCreate(savedInstanceState); int layout = getLayout(); getWindow().addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON); setContentView(layout); displayLayout = (DisplayLayout) findViewById(R.id.display); ActionBar ab = getActionBar(); if (ab != null) { ab.hide(); } if (!getIntent().getBooleanExtra(EXTRA_MIRROR_DISPLAY, false)) { mediaRouter = (MediaRouter) getSystemService(MEDIA_ROUTER_SERVICE); mediaRouter .addCallback(MediaRouter.ROUTE_TYPE_LIVE_VIDEO, callback); updatePresentation(); } displayLayout.go(0, false); View view = findViewById(R.id.display_attributes); DisplayInfoHelper.populate(this, view, getWindowManager().getDefaultDisplay()); DisplayInfoHelper.show(view, DURATION); }
private final void e() { MediaRouter localMediaRouter = (MediaRouter)this.i; int i1 = localMediaRouter.getRouteCount(); ArrayList localArrayList = new ArrayList(i1); for (int i2 = 0; i2 < i1; i2++) { localArrayList.add(localMediaRouter.getRouteAt(i2)); } Iterator localIterator = localArrayList.iterator(); boolean bool = false; while (localIterator.hasNext()) { bool |= f(localIterator.next()); } if (bool) { a(); } }
public final void a(aay paramaay) { aax localaax = paramaay.a; aao.a(); if (localaax.a != this) { Object localObject1 = this.i; Object localObject2 = this.s; MediaRouter.UserRouteInfo localUserRouteInfo = ((MediaRouter)localObject1).createUserRoute((MediaRouter.RouteCategory)localObject2); abz localabz = new abz(paramaay, localUserRouteInfo); ((MediaRouter.RouteInfo)localUserRouteInfo).setTag(localabz); Object localObject3 = this.r; ((MediaRouter.UserRouteInfo)localUserRouteInfo).setVolumeCallback((MediaRouter.VolumeCallback)localObject3); a(localabz); this.t.add(localabz); ((MediaRouter)this.i).addUserRoute((MediaRouter.UserRouteInfo)localUserRouteInfo); } int i1; do { return; i1 = g(((MediaRouter)this.i).getSelectedRoute(8388611)); } while ((i1 < 0) || (!((aby)this.n.get(i1)).b.equals(paramaay.b))); aao.a(); aao.b.a(paramaay, 3); }
protected void a(aby paramaby, aad paramaad) { int i1 = ((MediaRouter.RouteInfo)paramaby.a).getSupportedTypes(); if ((i1 & 0x1) != 0) { paramaad.a(o); } if ((i1 & 0x2) != 0) { paramaad.a(p); } int i2 = ((MediaRouter.RouteInfo)paramaby.a).getPlaybackType(); paramaad.a.putInt("playbackType", i2); int i3 = ((MediaRouter.RouteInfo)paramaby.a).getPlaybackStream(); paramaad.a.putInt("playbackStream", i3); int i4 = ((MediaRouter.RouteInfo)paramaby.a).getVolume(); paramaad.a.putInt("volume", i4); int i5 = ((MediaRouter.RouteInfo)paramaby.a).getVolumeMax(); paramaad.a.putInt("volumeMax", i5); int i6 = ((MediaRouter.RouteInfo)paramaby.a).getVolumeHandling(); paramaad.a.putInt("volumeHandling", i6); }
public final void a(Object paramObject) { if (paramObject != ((MediaRouter)this.i).getSelectedRoute(8388611)) {} aay localaay1; do { int i1; do { return; abz localabz = i(paramObject); if (localabz != null) { aay localaay2 = localabz.a; aao.a(); aao.b.a(localaay2, 3); return; } i1 = g(paramObject); } while (i1 < 0); aby localaby = (aby)this.n.get(i1); localaay1 = this.q.a(localaby.b); } while (localaay1 == null); aao.a(); aao.b.a(localaay1, 3); }
protected void b() { if (this.m) { this.m = false; Object localObject3 = this.i; Object localObject4 = this.j; ((MediaRouter)localObject3).removeCallback((MediaRouter.Callback)localObject4); } if (this.k != 0) { this.m = true; Object localObject1 = this.i; int i1 = this.k; Object localObject2 = this.j; ((MediaRouter)localObject1).addCallback(i1, (MediaRouter.Callback)localObject2); } }
public final void b(aay paramaay) { aax localaax = paramaay.a; aao.a(); if (localaax.a != this) { int i1 = e(paramaay); if (i1 >= 0) { abz localabz = (abz)this.t.remove(i1); ((MediaRouter.RouteInfo)localabz.b).setTag(null); ((MediaRouter.UserRouteInfo)localabz.b).setVolumeCallback((MediaRouter.VolumeCallback)null); Object localObject1 = this.i; Object localObject2 = localabz.b; ((MediaRouter)localObject1).removeUserRoute((MediaRouter.UserRouteInfo)localObject2); } } }
public final Object a(Object paramObject) { MediaRouter localMediaRouter = (MediaRouter)paramObject; if (this.a != null) {} try { Object localObject = this.a.invoke(localMediaRouter, new Object[0]); return localObject; } catch (InvocationTargetException localInvocationTargetException) { return localMediaRouter.getRouteAt(0); } catch (IllegalAccessException localIllegalAccessException) { label31: break label31; } }
/** * Initialization of the Activity after it is first created. Must at least * call {@link android.app.Activity#setContentView setContentView()} to * describe what is to be displayed in the screen. */ @Override protected void onCreate(Bundle savedInstanceState) { // Be sure to call the super class. super.onCreate(savedInstanceState); // Get the media router service. mMediaRouter = (MediaRouter)getSystemService(Context.MEDIA_ROUTER_SERVICE); // See assets/res/any/layout/presentation_with_media_router_activity.xml for this // view layout definition, which is being set here as // the content of our screen. setContentView(R.layout.presentation_with_media_router_activity); // Set up the surface view for visual interest. mSurfaceView = (GLSurfaceView)findViewById(R.id.surface_view); mSurfaceView.setRenderer(new CubeRenderer(false)); // Get a text view where we will show information about what's happening. mInfoTextView = (TextView)findViewById(R.id.info); }
@Override public boolean onCreateOptionsMenu(Menu menu) { // Be sure to call the super class. super.onCreateOptionsMenu(menu); // Inflate the menu and configure the media router action provider. getMenuInflater().inflate(R.menu.presentation_with_media_router_menu, menu); MenuItem mediaRouteMenuItem = menu.findItem(R.id.menu_media_route); MediaRouteActionProvider mediaRouteActionProvider = (MediaRouteActionProvider)mediaRouteMenuItem.getActionProvider(); mediaRouteActionProvider.setRouteTypes(MediaRouter.ROUTE_TYPE_LIVE_VIDEO); // Return true to show the menu. return true; }
private void broadcastDescriptor() { // Create intents IntentFilter routeIntentFilter = new IntentFilter(); routeIntentFilter.addCategory(CATEGORY_JUKEBOX_ROUTE); routeIntentFilter.addAction(MediaControlIntent.ACTION_START_SESSION); routeIntentFilter.addAction(MediaControlIntent.ACTION_GET_SESSION_STATUS); routeIntentFilter.addAction(MediaControlIntent.ACTION_END_SESSION); // Create route descriptor MediaRouteDescriptor.Builder routeBuilder = new MediaRouteDescriptor.Builder("Jukebox Route", "Subsonic Jukebox"); routeBuilder.addControlFilter(routeIntentFilter) .setPlaybackStream(AudioManager.STREAM_MUSIC) .setPlaybackType(MediaRouter.RouteInfo.PLAYBACK_TYPE_REMOTE) .setDescription("Subsonic Jukebox") .setVolume(controller == null ? 5 : (int) (controller.getVolume() * 10)) .setVolumeMax(MAX_VOLUME) .setVolumeHandling(MediaRouter.RouteInfo.PLAYBACK_VOLUME_VARIABLE); // Create descriptor MediaRouteProviderDescriptor.Builder providerBuilder = new MediaRouteProviderDescriptor.Builder(); providerBuilder.addRoute(routeBuilder.build()); setDescriptor(providerBuilder.build()); }
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) private void createPresentation() { if (mMediaRouter == null || mEnableCloneMode) return; // Get the current route and its presentation display. MediaRouter.RouteInfo route = mMediaRouter.getSelectedRoute( MediaRouter.ROUTE_TYPE_LIVE_VIDEO); Display presentationDisplay = route != null ? route.getPresentationDisplay() : null; if (presentationDisplay != null) { // Show a new presentation if possible. Log.i(TAG, "Showing presentation on display: " + presentationDisplay); mPresentation = new SecondaryDisplay(this, presentationDisplay); mPresentation.setOnDismissListener(mOnDismissListener); try { mPresentation.show(); } catch (WindowManager.InvalidDisplayException ex) { Log.w(TAG, "Couldn't show presentation! Display was removed in " + "the meantime.", ex); mPresentation = null; } } else Log.i(TAG, "No secondary display detected"); }
public GetDefaultRouteWorkaround() { if (android.os.Build.VERSION.SDK_INT < 16 || android.os.Build.VERSION.SDK_INT > 17) { throw new UnsupportedOperationException(); } try { mGetSystemAudioRouteMethod = android/media/MediaRouter.getMethod("getSystemAudioRoute", new Class[0]); return; } catch (NoSuchMethodException nosuchmethodexception) { return; } }
public SelectRouteWorkaround() { if (android.os.Build.VERSION.SDK_INT < 16 || android.os.Build.VERSION.SDK_INT > 17) { throw new UnsupportedOperationException(); } try { mSelectRouteIntMethod = android/media/MediaRouter.getMethod("selectRouteInt", new Class[] { Integer.TYPE, android/media/MediaRouter$RouteInfo }); return; } catch (NoSuchMethodException nosuchmethodexception) { return; } }
private void updatePresentation() { MediaRouter.RouteInfo route = mediaRouter .getSelectedRoute(MediaRouter.ROUTE_TYPE_LIVE_VIDEO); Display presentationDisplay = route != null ? route .getPresentationDisplay() : null; if (displayPresentation != null && displayPresentation.getDisplay() != presentationDisplay) { displayPresentation.dismiss(); displayPresentation = null; } if (displayPresentation == null && presentationDisplay != null) { displayPresentation = new DisplayPresentation(this, presentationDisplay); displayPresentation.setOnDismissListener( new OnDismissListener() { @Override public void onDismiss(DialogInterface dialog) { if (dialog == displayPresentation) { displayPresentation = null; } } } ); displayPresentation.show(); displayPresentation.go(displayLayout.getCurrentSlidePos(), displayLayout.getCurrentSlidePhase()); } }
private void setupThing() { MediaRouter mediaRouter = (MediaRouter) getSystemService(Context.MEDIA_ROUTER_SERVICE); if (mediaRouter != null) { MediaRouter.RouteInfo routeInfo = mediaRouter.getSelectedRoute(MediaRouter.ROUTE_TYPE_LIVE_VIDEO); if (routeInfo != null) { Display presentationDisplay = routeInfo.getPresentationDisplay(); Bundle bundle = ActivityOptions.makeBasic().setLaunchDisplayId(presentationDisplay.getDisplayId()).toBundle(); Intent intent = new Intent(this, EachAnotherActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent, bundle); } } }
public abw(Context paramContext, acf paramacf) { super(paramContext); this.q = paramacf; this.i = paramContext.getSystemService("media_router"); this.j = c(); this.r = new abe(this); Resources localResources = paramContext.getResources(); Object localObject = this.i; String str = localResources.getString(efj.bF); this.s = ((MediaRouter)localObject).createRouteCategory(str, false); e(); }
private static abz i(Object paramObject) { Object localObject = ((MediaRouter.RouteInfo)paramObject).getTag(); if ((localObject instanceof abz)) { return (abz)localObject; } return null; }
private String j(Object paramObject) { Context localContext = this.a; CharSequence localCharSequence = ((MediaRouter.RouteInfo)paramObject).getName(localContext); if (localCharSequence != null) { return localCharSequence.toString(); } return ""; }
protected void h(Object paramObject) { if (this.u == null) { this.u = new abc(); } abc localabc = this.u; MediaRouter localMediaRouter = (MediaRouter)this.i; MediaRouter.RouteInfo localRouteInfo = (MediaRouter.RouteInfo)paramObject; if (((0x800000 & localRouteInfo.getSupportedTypes()) == 0) && (localabc.a != null)) {} try { Method localMethod = localabc.a; Object[] arrayOfObject = new Object[2]; arrayOfObject[0] = Integer.valueOf(8388611); arrayOfObject[1] = localRouteInfo; localMethod.invoke(localMediaRouter, arrayOfObject); return; } catch (InvocationTargetException localInvocationTargetException) { localMediaRouter.selectRoute(8388611, localRouteInfo); return; } catch (IllegalAccessException localIllegalAccessException) { label96: break label96; } }
protected final void a(aby paramaby, aad paramaad) { super.a(paramaby, paramaad); CharSequence localCharSequence = ((MediaRouter.RouteInfo)paramaby.a).getDescription(); if (localCharSequence != null) { String str = localCharSequence.toString(); paramaad.a.putString("status", str); } }
protected final void a(abz paramabz) { super.a(paramabz); Object localObject = paramabz.b; String str = paramabz.a.e; ((MediaRouter.UserRouteInfo)localObject).setDescription(str); }
/** * Add or remove MediaRouter callbacks. This is provided for version targeting. * * @param add true to add, false to remove */ @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) private void mediaRouterAddCallback(boolean add) { if(!AndroidUtil.isJellyBeanMR1OrLater() || mMediaRouter == null) return; if(add) mMediaRouter.addCallback(MediaRouter.ROUTE_TYPE_LIVE_VIDEO, mMediaRouterCallback); else mMediaRouter.removeCallback(mMediaRouterCallback); }
@TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) private void createPresentation() { if (mMediaRouter == null || mEnableCloneMode) return; // Get the current route and its presentation display. MediaRouter.RouteInfo route = mMediaRouter.getSelectedRoute( MediaRouter.ROUTE_TYPE_LIVE_VIDEO); Display presentationDisplay = route != null ? route.getPresentationDisplay() : null; if (presentationDisplay != null) { // Show a new presentation if possible. Log.i(TAG, "Showing presentation on display: " + presentationDisplay); mPresentation = new SecondaryDisplay(this, LibVLC(), presentationDisplay); mPresentation.setOnDismissListener(mOnDismissListener); try { mPresentation.show(); mPresentationDisplayId = presentationDisplay.getDisplayId(); } catch (WindowManager.InvalidDisplayException ex) { Log.w(TAG, "Couldn't show presentation! Display was removed in " + "the meantime.", ex); mPresentation = null; } } else Log.i(TAG, "No secondary display detected"); }
private void useBestRouteForGameplayPresentation() { MediaRouter.RouteInfo mRouteInfo = findSecundaryDisplayRouter(); if (mRouteInfo != null) { Display presentationDisplay = mRouteInfo.getPresentationDisplay(); if (presentationDisplay != null) { useSecundaryDisplayForGameplayPresentation(presentationDisplay); } } }
@Override public void onRouteSelected(MediaRouter router, int type, MediaRouter.RouteInfo info) { LOGD("MediaRouteListener", "onRouteSelected(" + type + ", " + info.getName() + ")"); mCurrentRouteInfo = info; mCurrentRouteType = type; refreshRoute(); }
@Override public void onRouteUnselected(MediaRouter router, int type, MediaRouter.RouteInfo info) { LOGD("MediaRouteListener", "onRouteUnselected(" + type + ", " + info.getName() + ")"); mCurrentRouteInfo = null; mCurrentRouteType = type; refreshRoute(); }
@Override protected void onResume() { // Be sure to call the super class. super.onResume(); // Listen for changes to media routes. mMediaRouter.addCallback(MediaRouter.ROUTE_TYPE_LIVE_VIDEO, mMediaRouterCallback); // Update the presentation based on the currently selected route. mPaused = false; updatePresentation(); }
@Override public boolean onControlRequest(Intent intent, android.support.v7.media.MediaRouter.ControlRequestCallback callback) { if (intent.hasCategory(CATEGORY_JUKEBOX_ROUTE)) { return true; } else { return false; } }
@Override public boolean onControlRequest(Intent intent, android.support.v7.media.MediaRouter.ControlRequestCallback callback) { if (intent.hasCategory(CATEGORY_DLNA)) { return true; } else { return false; } }
private void updatePresentation() { // Get the current route and its presentation display. MediaRouter.RouteInfo route = mMediaRouter.getSelectedRoute( MediaRouter.ROUTE_TYPE_LIVE_VIDEO); Display presentationDisplay = route != null ? route.getPresentationDisplay() : null; // Dismiss the current presentation if the display has changed. if (mPresentation != null && mPresentation.getDisplay() != presentationDisplay) { Log.i(TAG, "Dismissing presentation because the current route no longer " + "has a presentation display."); mPresentation.dismiss(); mPresentation = null; } // Show a new presentation if needed. if (mPresentation == null && presentationDisplay != null) { Log.i(TAG, "Showing presentation on display: " + presentationDisplay); mPresentation = new DemoPresentation(this, presentationDisplay); mPresentation.setOnDismissListener(mOnDismissListener); try { mPresentation.show(); } catch (WindowManager.InvalidDisplayException ex) { Log.w(TAG, "Couldn't show presentation! Display was removed in " + "the meantime.", ex); mPresentation = null; } } // Update the contents playing in this activity. updateContents(); }
/** * Add or remove MediaRouter callbacks. This is provided for version targeting. * * @param add true to add, false to remove */ @TargetApi(Build.VERSION_CODES.JELLY_BEAN_MR1) private void mediaRouterAddCallback(boolean add) { if(!LibVlcUtil.isJellyBeanMR1OrLater() || mMediaRouter == null) return; if(add) mMediaRouter.addCallback(MediaRouter.ROUTE_TYPE_LIVE_VIDEO, mMediaRouterCallback); else mMediaRouter.removeCallback(mMediaRouterCallback); }
@TargetApi(Build.VERSION_CODES.JELLY_BEAN) private static void unregisterMediaRouter(Context context) { final MediaRouter mr = (MediaRouter)context.getSystemService(MEDIA_ROUTER_SERVICE); if (mediaRouterCallback != null && mr != null) mr.removeCallback((MediaRouter.Callback)mediaRouterCallback); mediaRouterCallback = null; }
/** * 返回 {@link MediaRouter} */ public static MediaRouter getMediaRouter() { return (MediaRouter) get(MEDIA_ROUTER_SERVICE); }
public void onRoutePresentationDisplayChanged(MediaRouter router, RouteInfo info) { updatePresentation(); }