2016-07-27 3 views
7

FloatingViewを実装したいと思います。アクティビティのサイズを変更してドラッグできるようにする(Pictureのように)私もこのthreadを参照し、それに基づいて自分自身のserviceを作成します。 (this & thisライブラリビデオストリーミングのための浮動表示の実装

問題は実装上、私はビデオを続行できず、時には画面も黒く表示されません。私はこれを処理する正しい方法が何かを知りたいですか?ビデオが中断されずに再生が継続されます。 (私は理由setOnPrepareListenerの中断を知っているが、それを避ける方法?)ここで

は私のコードです:

public class FloatingStream extends Service implements FloatingViewListener { 


    @Override 
    public int onStartCommand(Intent intent, int flags, int startId) { 
     if (mFloatingViewManager != null) { 
      return START_STICKY; 
     } 


     final DisplayMetrics metrics = new DisplayMetrics(); 
     final WindowManager windowManager = (WindowManager) getSystemService(Context.WINDOW_SERVICE); 
     windowManager.getDefaultDisplay().getMetrics(metrics); 
     floatingServiceBinder = new FloatingServiceBinder(this); 
     final View rootView = LayoutInflater.from(this).inflate(R.layout.view_exoplayer, null, false); 
     final VideoView videoView = (VideoView) rootView.findViewById(R.id.video_view); 
     videoView.setVideoURI(Uri.parse(MY_URL)); 
     videoView.setOnPreparedListener(new OnPreparedListener() { 
      @Override 
      public void onPrepared() { 
       videoView.start(); 
      } 
     }); 

     mFloatingViewManager = new FloatingViewManager(this, this); 
     mFloatingViewManager.setFixedTrashIconImage(R.drawable.ic_play_circle_filled); 
     mFloatingViewManager.setActionTrashIconImage(R.drawable.ic_menu); 
     final FloatingViewManager.Options options = new FloatingViewManager.Options(); 
     mFloatingViewManager.addViewToWindow(rootView, options); 


     return START_REDELIVER_INTENT; 
    } 

} 

enter image description here

編集:それがあるため、ユーザーが別のものに行く場合は、このアプリではありませんdraggable panelですアクティビティビデオは中断されずに再生されます。

+0

こんにちは、このダミーの質問は申し訳ありませんが、あなたは「ビデオを続けることはできません」とはどういう意味ですか?あなたはビデオを「スムーズに」見ることができないのですか? – jos

+0

@jos GIFで見るように、画像は停止(または中断)されていません。サイズ変更アクティビティが** setOnPreparedListener **を呼び出す必要がないとき。 – Amir

答えて

1

あなたが達成しようとしているのは、Picture in Pictureです。これはYouTubeアプリのようなものです。

AndroidはAndroid N以降、正式にこれをテレビでサポートしています。ただし、モバイルデバイスの場合はDraggable Panel libraryを使用できます。

+0

ありがとうございますが、ドラッグ可能パネルは、そのアクティビティにバインドされているために、別のアクティビティをドラッグ可能にすると動作しません。 – Amir

+0

私たちはFragments、私の友人を使用しています: – Suleiman19

+0

ここでは、あなたはそれが断片だと思うアプリケーションのリンクですか? https://play.google.com/store/apps/details?id=tv.perception.android.aio – Amir

関連する問題