diff --git a/LICENSE b/LICENSE
new file mode 100644
index 000000000..d216c3c38
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,21 @@
+The MIT License (MIT)
+
+Copyright (c) [year] [fullname]
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
+SOFTWARE.
\ No newline at end of file
diff --git a/README.md b/README.md
new file mode 100644
index 000000000..457627c6e
--- /dev/null
+++ b/README.md
@@ -0,0 +1,33 @@
+#节操视频播放器
+
+真正实现Android的全屏功能,励志成为Android平台使用最广泛的视频播放控件
+
+##使用
+添加布局
+```html
+
+```
+
+设置视频地址、缩略图地址、标题
+```java
+JCVideoPlayer videoController = (JCVideoPlayer) findViewById(R.id.videocontroller);
+videoController.setUp("http://2449.vod.myqcloud.com/2449_43b6f696980311e59ed467f22794e792.f20.mp4",
+ "http://p.qpic.cn/videoyun/0/2449_43b6f696980311e59ed467f22794e792_1/640",
+ "嫂子别摸我");
+```
+
+其他接口,停止所有视频
+```
+JCVideoPlayer.releaseAllVideo();
+```
+
+##效果
+
+![Demo Screenshot][1]
+
+效果视频 : http://v.youku.com/v_show/id_XMTQ2NzUwOTcyNA==.html?firsttime=0&from=y1.4-2
+
+[1]: ./effect.gif
diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml
index 5a8642fd1..4a5bec139 100644
--- a/app/src/main/AndroidManifest.xml
+++ b/app/src/main/AndroidManifest.xml
@@ -11,13 +11,21 @@
android:theme="@style/AppTheme">
+ android:configChanges="orientation"
+ android:screenOrientation="portrait">
+
+
+
diff --git a/app/src/main/java/fm/jiecao/jiecaovideoplayer/ListActivity.java b/app/src/main/java/fm/jiecao/jiecaovideoplayer/ListActivity.java
new file mode 100644
index 000000000..9ed76e61b
--- /dev/null
+++ b/app/src/main/java/fm/jiecao/jiecaovideoplayer/ListActivity.java
@@ -0,0 +1,47 @@
+package fm.jiecao.jiecaovideoplayer;
+
+import android.content.Context;
+import android.os.Bundle;
+import android.support.v7.app.AppCompatActivity;
+import android.view.LayoutInflater;
+import android.view.MenuItem;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+import android.widget.ListView;
+
+import fm.jiecao.jcvideoplayer_lib.JCVideoPlayer;
+
+/**
+ * Created by Nathen
+ * On 2016/02/06 19:12
+ */
+public class ListActivity extends AppCompatActivity {
+ ListView listView;
+
+
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_list);
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+ getSupportActionBar().setDisplayShowHomeEnabled(true);
+ getSupportActionBar().setDisplayShowTitleEnabled(true);
+ getSupportActionBar().setDisplayUseLogoEnabled(false);
+
+ listView = (ListView) findViewById(R.id.listview);
+ listView.setAdapter(new VideoListAdapter(this));
+ }
+
+
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ finish();
+ break;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+}
diff --git a/app/src/main/java/fm/jiecao/jiecaovideoplayer/ListViewpagerActivity.java b/app/src/main/java/fm/jiecao/jiecaovideoplayer/ListViewpagerActivity.java
new file mode 100644
index 000000000..ffd8b25ad
--- /dev/null
+++ b/app/src/main/java/fm/jiecao/jiecaovideoplayer/ListViewpagerActivity.java
@@ -0,0 +1,105 @@
+package fm.jiecao.jiecaovideoplayer;
+
+import android.os.Bundle;
+import android.support.v4.view.PagerAdapter;
+import android.support.v4.view.ViewPager;
+import android.support.v7.app.AppCompatActivity;
+import android.view.MenuItem;
+import android.view.View;
+import android.widget.ListView;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import fm.jiecao.jcvideoplayer_lib.JCVideoPlayer;
+
+/**
+ * Created by Nathen
+ * On 2016/02/07 01:01
+ */
+public class ListViewpagerActivity extends AppCompatActivity implements ViewPager.OnPageChangeListener {
+ @Override
+ protected void onCreate(Bundle savedInstanceState) {
+ super.onCreate(savedInstanceState);
+ setContentView(R.layout.activity_list_viewpager);
+ getSupportActionBar().setDisplayHomeAsUpEnabled(true);
+ getSupportActionBar().setDisplayShowHomeEnabled(true);
+ getSupportActionBar().setDisplayShowTitleEnabled(true);
+ getSupportActionBar().setDisplayUseLogoEnabled(false);
+
+ List listViews = new ArrayList<>();
+ ListView listView1 = (ListView) getLayoutInflater().inflate(R.layout.layout_list, null);
+ ListView listView2 = (ListView) getLayoutInflater().inflate(R.layout.layout_list, null);
+ ListView listView3 = (ListView) getLayoutInflater().inflate(R.layout.layout_list, null);
+
+ listView1.setAdapter(new VideoListAdapter(this));
+ listView2.setAdapter(new VideoListAdapter(this));
+ listView3.setAdapter(new VideoListAdapter(this));
+
+ listViews.add(listView1);
+ listViews.add(listView2);
+ listViews.add(listView3);
+
+ MyAdapter myAdapter = new MyAdapter(listViews);
+ ViewPager viewPager = (ViewPager) findViewById(R.id.viewPager);
+ viewPager.setAdapter(myAdapter);
+ viewPager.setOnPageChangeListener(this);
+ }
+
+ @Override
+ public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) {
+
+ }
+
+ @Override
+ public void onPageSelected(int position) {
+ JCVideoPlayer.releaseAllVideo();
+ }
+
+ @Override
+ public void onPageScrollStateChanged(int state) {
+
+ }
+
+ public class MyAdapter extends PagerAdapter {
+
+ List viewLists;
+
+ public MyAdapter(List lists) {
+ viewLists = lists;
+ }
+
+ @Override
+ public int getCount() {
+ // TODO Auto-generated method stub
+ return viewLists.size();
+ }
+
+ @Override
+ public boolean isViewFromObject(View arg0, Object arg1) {
+ // TODO Auto-generated method stub
+ return arg0 == arg1;
+ }
+
+ @Override
+ public void destroyItem(View view, int position, Object object) {
+ ((ViewPager) view).removeView(viewLists.get(position));
+ }
+
+ @Override
+ public Object instantiateItem(View view, int position) {
+ ((ViewPager) view).addView(viewLists.get(position), 0);
+ return viewLists.get(position);
+ }
+ }
+
+ @Override
+ public boolean onOptionsItemSelected(MenuItem item) {
+ switch (item.getItemId()) {
+ case android.R.id.home:
+ finish();
+ break;
+ }
+ return super.onOptionsItemSelected(item);
+ }
+}
diff --git a/app/src/main/java/fm/jiecao/jiecaovideoplayer/MainActivity.java b/app/src/main/java/fm/jiecao/jiecaovideoplayer/MainActivity.java
index bed51a58d..19585c3a0 100644
--- a/app/src/main/java/fm/jiecao/jiecaovideoplayer/MainActivity.java
+++ b/app/src/main/java/fm/jiecao/jiecaovideoplayer/MainActivity.java
@@ -1,21 +1,27 @@
package fm.jiecao.jiecaovideoplayer;
+import android.content.Intent;
import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
+import android.view.View;
+import android.widget.Button;
+import android.widget.Toast;
import de.greenrobot.event.EventBus;
import fm.jiecao.jcvideoplayer_lib.JCVideoPlayer;
import fm.jiecao.jcvideoplayer_lib.VideoEvents;
-public class MainActivity extends AppCompatActivity {
+
+public class MainActivity extends AppCompatActivity implements View.OnClickListener {
JCVideoPlayer videoController1, videoController2;
+ Button btnToList, btnToListViewpager, btnToFullscreen, btnToChangecolor;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
-
setContentView(R.layout.activity_main);
+ EventBus.getDefault().register(this);
videoController1 = (JCVideoPlayer) findViewById(R.id.videocontroller1);
videoController1.setUp("http://2449.vod.myqcloud.com/2449_43b6f696980311e59ed467f22794e792.f20.mp4",
@@ -26,7 +32,23 @@ protected void onCreate(Bundle savedInstanceState) {
videoController2.setUp("http://2449.vod.myqcloud.com/2449_ded7b566b37911e5942f0b208e48548d.f20.mp4",//
"http://p.qpic.cn/videoyun/0/2449_ded7b566b37911e5942f0b208e48548d_2/640",
"嫂子还摸我", false);
- EventBus.getDefault().register(this);
+
+ btnToList = (Button) findViewById(R.id.to_list_activity);
+ btnToListViewpager = (Button) findViewById(R.id.to_list_viewpager_activity);
+ btnToFullscreen = (Button) findViewById(R.id.to_fullscreen);
+ btnToChangecolor = (Button) findViewById(R.id.to_changecolor_activity);
+
+ btnToList.setOnClickListener(this);
+ btnToListViewpager.setOnClickListener(this);
+ btnToFullscreen.setOnClickListener(this);
+ btnToChangecolor.setOnClickListener(this);
+
+ }
+
+ @Override
+ protected void onPause() {
+ super.onPause();
+ JCVideoPlayer.releaseAllVideo();
}
@Override
@@ -66,4 +88,23 @@ public void onEventMainThread(VideoEvents event) {
Log.i("Video Event", "POINT_QUIT_FULLSCREEN");
}
}
+
+ @Override
+ public void onClick(View v) {
+ JCVideoPlayer.releaseAllVideo();
+ switch (v.getId()) {
+ case R.id.to_list_activity:
+ startActivity(new Intent(MainActivity.this, ListActivity.class));
+ break;
+ case R.id.to_list_viewpager_activity:
+ startActivity(new Intent(MainActivity.this, ListViewpagerActivity.class));
+ break;
+ case R.id.to_fullscreen:
+ Toast.makeText(MainActivity.this, "coming soon", Toast.LENGTH_SHORT).show();
+ break;
+ case R.id.to_changecolor_activity:
+ Toast.makeText(MainActivity.this, "coming soon", Toast.LENGTH_SHORT).show();
+ break;
+ }
+ }
}
diff --git a/app/src/main/java/fm/jiecao/jiecaovideoplayer/VideoListAdapter.java b/app/src/main/java/fm/jiecao/jiecaovideoplayer/VideoListAdapter.java
new file mode 100644
index 000000000..45140358d
--- /dev/null
+++ b/app/src/main/java/fm/jiecao/jiecaovideoplayer/VideoListAdapter.java
@@ -0,0 +1,66 @@
+package fm.jiecao.jiecaovideoplayer;
+
+import android.content.Context;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.BaseAdapter;
+
+import fm.jiecao.jcvideoplayer_lib.JCVideoPlayer;
+
+/**
+ * Created by Nathen
+ * On 2016/02/07 01:20
+ */
+public class VideoListAdapter extends BaseAdapter {
+ String[] videoUrls = {"http://2449.vod.myqcloud.com/2449_43b6f696980311e59ed467f22794e792.f20.mp4",
+ "http://2449.vod.myqcloud.com/2449_ded7b566b37911e5942f0b208e48548d.f20.mp4"};
+ String[] videoThumbs = {"http://p.qpic.cn/videoyun/0/2449_43b6f696980311e59ed467f22794e792_1/640",
+ "http://p.qpic.cn/videoyun/0/2449_ded7b566b37911e5942f0b208e48548d_2/640"};
+ String[] videoTitles = {"嫂子别摸我", "嫂子还摸我"};
+
+ int[] videoIndexs = {0, 1, 1, 1, 1, 0, 1, 0, 1, 1, 0, 0, 1};
+ Context context;
+
+ public VideoListAdapter(Context context) {
+ this.context = context;
+ }
+
+ @Override
+ public int getCount() {
+ return videoIndexs.length;
+ }
+
+ @Override
+ public Object getItem(int position) {
+ return null;
+ }
+
+ @Override
+ public long getItemId(int position) {
+ return 0;
+ }
+
+ @Override
+ public View getView(int position, View convertView, ViewGroup parent) {
+ ViewHolder viewHolder;
+ if (null == convertView) {
+ viewHolder = new ViewHolder();
+ LayoutInflater mInflater = LayoutInflater.from(context);
+ convertView = mInflater.inflate(R.layout.item_list, null);
+ viewHolder.jcVideoPlayer = (JCVideoPlayer) convertView.findViewById(R.id.videoplayer);
+ convertView.setTag(viewHolder);
+ } else {
+ viewHolder = (ViewHolder) convertView.getTag();
+ }
+ viewHolder.jcVideoPlayer.setUp(
+ videoUrls[videoIndexs[position]],
+ videoThumbs[videoIndexs[position]],
+ videoTitles[videoIndexs[position]]);
+ return convertView;
+ }
+
+ class ViewHolder {
+ JCVideoPlayer jcVideoPlayer;
+ }
+}
diff --git a/app/src/main/res/layout/activity_list.xml b/app/src/main/res/layout/activity_list.xml
new file mode 100644
index 000000000..35be9327f
--- /dev/null
+++ b/app/src/main/res/layout/activity_list.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/activity_list_viewpager.xml b/app/src/main/res/layout/activity_list_viewpager.xml
new file mode 100644
index 000000000..19f242abd
--- /dev/null
+++ b/app/src/main/res/layout/activity_list_viewpager.xml
@@ -0,0 +1,12 @@
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml
index c568cd139..f6a447991 100644
--- a/app/src/main/res/layout/activity_main.xml
+++ b/app/src/main/res/layout/activity_main.xml
@@ -4,18 +4,63 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
- android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="fm.jiecao.jiecaovideoplayer.MainActivity">
-
+ android:layout_height="wrap_content"
+ android:scrollbars="none">
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
-
diff --git a/app/src/main/res/layout/item_list.xml b/app/src/main/res/layout/item_list.xml
new file mode 100644
index 000000000..e9b57218e
--- /dev/null
+++ b/app/src/main/res/layout/item_list.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
diff --git a/app/src/main/res/layout/layout_list.xml b/app/src/main/res/layout/layout_list.xml
new file mode 100644
index 000000000..a519ca432
--- /dev/null
+++ b/app/src/main/res/layout/layout_list.xml
@@ -0,0 +1,6 @@
+
+
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 0a30b5310..c532badb8 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -1,3 +1,3 @@
- 节操精选视频播放器
+ 节操视频播放器
diff --git a/build.gradle b/build.gradle
index 0abc2df9f..481a2e27c 100644
--- a/build.gradle
+++ b/build.gradle
@@ -5,7 +5,7 @@ buildscript {
jcenter()
}
dependencies {
- classpath 'com.android.tools.build:gradle:2.0.0-alpha5'
+ classpath 'com.android.tools.build:gradle:2.0.0-beta5'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
diff --git a/effect.gif b/effect.gif
new file mode 100644
index 000000000..b23cf0ed0
Binary files /dev/null and b/effect.gif differ
diff --git a/jcvideoplayer-lib/build.gradle b/jcvideoplayer-lib/build.gradle
index 264a50840..5b5ec46ae 100644
--- a/jcvideoplayer-lib/build.gradle
+++ b/jcvideoplayer-lib/build.gradle
@@ -7,8 +7,8 @@ android {
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
- versionCode 1
- versionName "1.0"
+ versionCode 12
+ versionName "1.2_preview"
}
buildTypes {
release {
diff --git a/jcvideoplayer-lib/src/main/java/fm/jiecao/jcvideoplayer_lib/JCVideoPlayer.java b/jcvideoplayer-lib/src/main/java/fm/jiecao/jcvideoplayer_lib/JCVideoPlayer.java
index 2b74c3260..07a883c53 100644
--- a/jcvideoplayer-lib/src/main/java/fm/jiecao/jcvideoplayer_lib/JCVideoPlayer.java
+++ b/jcvideoplayer-lib/src/main/java/fm/jiecao/jcvideoplayer_lib/JCVideoPlayer.java
@@ -151,6 +151,9 @@ public void setUp(String url, String thumb, String title, boolean ifShowTitle) {
ImageLoader.getInstance().displayImage(thumb, ivThumb, getDefaultDisplayImageOption());
CURRENT_STATE = CURRENT_STATE_NORMAL;
setTitleVisibility(View.VISIBLE);
+ if (uuid.equals(JCMediaPlayer.intance().uuid)) {
+ JCMediaPlayer.intance().mediaPlayer.stop();
+ }
}
public void setUpForFullscreen(String url, String thumb, String title, boolean ifFullScreen) {
@@ -576,7 +579,9 @@ protected void onDetachedFromWindow() {
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
- EventBus.getDefault().register(this);
+ if (!EventBus.getDefault().isRegistered(this)) {
+ EventBus.getDefault().register(this);
+ }
}
@Override
@@ -646,15 +651,13 @@ private String stringForTime(int timeMs) {
* 停止所有音频的播放
*/
public static void releaseAllVideo() {
- if (JCMediaPlayer.intance().mediaPlayer.isPlaying()) {
- JCMediaPlayer.intance().mediaPlayer.stop();
- JCMediaPlayer.intance().setUuid("");
- JCMediaPlayer.intance().setUuid("");
- EventBus.getDefault().post(new VideoEvents().setType(VideoEvents.VE_MEDIAPLAYER_FINISH_COMPLETE));
- }
+ JCMediaPlayer.intance().mediaPlayer.stop();
+ JCMediaPlayer.intance().setUuid("");
+ JCMediaPlayer.intance().setUuid("");
+ EventBus.getDefault().post(new VideoEvents().setType(VideoEvents.VE_MEDIAPLAYER_FINISH_COMPLETE));
}
- public static DisplayImageOptions getDefaultDisplayImageOption() {
+ public DisplayImageOptions getDefaultDisplayImageOption() {
DisplayImageOptions options = new DisplayImageOptions.Builder()
.showImageOnLoading(new ColorDrawable(Color.parseColor("#f0f0f0")))
.resetViewBeforeLoading(true)
diff --git a/jcvideoplayer-lib/src/main/res/values/strings.xml b/jcvideoplayer-lib/src/main/res/values/strings.xml
index 0a30b5310..c532badb8 100644
--- a/jcvideoplayer-lib/src/main/res/values/strings.xml
+++ b/jcvideoplayer-lib/src/main/res/values/strings.xml
@@ -1,3 +1,3 @@
- 节操精选视频播放器
+ 节操视频播放器