android MediaPlayer+ SurfaceView 播放视频 全屏播放视频没有成功

likesyour 2017-09-04 04:38:53
上图:





上代码:
if(getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE){
MyUtils.hideSupportActionBar(MainActivity.this);
setVideoViewScale(screen_height,screen_width);
music_imageView.setVisibility(View.VISIBLE);
volume_seek.setVisibility(View.VISIBLE);
isFullScreen = true;
// getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
// getWindow().addFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);

int heightPixels = this.getResources().getDisplayMetrics().heightPixels;
int widthPixels = this.getResources().getDisplayMetrics().widthPixels;
ViewGroup.LayoutParams layoutParams = videolayout.getLayoutParams();
layoutParams.height = heightPixels;
layoutParams.width = widthPixels;
videolayout.setLayoutParams(layoutParams);
}else{
setVideoViewScale(ViewGroup.LayoutParams.MATCH_PARENT,DisplayUtils.dip2px(this,240));
music_imageView.setVisibility(View.GONE);
volume_seek.setVisibility(View.GONE);
isFullScreen = false;
getWindow().clearFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN);
getWindow().addFlags(WindowManager.LayoutParams.FLAG_FORCE_NOT_FULLSCREEN);
}
...全文
573 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
BandaYung 2017-09-05
  • 打赏
  • 举报
回复
推荐:https://github.com/wlsh/JieCaoVideoPlayer/
smile_邝野 2017-09-05
  • 打赏
  • 举报
回复
把你的布局粘出来看看,肯定是布局的问题
likesyour 2017-09-05
  • 打赏
  • 举报
回复
谢谢您回答我的问题,我想说一下,我把顶上的android Imageview控件直接删掉,可以全屏,正如你说的layout控件影响他了。我现在不想每次手动的去隐藏,这样如果很多控件,体验不好。所以我现在想的是如何忽略这个图片控件占的位置,就能直接全屏。比如在listview中怎么实现播放视频能全屏
辉_alexxm 2017-09-05
  • 打赏
  • 举报
回复
我看了下界面是全屏的,也就是说没有标题栏,也没有系统的状态栏;应为layout的问题,与全屏无关; 楼主看下布局(注意备份哦),先直接去掉图标,再想办法加个ID,代码中加 一个控制,例: music_imageView= music_imageView.setVisibility(View.VISIBLE); music_imageView.setVisibility(View.GONE);
likesyour 2017-09-05
  • 打赏
  • 举报
回复
@qq_30552993 您好,你说的JCPlayer我看过了,感觉它封装的太多了,他用的是TextureView 显示的视频。我想用Surfaceview显示视频。实在不会整啊 求教
likesyour 2017-09-05
  • 打赏
  • 举报
回复
布局如图:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:id="@+id/group_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:android="http://schemas.android.com/apk/res/android">
<ImageView
android:id="@+id/image_test"
android:src="@mipmap/ic_launcher"
android:layout_width="match_parent"
android:layout_height="100dp"/>

<RelativeLayout
android:layout_below="@id/image_test"
android:id="@+id/videolayout"
android:layout_width="match_parent"
android:layout_height="240dp">

<com.systems.alva.videoplayerdemo1.CustomSurfaceView
android:id="@+id/videoplayer"
android:layout_width="match_parent"
android:layout_height="240dp"/>
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<SeekBar
android:id="@+id/play_seek"
android:layout_marginRight="-20dp"
android:layout_marginLeft="-20dp"
android:max="100"
android:progress="20"
android:indeterminate="false"
android:layout_width="match_parent"
android:layout_height="5dp"/>

<RelativeLayout
android:gravity="center_vertical"
android:background="#aa000000"
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:id="@+id/left_layout"
android:orientation="horizontal"
android:gravity="center_vertical"
android:layout_width="wrap_content"
android:layout_height="match_parent">
<ImageView
android:id="@+id/pase_image"
android:layout_marginLeft="16dp"
android:src="@mipmap/video_start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
<TextView
android:layout_marginLeft="32dp"
android:textSize="14sp"
android:textColor="#ffffff"
android:id="@+id/current_text_tv"
android:text="00:00:00"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>

<TextView
android:layout_marginLeft="5dp"
android:textSize="14sp"
android:textColor="#4c4c4c"
android:text="/"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>

<TextView
android:id="@+id/time_total_tv"
android:layout_marginLeft="5dp"
android:textSize="14sp"
android:textColor="#4c4c4c"
android:text="00:00:00"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>

<LinearLayout
android:id="@+id/controller_layout"
android:gravity="center_vertical|right"
android:orientation="horizontal"
android:layout_toRightOf="@id/left_layout"
android:layout_width="10dp"
android:layout_alignParentRight="true"
android:layout_height="match_parent">

<ImageView
android:visibility="gone"
android:id="@+id/music_imageView"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="@mipmap/video_music"/>

<SeekBar
android:visibility="gone"
android:id="@+id/volume_seek"
android:max="100"
android:progress="20"
android:indeterminate="false"
android:layout_width="100dp"
android:layout_height="5dp"/>
<View
android:background="#1E1E1E"
android:layout_marginLeft="1dp"
android:layout_marginTop="5dp"
android:layout_marginBottom="5dp"
android:layout_width="1dp"
android:layout_height="match_parent"/>
<ImageView
android:id="@+id/screen"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:src="@mipmap/video_fullscreen"
android:layout_width="wrap_content"
android:layout_height="match_parent"/>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
<RelativeLayout
android:visibility="visible"
android:id="@+id/thumbnail_layout"
android:background="#000000"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<ImageView
android:id="@+id/thumbnail_image"
android:layout_centerInParent="true"
android:src="@mipmap/video_start"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>

</RelativeLayout>
</RelativeLayout>
<RelativeLayout
android:layout_below="@id/videolayout"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/Lv"
android:layout_width="match_parent"
android:layout_height="match_parent"></ListView>
</RelativeLayout>
</RelativeLayout>


80,472

社区成员

发帖
与我相关
我的任务
社区描述
移动平台 Android
androidandroid-studioandroidx 技术论坛(原bbs)
社区管理员
  • Android
  • yechaoa
  • 失落夏天
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧