Skip to content

Commit

Permalink
增加了镜像旋转demo (2017-04-26)
Browse files Browse the repository at this point in the history
  • Loading branch information
CarGuo committed Apr 28, 2017
1 parent e50ccdb commit fd0e84b
Show file tree
Hide file tree
Showing 6 changed files with 235 additions and 3 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
* **连续播放一个列表的视频。**
* **支持全屏与非全屏两套布局切换**
* **弹幕支持**
* **镜像旋转**

[![](https://jitpack.io/v/CarGuo/GSYVideoPlayer.svg)](https://jitpack.io/#CarGuo/GSYVideoPlayer)
[ ![Download](https://api.bintray.com/packages/carguo/GSYVideoPlayer/gsyVideoPlayer/images/download.svg) ](https://bintray.com/carguo/GSYVideoPlayer/gsyVideoPlayer/_latestVersion)
Expand Down Expand Up @@ -104,6 +105,7 @@ dependencies {
## 近期版本

### 1.6.5(未发布)
* 增加镜像旋转demo SampleVideo
* 修改了循环播放的UI问题
* 修改了本地文件或者已缓存文件,显示进度问题
* GSYVideoType增加SCREEN_TYPE_FULL类型,通过按照比例裁减放大视频,达到全屏
Expand Down
1 change: 1 addition & 0 deletions UPDATE_VERSION.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
## 下方个版本说明,可以当做简单的wiki使用~,效果可参考DEMO。

### 1.6.5(未发布)
* 增加镜像旋转demo SampleVideo
* 修改了循环播放的UI问题
* 修改了本地文件或者已缓存文件,显示进度问题
* GSYVideoType增加SCREEN_TYPE_FULL类型,通过按照比例裁减放大视频,达到全屏
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public int getLayoutId() {
if (mIfCurrentIsFullscreen) {
return R.layout.sample_video_land;
}
return R.layout.sample_video;
return R.layout.sample_video_normal;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.app.Activity;
import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Matrix;
import android.media.MediaMetadataRetriever;
import android.os.Handler;
import android.text.TextUtils;
Expand Down Expand Up @@ -44,11 +45,15 @@ public class SampleVideo extends StandardGSYVideoPlayer {

private TextView mChangeRotate;

private TextView mChangeTransform;

private List<SwitchVideoModel> mUrlList = new ArrayList<>();

//记住切换数据源类型
private int mType = 0;

private int mTransformSize = 0;

//数据源
private int mSourcePosition = 0;

Expand Down Expand Up @@ -77,6 +82,7 @@ private void initView() {
mMoreScale = (TextView) findViewById(R.id.moreScale);
mSwitchSize = (TextView) findViewById(R.id.switchSize);
mChangeRotate = (TextView) findViewById(R.id.change_rotate);
mChangeTransform = (TextView) findViewById(R.id.change_transform);

//切换清晰度
mMoreScale.setOnClickListener(new OnClickListener() {
Expand Down Expand Up @@ -133,8 +139,32 @@ public void onClick(View v) {
mCoverImageView.setRotation(mCoverImageView.getRotation() + 90);
mCoverImageView.requestLayout();
}
}
});


//镜像旋转
mChangeTransform.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
if (mTransformSize == 0) {
mTransformSize = 1;
Matrix transform = new Matrix();
transform.setScale(-1, 1, mTextureView.getWidth() / 2, 0);
mTextureView.setTransform(transform);
mChangeTransform.setText("左右镜像");
} else if (mTransformSize == 1) {
mTransformSize = 2;
Matrix transform = new Matrix();
transform.setScale(1, -1, 0, mTextureView.getHeight() / 2);
mTextureView.setTransform(transform);
mChangeTransform.setText("上下镜像");
} else if (mTransformSize == 2) {
mTransformSize = 0;
Matrix transform = new Matrix();
transform.setScale(1, 1, mTextureView.getWidth() / 2, 0);
mTextureView.setTransform(transform);
mChangeTransform.setText("旋转镜像");
}
}
});

Expand Down Expand Up @@ -175,9 +205,10 @@ public int getLayoutId() {

@Override
public GSYBaseVideoPlayer startWindowFullscreen(Context context, boolean actionBar, boolean statusBar) {
SampleVideo sampleVideo = (SampleVideo) super.startWindowFullscreen(context, actionBar, statusBar);
SampleVideo sampleVideo = (SampleVideo) super.startWindowFullscreen(context, actionBar, statusBar);
//这个播放器的demo配置切换到全屏播放器
//这只是单纯的作为全屏播放显示,如果需要做大小屏幕切换,请记得在这里耶设置上视频全屏的需要的自定义配置
//比如已旋转角度之类的等等
//可参考super中的实现
return sampleVideo;
}
Expand Down
11 changes: 11 additions & 0 deletions app/src/main/res/layout/sample_video.xml
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,17 @@
android:textColor="@android:color/white"
android:textSize="18sp" />

<TextView
android:id="@+id/change_transform"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="center"
android:minEms="5"
android:paddingLeft="10dp"
android:text="旋转镜像"
android:textColor="@android:color/white"
android:textSize="13sp" />

<TextView
android:id="@+id/change_rotate"
android:layout_width="wrap_content"
Expand Down
187 changes: 187 additions & 0 deletions app/src/main/res/layout/sample_video_normal.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@android:color/black">

<FrameLayout
android:id="@+id/surface_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">

</FrameLayout>

<com.shuyu.gsyvideoplayer.GSYImageCover
android:id="@+id/cover"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_centerInParent="true"
android:scaleType="fitXY" />

<RelativeLayout
android:id="@+id/thumb"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentBottom="true"
android:layout_alignParentEnd="true"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:background="#000000"
android:scaleType="fitCenter" />

<LinearLayout
android:id="@+id/layout_bottom"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_alignParentBottom="true"
android:background="#99000000"
android:gravity="center_vertical"
android:orientation="horizontal"
android:visibility="invisible">

<TextView
android:id="@+id/current"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:text="00:00"
android:textColor="#ffffff" />

<SeekBar
android:id="@+id/progress"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_weight="1.0"
android:background="@null"
android:max="100"
android:maxHeight="4dp"
android:minHeight="4dp"
android:paddingBottom="8dp"
android:paddingTop="8dp"
android:progressDrawable="@drawable/video_seek_progress"
android:thumb="@drawable/video_seek_thumb" />

<TextView
android:id="@+id/total"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="16dp"
android:text="00:00"
android:textColor="#ffffff" />

<TextView
android:id="@+id/switchSize"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginRight="16dp"
android:gravity="center"
android:minEms="2"
android:text="标准"
android:textColor="#ffffff" />

<ImageView
android:id="@+id/fullscreen"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:paddingRight="16dp"
android:scaleType="center"
android:src="@drawable/video_enlarge" />
</LinearLayout>

<ProgressBar
android:id="@+id/bottom_progressbar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="match_parent"
android:layout_height="1.5dp"
android:layout_alignParentBottom="true"
android:max="100"
android:progressDrawable="@drawable/video_progress" />

<ImageView
android:id="@+id/back_tiny"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_marginLeft="6dp"
android:layout_marginTop="6dp"
android:visibility="gone" />

<moe.codeest.enviews.ENDownloadView
android:id="@+id/loading"
android:layout_width="28dp"
android:layout_height="28dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:visibility="invisible" />

<moe.codeest.enviews.ENPlayView
android:id="@+id/start"
android:layout_width="60dp"
android:layout_height="60dp"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_gravity="center_vertical" />


<ImageView
android:id="@+id/small_close"
android:layout_width="30dp"
android:layout_height="30dp"
android:paddingLeft="10dp"
android:paddingTop="10dp"
android:scaleType="centerInside"
android:src="@drawable/video_small_close"
android:visibility="gone" />

<ImageView
android:id="@+id/lock_screen"
android:layout_width="30dp"
android:layout_height="30dp"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginRight="50dp"
android:scaleType="centerInside"
android:src="@drawable/unlock"
android:visibility="gone" />

<LinearLayout
android:id="@+id/layout_top"
android:layout_width="match_parent"
android:layout_height="48dp"
android:layout_alignParentTop="true"
android:layout_toEndOf="@+id/back_tiny"
android:layout_toRightOf="@+id/back_tiny"
android:background="@drawable/video_title_bg"
android:gravity="center_vertical">

<ImageView
android:id="@+id/back"
android:layout_width="48dp"
android:layout_height="48dp"
android:paddingLeft="10dp"
android:scaleType="centerInside"
android:src="@drawable/video_back" />

<TextView
android:id="@+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingLeft="10dp"
android:textColor="@android:color/white"
android:textSize="18sp" />
</LinearLayout>

<RelativeLayout
android:id="@+id/preview_layout"
android:layout_width="@dimen/seek_bar_image"
android:layout_height="100dp"
android:layout_above="@+id/layout_bottom"
android:layout_alignParentBottom="true"
android:layout_marginBottom="30dp"
android:visibility="gone" />

</RelativeLayout>

0 comments on commit fd0e84b

Please sign in to comment.