forked from CarGuo/GSYVideoPlayer
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 31c7187
Showing
42 changed files
with
2,469 additions
and
0 deletions.
There are no files selected for viewing
18 changes: 18 additions & 0 deletions
18
app/src/main/java/com/example/gsyvideoplayer/GSYApplication.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.example.gsyvideoplayer; | ||
|
||
import android.app.Application; | ||
|
||
import com.shuyu.gsyvideoplayer.GSYVideoManager; | ||
|
||
/** | ||
* Created by shuyu on 2016/11/11. | ||
*/ | ||
|
||
public class GSYApplication extends Application { | ||
|
||
@Override | ||
public void onCreate() { | ||
super.onCreate(); | ||
GSYVideoManager.initVideo(this); | ||
} | ||
} |
136 changes: 136 additions & 0 deletions
136
app/src/main/java/com/example/gsyvideoplayer/PlayActivity.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,136 @@ | ||
package com.example.gsyvideoplayer; | ||
|
||
import android.annotation.TargetApi; | ||
import android.content.pm.ActivityInfo; | ||
import android.os.Build; | ||
import android.os.Bundle; | ||
import android.support.v4.view.ViewCompat; | ||
import android.support.v7.app.AppCompatActivity; | ||
import android.transition.Transition; | ||
import android.view.View; | ||
|
||
|
||
import com.example.gsyvideoplayer.listener.OnTransitionListener; | ||
import com.shuyu.gsyvideoplayer.GSYVideoPlayer; | ||
import com.shuyu.gsyvideoplayer.utils.OrientationUtils; | ||
import com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer; | ||
|
||
import butterknife.BindView; | ||
import butterknife.ButterKnife; | ||
|
||
public class PlayActivity extends AppCompatActivity { | ||
|
||
public final static String IMG_TRANSITION = "IMG_TRANSITION"; | ||
public final static String TRANSITION = "TRANSITION"; | ||
|
||
@BindView(R.id.video_player) | ||
StandardGSYVideoPlayer videoPlayer; | ||
|
||
OrientationUtils orientationUtils; | ||
|
||
private boolean isTransition; | ||
|
||
@Override | ||
protected void onCreate(Bundle savedInstanceState) { | ||
super.onCreate(savedInstanceState); | ||
setContentView(R.layout.activity_play); | ||
ButterKnife.bind(this); | ||
isTransition = getIntent().getBooleanExtra(TRANSITION, false); | ||
init(); | ||
} | ||
|
||
private void init() { | ||
String url = "http://baobab.wdjcdn.com/14564977406580.mp4"; | ||
videoPlayer.setUp(url, true, ""); | ||
|
||
//Uri uri = Uri.parse(cover); | ||
//standardPlayer.thumbImageView.setImageURI(uri); | ||
//standardPlayer.titleTextView.setVisibility(View.GONE); | ||
|
||
videoPlayer.backButton.setVisibility(View.VISIBLE); | ||
videoPlayer.setIsTouchWiget(true); | ||
|
||
|
||
orientationUtils = new OrientationUtils(this, videoPlayer); | ||
|
||
videoPlayer.fullscreenButton.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
orientationUtils.resolveByClick(); | ||
} | ||
}); | ||
|
||
videoPlayer.backButton.setOnClickListener(new View.OnClickListener() { | ||
@Override | ||
public void onClick(View v) { | ||
onBackPressed(); | ||
} | ||
}); | ||
|
||
initTransition(); | ||
} | ||
|
||
|
||
@Override | ||
protected void onPause() { | ||
super.onPause(); | ||
videoPlayer.onVideoPause(); | ||
} | ||
|
||
@Override | ||
protected void onResume() { | ||
super.onResume(); | ||
} | ||
|
||
@Override | ||
protected void onDestroy() { | ||
super.onDestroy(); | ||
} | ||
|
||
@Override | ||
public void onBackPressed() { | ||
|
||
if (orientationUtils.getScreenType() == ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE) { | ||
videoPlayer.fullscreenButton.performClick(); | ||
return; | ||
} | ||
StandardGSYVideoPlayer.setJcBuriedPointStandard(null); | ||
GSYVideoPlayer.releaseAllVideos(); | ||
if (isTransition && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { | ||
super.onBackPressed(); | ||
} else { | ||
finish(); | ||
overridePendingTransition(R.anim.abc_fade_in, R.anim.abc_fade_out); | ||
} | ||
} | ||
|
||
|
||
private void initTransition() { | ||
if (isTransition && Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) { | ||
postponeEnterTransition(); | ||
ViewCompat.setTransitionName(videoPlayer, IMG_TRANSITION); | ||
addTransitionListener(); | ||
startPostponedEnterTransition(); | ||
} else { | ||
videoPlayer.startPlayLocic(); | ||
} | ||
} | ||
|
||
@TargetApi(Build.VERSION_CODES.LOLLIPOP) | ||
private boolean addTransitionListener() { | ||
final Transition transition = getWindow().getSharedElementEnterTransition(); | ||
if (transition != null) { | ||
transition.addListener(new OnTransitionListener() { | ||
@Override | ||
public void onTransitionEnd(Transition transition) { | ||
videoPlayer.startPlayLocic(); | ||
// Make sure we remove ourselves as a listener | ||
transition.removeListener(this); | ||
} | ||
}); | ||
return true; | ||
} | ||
return false; | ||
} | ||
|
||
} |
39 changes: 39 additions & 0 deletions
39
app/src/main/java/com/example/gsyvideoplayer/listener/OnTransitionListener.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
package com.example.gsyvideoplayer.listener; | ||
|
||
import android.annotation.TargetApi; | ||
import android.os.Build; | ||
import android.transition.Transition; | ||
|
||
/** | ||
* Created by shuyu on 2016/8/15. | ||
*/ | ||
|
||
@TargetApi(Build.VERSION_CODES.KITKAT) | ||
public class OnTransitionListener implements Transition.TransitionListener { | ||
|
||
|
||
@Override | ||
public void onTransitionStart(Transition transition) { | ||
|
||
} | ||
|
||
@Override | ||
public void onTransitionEnd(Transition transition) { | ||
|
||
} | ||
|
||
@Override | ||
public void onTransitionCancel(Transition transition) { | ||
|
||
} | ||
|
||
@Override | ||
public void onTransitionPause(Transition transition) { | ||
|
||
} | ||
|
||
@Override | ||
public void onTransitionResume(Transition transition) { | ||
|
||
} | ||
} |
36 changes: 36 additions & 0 deletions
36
app/src/main/java/com/example/gsyvideoplayer/utils/JumpUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package com.example.gsyvideoplayer.utils; | ||
|
||
import android.app.Activity; | ||
import android.content.Intent; | ||
import android.support.v4.app.ActivityCompat; | ||
import android.support.v4.app.ActivityOptionsCompat; | ||
import android.support.v4.util.Pair; | ||
import android.view.View; | ||
|
||
import com.example.gsyvideoplayer.PlayActivity; | ||
import com.example.gsyvideoplayer.R; | ||
|
||
/** | ||
* Created by shuyu on 2016/11/11. | ||
*/ | ||
|
||
public class JumpUtils { | ||
|
||
/** | ||
* @param activity | ||
* @param view | ||
*/ | ||
public static void goToVideoPlayer(Activity activity, View view) { | ||
Intent intent = new Intent(activity, PlayActivity.class); | ||
intent.putExtra(PlayActivity.TRANSITION, true); | ||
if (android.os.Build.VERSION.SDK_INT >= android.os.Build.VERSION_CODES.LOLLIPOP) { | ||
Pair pair = new Pair<>(view, PlayActivity.IMG_TRANSITION); | ||
ActivityOptionsCompat activityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation( | ||
activity, pair); | ||
ActivityCompat.startActivity(activity, intent, activityOptions.toBundle()); | ||
} else { | ||
activity.startActivity(intent); | ||
activity.overridePendingTransition(R.anim.abc_fade_in, R.anim.abc_fade_out); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" | ||
android:id="@+id/activity_play" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:background="#000000"> | ||
|
||
<com.shuyu.gsyvideoplayer.video.StandardGSYVideoPlayer | ||
android:id="@+id/video_player" | ||
android:layout_width="match_parent" | ||
android:layout_height="match_parent" | ||
android:layout_centerInParent="true" /> | ||
|
||
</RelativeLayout> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
allprojects { | ||
repositories { | ||
jcenter() | ||
} | ||
} | ||
|
||
ext { | ||
//Android | ||
androidBuildToolsVersion = "23.0.1" | ||
androidMinSdkVersion = 19 | ||
androidTargetSdkVersion = 22 | ||
androidCompileSdkVersion = 22 | ||
supportLibraryVersion = '24.2.0' | ||
otherLibraryVersion = '22.2.1' | ||
|
||
//ViewLibraries | ||
butterKnifeVersion = '8.2.1' | ||
|
||
//ViewLibraries | ||
butterKnifeVersion = '8.2.1' | ||
ijkplayer = '0.7.2' | ||
|
||
//DataLibraries | ||
videocache = '2.6.3' | ||
|
||
androidDependencies = [ | ||
recyclerView: "com.android.support:recyclerview-v7:${supportLibraryVersion}", | ||
appcompat_v7: "com.android.support:appcompat-v7:${otherLibraryVersion}", | ||
cardview_v7 : "com.android.support:cardview-v7:23.2.0", | ||
support_v4 : "com.android.support:support-v4:${supportLibraryVersion}", | ||
design : "com.android.support:design:${otherLibraryVersion}", | ||
] | ||
|
||
viewDependencies = [ | ||
butterKnife : "com.jakewharton:butterknife:${butterKnifeVersion}", | ||
apt_butterKnife : "com.jakewharton:butterknife-compiler:${butterKnifeVersion}", | ||
ijkplayer_java : "tv.danmaku.ijk.media:ijkplayer-java:${ijkplayer}", | ||
ijkplayer_armv7a: "tv.danmaku.ijk.media:ijkplayer-armv7a:${ijkplayer}", | ||
ijkplayer_armv5 : "tv.danmaku.ijk.media:ijkplayer-armv5:${ijkplayer}", | ||
ijkplayer_exo : "tv.danmaku.ijk.media:ijkplayer-exo:${ijkplayer}", | ||
] | ||
|
||
dataDependencies = [ | ||
videocache : "com.danikula:videocache:${videocache}", | ||
] | ||
} |
Oops, something went wrong.