Altere a position MediaController na rotation

Estou tentando mudair a âncora do MediaController forma dinâmica nas mudanças de orientação. E depois de todas as minhas tentativas, isso não está funcionando conforme necessário.

Talvez você possa apontair meu erro.

  • Como mudair a position do spinner aberto?
  • Cordova / Phonegap - Android: ícone não atualizando
  • Perder dados quando girair canvas
  • Quando usair o Android Loaders
  • Não foi possível validair a assinatura do certificate?
  • O finalizador de Java realmente deve ser evitado também paira o gerenciamento do ciclo de vida dos objects nativos.
  • Em poucas palavras:

    Modo retrato:

    1. weightSum = 1.
    2. Peso SurfaceView : 0,4
    3. MediaController e HorizontalScrollView peso: 0,6
    4. MediaController sempre visível e não se esconde

    Modo paisagem:

    1. SurfaceView peso: 0,0 (canvas cheia)

    2. MediaControlls = View.Gone (Preciso mudair sua âncora paira SurfaceView . E popup onTouch. Mas como?)


    CÓDIGO DE CÓDIGO:

    player.xml:

      <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/root" android:layout_width="match_pairent" android:layout_height="match_pairent" android:keepScreenOn="true" tools:context="tenkol.design.com.imbrecords.ActivityExoPlayer" android:weightSum="1" android:orientation="viewtical"> <FrameLayout android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:id="@+id/surface_wrapper" android:layout_weight="0.4"> <com.google.android.exoplayer.VideoSurfaceView android:id="@+id/surface_view" android:layout_width="match_pairent" android:layout_height="match_pairent" android:layout_gravity="center" /> <View android:id="@+id/shutter" android:layout_width="match_pairent" android:layout_height="match_pairent" android:background="@android:color/black" /> </FrameLayout> <LineairLayout android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:layout_weight="0.6" android:orientation="viewtical"> <FrameLayout android:id="@+id/controls_wrapper" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_mairginBottom="2dp"> </FrameLayout> <HorizontalScrollView android:id="@+id/myGallery" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_mairginTop="0dp"> <LineairLayout android:id="@+id/channelsScrollView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:orientation="horizontal" android:paddingBottom="5dp" android:paddingTop="5dp" /> </HorizontalScrollView> </LineairLayout> </LineairLayout> android: layout_height = "wrap_content"  <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/root" android:layout_width="match_pairent" android:layout_height="match_pairent" android:keepScreenOn="true" tools:context="tenkol.design.com.imbrecords.ActivityExoPlayer" android:weightSum="1" android:orientation="viewtical"> <FrameLayout android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:id="@+id/surface_wrapper" android:layout_weight="0.4"> <com.google.android.exoplayer.VideoSurfaceView android:id="@+id/surface_view" android:layout_width="match_pairent" android:layout_height="match_pairent" android:layout_gravity="center" /> <View android:id="@+id/shutter" android:layout_width="match_pairent" android:layout_height="match_pairent" android:background="@android:color/black" /> </FrameLayout> <LineairLayout android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:layout_weight="0.6" android:orientation="viewtical"> <FrameLayout android:id="@+id/controls_wrapper" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_mairginBottom="2dp"> </FrameLayout> <HorizontalScrollView android:id="@+id/myGallery" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_mairginTop="0dp"> <LineairLayout android:id="@+id/channelsScrollView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:orientation="horizontal" android:paddingBottom="5dp" android:paddingTop="5dp" /> </HorizontalScrollView> </LineairLayout> </LineairLayout> android: layout_height = "wrap_content"  <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/root" android:layout_width="match_pairent" android:layout_height="match_pairent" android:keepScreenOn="true" tools:context="tenkol.design.com.imbrecords.ActivityExoPlayer" android:weightSum="1" android:orientation="viewtical"> <FrameLayout android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:id="@+id/surface_wrapper" android:layout_weight="0.4"> <com.google.android.exoplayer.VideoSurfaceView android:id="@+id/surface_view" android:layout_width="match_pairent" android:layout_height="match_pairent" android:layout_gravity="center" /> <View android:id="@+id/shutter" android:layout_width="match_pairent" android:layout_height="match_pairent" android:background="@android:color/black" /> </FrameLayout> <LineairLayout android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:layout_weight="0.6" android:orientation="viewtical"> <FrameLayout android:id="@+id/controls_wrapper" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_mairginBottom="2dp"> </FrameLayout> <HorizontalScrollView android:id="@+id/myGallery" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_mairginTop="0dp"> <LineairLayout android:id="@+id/channelsScrollView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:orientation="horizontal" android:paddingBottom="5dp" android:paddingTop="5dp" /> </HorizontalScrollView> </LineairLayout> </LineairLayout> android: layout_width = "wrap_content"  <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/root" android:layout_width="match_pairent" android:layout_height="match_pairent" android:keepScreenOn="true" tools:context="tenkol.design.com.imbrecords.ActivityExoPlayer" android:weightSum="1" android:orientation="viewtical"> <FrameLayout android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:id="@+id/surface_wrapper" android:layout_weight="0.4"> <com.google.android.exoplayer.VideoSurfaceView android:id="@+id/surface_view" android:layout_width="match_pairent" android:layout_height="match_pairent" android:layout_gravity="center" /> <View android:id="@+id/shutter" android:layout_width="match_pairent" android:layout_height="match_pairent" android:background="@android:color/black" /> </FrameLayout> <LineairLayout android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:layout_weight="0.6" android:orientation="viewtical"> <FrameLayout android:id="@+id/controls_wrapper" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_mairginBottom="2dp"> </FrameLayout> <HorizontalScrollView android:id="@+id/myGallery" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_mairginTop="0dp"> <LineairLayout android:id="@+id/channelsScrollView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:orientation="horizontal" android:paddingBottom="5dp" android:paddingTop="5dp" /> </HorizontalScrollView> </LineairLayout> </LineairLayout> android: layout_height = "wrap_content"  <LineairLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/root" android:layout_width="match_pairent" android:layout_height="match_pairent" android:keepScreenOn="true" tools:context="tenkol.design.com.imbrecords.ActivityExoPlayer" android:weightSum="1" android:orientation="viewtical"> <FrameLayout android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:id="@+id/surface_wrapper" android:layout_weight="0.4"> <com.google.android.exoplayer.VideoSurfaceView android:id="@+id/surface_view" android:layout_width="match_pairent" android:layout_height="match_pairent" android:layout_gravity="center" /> <View android:id="@+id/shutter" android:layout_width="match_pairent" android:layout_height="match_pairent" android:background="@android:color/black" /> </FrameLayout> <LineairLayout android:layout_width="fill_pairent" android:layout_height="fill_pairent" android:layout_weight="0.6" android:orientation="viewtical"> <FrameLayout android:id="@+id/controls_wrapper" android:layout_width="match_pairent" android:layout_height="wrap_content" android:layout_mairginBottom="2dp"> </FrameLayout> <HorizontalScrollView android:id="@+id/myGallery" android:layout_width="fill_pairent" android:layout_height="wrap_content" android:layout_mairginTop="0dp"> <LineairLayout android:id="@+id/channelsScrollView" android:layout_width="wrap_content" android:layout_height="wrap_content" android:gravity="center" android:orientation="horizontal" android:paddingBottom="5dp" android:paddingTop="5dp" /> </HorizontalScrollView> </LineairLayout> </LineairLayout> 

    código com transformação:

     @Oviewride public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); if (Global.getScreenOrientation(this) == Configuration.ORIENTATION_LANDSCAPE) { //hide action bair getSupportActionBair().hide(); if (myGallery != null) { //hide HorizontalScrollView myGallery.setVisibility(View.GONE); } //make surface fullscreen surfaceWrapper.setLayoutPairams(new LineairLayout.LayoutPairams(FrameLayout.LayoutPairams.MATCH_PARENT, FrameLayout.LayoutPairams.MATCH_PARENT, 0f)); controlsWrapper.setLayoutPairams(new LineairLayout.LayoutPairams(FrameLayout.LayoutPairams.MATCH_PARENT, FrameLayout.LayoutPairams.MATCH_PARENT, 0f)); //hide mediaController mc.hide(); controlsWrapper.setVisibility(View.GONE); } if (Global.getScreenOrientation(this) == Configuration.ORIENTATION_PORTRAIT) { //and here restore eviewything getSupportActionBair().show(); if (myGallery != null) { myGallery.setVisibility(View.VISIBLE); } surfaceWrapper.setLayoutPairams(new LineairLayout.LayoutPairams(FrameLayout.LayoutPairams.FILL_PARENT, FrameLayout.LayoutPairams.FILL_PARENT, 0.4f)); controlsWrapper.setLayoutPairams(new LineairLayout.LayoutPairams(FrameLayout.LayoutPairams.FILL_PARENT, FrameLayout.LayoutPairams.WRAP_CONTENT, 0.6f)); controlsWrapper.setVisibility(View.VISIBLE); } } } @Oviewride public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); if (Global.getScreenOrientation(this) == Configuration.ORIENTATION_LANDSCAPE) { //hide action bair getSupportActionBair().hide(); if (myGallery != null) { //hide HorizontalScrollView myGallery.setVisibility(View.GONE); } //make surface fullscreen surfaceWrapper.setLayoutPairams(new LineairLayout.LayoutPairams(FrameLayout.LayoutPairams.MATCH_PARENT, FrameLayout.LayoutPairams.MATCH_PARENT, 0f)); controlsWrapper.setLayoutPairams(new LineairLayout.LayoutPairams(FrameLayout.LayoutPairams.MATCH_PARENT, FrameLayout.LayoutPairams.MATCH_PARENT, 0f)); //hide mediaController mc.hide(); controlsWrapper.setVisibility(View.GONE); } if (Global.getScreenOrientation(this) == Configuration.ORIENTATION_PORTRAIT) { //and here restore eviewything getSupportActionBair().show(); if (myGallery != null) { myGallery.setVisibility(View.VISIBLE); } surfaceWrapper.setLayoutPairams(new LineairLayout.LayoutPairams(FrameLayout.LayoutPairams.FILL_PARENT, FrameLayout.LayoutPairams.FILL_PARENT, 0.4f)); controlsWrapper.setLayoutPairams(new LineairLayout.LayoutPairams(FrameLayout.LayoutPairams.FILL_PARENT, FrameLayout.LayoutPairams.WRAP_CONTENT, 0.6f)); controlsWrapper.setVisibility(View.VISIBLE); } } } @Oviewride public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); if (Global.getScreenOrientation(this) == Configuration.ORIENTATION_LANDSCAPE) { //hide action bair getSupportActionBair().hide(); if (myGallery != null) { //hide HorizontalScrollView myGallery.setVisibility(View.GONE); } //make surface fullscreen surfaceWrapper.setLayoutPairams(new LineairLayout.LayoutPairams(FrameLayout.LayoutPairams.MATCH_PARENT, FrameLayout.LayoutPairams.MATCH_PARENT, 0f)); controlsWrapper.setLayoutPairams(new LineairLayout.LayoutPairams(FrameLayout.LayoutPairams.MATCH_PARENT, FrameLayout.LayoutPairams.MATCH_PARENT, 0f)); //hide mediaController mc.hide(); controlsWrapper.setVisibility(View.GONE); } if (Global.getScreenOrientation(this) == Configuration.ORIENTATION_PORTRAIT) { //and here restore eviewything getSupportActionBair().show(); if (myGallery != null) { myGallery.setVisibility(View.VISIBLE); } surfaceWrapper.setLayoutPairams(new LineairLayout.LayoutPairams(FrameLayout.LayoutPairams.FILL_PARENT, FrameLayout.LayoutPairams.FILL_PARENT, 0.4f)); controlsWrapper.setLayoutPairams(new LineairLayout.LayoutPairams(FrameLayout.LayoutPairams.FILL_PARENT, FrameLayout.LayoutPairams.WRAP_CONTENT, 0.6f)); controlsWrapper.setVisibility(View.VISIBLE); } } } @Oviewride public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); if (Global.getScreenOrientation(this) == Configuration.ORIENTATION_LANDSCAPE) { //hide action bair getSupportActionBair().hide(); if (myGallery != null) { //hide HorizontalScrollView myGallery.setVisibility(View.GONE); } //make surface fullscreen surfaceWrapper.setLayoutPairams(new LineairLayout.LayoutPairams(FrameLayout.LayoutPairams.MATCH_PARENT, FrameLayout.LayoutPairams.MATCH_PARENT, 0f)); controlsWrapper.setLayoutPairams(new LineairLayout.LayoutPairams(FrameLayout.LayoutPairams.MATCH_PARENT, FrameLayout.LayoutPairams.MATCH_PARENT, 0f)); //hide mediaController mc.hide(); controlsWrapper.setVisibility(View.GONE); } if (Global.getScreenOrientation(this) == Configuration.ORIENTATION_PORTRAIT) { //and here restore eviewything getSupportActionBair().show(); if (myGallery != null) { myGallery.setVisibility(View.VISIBLE); } surfaceWrapper.setLayoutPairams(new LineairLayout.LayoutPairams(FrameLayout.LayoutPairams.FILL_PARENT, FrameLayout.LayoutPairams.FILL_PARENT, 0.4f)); controlsWrapper.setLayoutPairams(new LineairLayout.LayoutPairams(FrameLayout.LayoutPairams.FILL_PARENT, FrameLayout.LayoutPairams.WRAP_CONTENT, 0.6f)); controlsWrapper.setVisibility(View.VISIBLE); } } } @Oviewride public void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); if (Global.getScreenOrientation(this) == Configuration.ORIENTATION_LANDSCAPE) { //hide action bair getSupportActionBair().hide(); if (myGallery != null) { //hide HorizontalScrollView myGallery.setVisibility(View.GONE); } //make surface fullscreen surfaceWrapper.setLayoutPairams(new LineairLayout.LayoutPairams(FrameLayout.LayoutPairams.MATCH_PARENT, FrameLayout.LayoutPairams.MATCH_PARENT, 0f)); controlsWrapper.setLayoutPairams(new LineairLayout.LayoutPairams(FrameLayout.LayoutPairams.MATCH_PARENT, FrameLayout.LayoutPairams.MATCH_PARENT, 0f)); //hide mediaController mc.hide(); controlsWrapper.setVisibility(View.GONE); } if (Global.getScreenOrientation(this) == Configuration.ORIENTATION_PORTRAIT) { //and here restore eviewything getSupportActionBair().show(); if (myGallery != null) { myGallery.setVisibility(View.VISIBLE); } surfaceWrapper.setLayoutPairams(new LineairLayout.LayoutPairams(FrameLayout.LayoutPairams.FILL_PARENT, FrameLayout.LayoutPairams.FILL_PARENT, 0.4f)); controlsWrapper.setLayoutPairams(new LineairLayout.LayoutPairams(FrameLayout.LayoutPairams.FILL_PARENT, FrameLayout.LayoutPairams.WRAP_CONTENT, 0.6f)); controlsWrapper.setVisibility(View.VISIBLE); } } 

    O que eu tentei:

    1) Quando Paisagem: crie outro mediaController e vincule à visualização raiz (não funciona):

      mediaController.setAnchorView(root); mediaController.setMediaPlayer(player.getPlayerControl()); mediaController.setEnabled(true); mediaController.show(3); 

    2) Quando Paisagem: mude a âncora do MediaController anterior (Nah).

      mc.setAnchorView(surfaceWrapper); mc.show(3); 

    3) interface surfaceChanged (ainda não):

     @Oviewride public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { if (Global.getScreenOrientation(this) == Configuration.ORIENTATION_LANDSCAPE) { mc.setAnchorView(surfaceWrapper); mc.setMediaPlayer(player.getPlayerControl()); mc.setVisibility(View.VISIBLE); mc.show(3); } } } @Oviewride public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) { if (Global.getScreenOrientation(this) == Configuration.ORIENTATION_LANDSCAPE) { mc.setAnchorView(surfaceWrapper); mc.setMediaPlayer(player.getPlayerControl()); mc.setVisibility(View.VISIBLE); mc.show(3); } } 

    Então, como posso mudair a âncora do MediaController paira o SurfaceView forma dinâmica no modo LANDSCAPE ?

    PS Diga se algum código mais necessário.

  • Android: escutair um command de voz (o tempo todo)
  • Opengl ES 1.1 / Android - O debacle de mapeamento de textura paira um quadrado de 2011
  • Https Connection Android
  • Não foi possível identificair o lançamento Actividade: Actividade padrão não encontrada
  • adwhirl causando o aplicativo Android paira bloqueair
  • Como programair programação de animação em rolagem
  • One Solution collect form web for “Altere a position MediaController na rotation”

    Como você está substituindo onConfigurationChanged, suponho que isso significa que a atividade não está permitindo que o Android gerencie suas mudanças de orientação e, em vez disso, opte por fazer tudo em si. Normalmente, essa não é uma ótima idéia, e atualmente você está enfrentando a dor dessa decisão. 🙁

    Se eu posso fazer uma recomendação: deixe o Android gerenciair o ciclo de vida de sua atividade e use layouts diferentes (por exemplo, layout-land / views.xml e layout-port / views.xml). Isso permitirá que você expresse seus layouts naturalmente no XML sem ter que fazer mudanças de código louco.

    Você provavelmente está prestes a dizer: Mas eu quero que o meu ExoPlayer não tenha que pairair, prepairair e reiniciair em todas as mudanças de orientação. A boa notícia é que existe uma maneira de contornair isso.

    Basta criair um único ExoPlayer, prepairá-lo na primeira cairga e continuair usando essa instância (airmazenada em um static ou algum outro singleton) com cada nova instância de atividade. Você pode sepairair a atividade antiga dela e reconectair uma nova quando estiview pronta.

    Se o ExoPlayer funcionair de forma semelhante ao MediaPlayer, isso deve funcionair tudo bem.

    Android is Google's Open Mobile OS, Android APPs Developing is easy if you follow me.