Ami*_*mir 9 android video-streaming android-videoview
我想实施FloatingView.这使活动调整大小和拖动(如下图).我也看到了这个帖子,并在此基础上创建了自己的帖子service.(另请参见本&这个库)
问题是根据实现我不能继续视频,有时屏幕变黑,没有任何显示.我想知道处理这个问题的正确方法是什么?没有视频中断并继续播放.(我知道中断因为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;
}
}
Run Code Online (Sandbox Code Playgroud)
编辑:它不是可拖动的面板,因为在这个应用程序中,如果用户转到另一个活动视频而不是中断并仍在播放.
| 归档时间: |
|
| 查看次数: |
1264 次 |
| 最近记录: |