From 2846ee1333698fca7b7e765f4c0cbc9efe556a97 Mon Sep 17 00:00:00 2001 From: Nathen <821537155@qq.com> Date: Sun, 29 Oct 2017 22:33:27 +0800 Subject: [PATCH 01/46] release surface when complete --- jiaozivideoplayer/src/main/java/cn/jzvd/JZVideoPlayer.java | 1 + 1 file changed, 1 insertion(+) diff --git a/jiaozivideoplayer/src/main/java/cn/jzvd/JZVideoPlayer.java b/jiaozivideoplayer/src/main/java/cn/jzvd/JZVideoPlayer.java index d262a2244..d8c44c4d3 100644 --- a/jiaozivideoplayer/src/main/java/cn/jzvd/JZVideoPlayer.java +++ b/jiaozivideoplayer/src/main/java/cn/jzvd/JZVideoPlayer.java @@ -712,6 +712,7 @@ public void onCompletion() { clearFullscreenLayout(); JZUtils.setRequestedOrientation(getContext(), NORMAL_ORIENTATION); + if (JZMediaManager.surface != null) JZMediaManager.surface.release(); JZMediaManager.textureView = null; JZMediaManager.savedSurfaceTexture = null; isVideoRendingStart = false; From 65633c8de5481b99972b6514a76b0f6dfa5fa32c Mon Sep 17 00:00:00 2001 From: lipan <821537155@qq.com> Date: Tue, 31 Oct 2017 15:00:30 +0800 Subject: [PATCH 02/46] fix code --- app/src/main/java/cn/jzvd/demo/ApiActivity.java | 12 ++++++------ ...deoPlayerStandardAutoCompleteAfterFullscreen.java | 1 - ...PlayerStandardShowShareButtonAfterFullscreen.java | 2 +- .../java/cn/jzvd/demo/DirectFullscreenActivity.java | 4 ++-- app/src/main/java/cn/jzvd/demo/ListViewActivity.java | 10 +++++----- .../jzvd/demo/ListViewFragmentViewPagerActivity.java | 2 +- .../cn/jzvd/demo/ListViewMultiHolderActivity.java | 6 +++--- .../java/cn/jzvd/demo/ListViewNormalActivity.java | 2 +- .../cn/jzvd/demo/ListViewNormalAutoTinyActivity.java | 2 +- app/src/main/java/cn/jzvd/demo/MainActivity.java | 12 ++++++------ .../main/java/cn/jzvd/demo/OrientationActivity.java | 2 +- .../cn/jzvd/demo/RecyclerViewNormalActivity.java | 2 +- .../java/cn/jzvd/demo/RecyclerViewVideoAdapter.java | 2 +- .../java/cn/jzvd/demo/UISmallChangeActivity.java | 8 ++++---- app/src/main/java/cn/jzvd/demo/VideoListAdapter.java | 2 +- app/src/main/java/cn/jzvd/demo/WebViewActivity.java | 2 +- 16 files changed, 35 insertions(+), 36 deletions(-) diff --git a/app/src/main/java/cn/jzvd/demo/ApiActivity.java b/app/src/main/java/cn/jzvd/demo/ApiActivity.java index 6349d88aa..f4f01f7e2 100644 --- a/app/src/main/java/cn/jzvd/demo/ApiActivity.java +++ b/app/src/main/java/cn/jzvd/demo/ApiActivity.java @@ -45,22 +45,22 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { getSupportActionBar().setTitle("Api"); setContentView(R.layout.activity_api); - mSmallChange = (Button) findViewById(R.id.small_change); - mBigChange = (Button) findViewById(R.id.big_change); - mOrientation = (Button) findViewById(R.id.orientation); - mExtendsNormalActivity = (Button) findViewById(R.id.extends_normal_activity); + mSmallChange = findViewById(R.id.small_change); + mBigChange = findViewById(R.id.big_change); + mOrientation = findViewById(R.id.orientation); + mExtendsNormalActivity = findViewById(R.id.extends_normal_activity); mSmallChange.setOnClickListener(this); mBigChange.setOnClickListener(this); mOrientation.setOnClickListener(this); mExtendsNormalActivity.setOnClickListener(this); - mJzVideoPlayerSimple = (JZVideoPlayerSimple) findViewById(R.id.simple_demo); + mJzVideoPlayerSimple = findViewById(R.id.simple_demo); mJzVideoPlayerSimple.setUp("http://devimages.apple.com/iphone/samples/bipbop/gear1/prog_index.m3u8" , JZVideoPlayerStandard.SCREEN_LAYOUT_NORMAL, "饺子在家吗"); - mJzVideoPlayerStandard = (JZVideoPlayerStandard) findViewById(R.id.jz_video); + mJzVideoPlayerStandard = findViewById(R.id.jz_video); LinkedHashMap map = new LinkedHashMap(); map.put("高清", VideoConstant.videoUrls[0][9]); map.put("标清", VideoConstant.videoUrls[0][6]); diff --git a/app/src/main/java/cn/jzvd/demo/CustomView/JZVideoPlayerStandardAutoCompleteAfterFullscreen.java b/app/src/main/java/cn/jzvd/demo/CustomView/JZVideoPlayerStandardAutoCompleteAfterFullscreen.java index 1c9d86d6c..45e16573d 100644 --- a/app/src/main/java/cn/jzvd/demo/CustomView/JZVideoPlayerStandardAutoCompleteAfterFullscreen.java +++ b/app/src/main/java/cn/jzvd/demo/CustomView/JZVideoPlayerStandardAutoCompleteAfterFullscreen.java @@ -25,7 +25,6 @@ public JZVideoPlayerStandardAutoCompleteAfterFullscreen(Context context, Attribu @Override public void startVideo() { -// super.startVideo(); if (currentScreen == SCREEN_WINDOW_FULLSCREEN) { Log.d(TAG, "startVideo [" + this.hashCode() + "] "); initTextureView(); diff --git a/app/src/main/java/cn/jzvd/demo/CustomView/JZVideoPlayerStandardShowShareButtonAfterFullscreen.java b/app/src/main/java/cn/jzvd/demo/CustomView/JZVideoPlayerStandardShowShareButtonAfterFullscreen.java index abe953a42..90753c433 100755 --- a/app/src/main/java/cn/jzvd/demo/CustomView/JZVideoPlayerStandardShowShareButtonAfterFullscreen.java +++ b/app/src/main/java/cn/jzvd/demo/CustomView/JZVideoPlayerStandardShowShareButtonAfterFullscreen.java @@ -28,7 +28,7 @@ public JZVideoPlayerStandardShowShareButtonAfterFullscreen(Context context, Attr @Override public void init(Context context) { super.init(context); - shareButton = (ImageView) findViewById(R.id.share); + shareButton = findViewById(R.id.share); shareButton.setOnClickListener(this); } diff --git a/app/src/main/java/cn/jzvd/demo/DirectFullscreenActivity.java b/app/src/main/java/cn/jzvd/demo/DirectFullscreenActivity.java index b2c78e0e2..581978f03 100644 --- a/app/src/main/java/cn/jzvd/demo/DirectFullscreenActivity.java +++ b/app/src/main/java/cn/jzvd/demo/DirectFullscreenActivity.java @@ -28,8 +28,8 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { getSupportActionBar().setTitle("PlayDirectlyWithoutLayout"); setContentView(R.layout.activity_directly_play); - mStartFullscreen = (Button) findViewById(R.id.fullscreen); - mStartTiny = (Button) findViewById(R.id.tiny_window); + mStartFullscreen = findViewById(R.id.fullscreen); + mStartTiny = findViewById(R.id.tiny_window); mStartFullscreen.setOnClickListener(this); mStartTiny.setOnClickListener(this); diff --git a/app/src/main/java/cn/jzvd/demo/ListViewActivity.java b/app/src/main/java/cn/jzvd/demo/ListViewActivity.java index 493672126..83f07219e 100644 --- a/app/src/main/java/cn/jzvd/demo/ListViewActivity.java +++ b/app/src/main/java/cn/jzvd/demo/ListViewActivity.java @@ -24,11 +24,11 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { getSupportActionBar().setTitle("ListView"); setContentView(R.layout.activity_listview); - mNormal = (Button) findViewById(R.id.normal); - mNormalAutoTiny = (Button) findViewById(R.id.normal_auto_tiny); - mViewPager = (Button) findViewById(R.id.listview_fragment_viewpager); - mMultiHolder = (Button) findViewById(R.id.multiholder); - mRecyleView = (Button) findViewById(R.id.recyleview); + mNormal = findViewById(R.id.normal); + mNormalAutoTiny = findViewById(R.id.normal_auto_tiny); + mViewPager = findViewById(R.id.listview_fragment_viewpager); + mMultiHolder = findViewById(R.id.multiholder); + mRecyleView = findViewById(R.id.recyleview); mNormal.setOnClickListener(this); mNormalAutoTiny.setOnClickListener(this); diff --git a/app/src/main/java/cn/jzvd/demo/ListViewFragmentViewPagerActivity.java b/app/src/main/java/cn/jzvd/demo/ListViewFragmentViewPagerActivity.java index 2ca4be152..154d89fec 100755 --- a/app/src/main/java/cn/jzvd/demo/ListViewFragmentViewPagerActivity.java +++ b/app/src/main/java/cn/jzvd/demo/ListViewFragmentViewPagerActivity.java @@ -35,7 +35,7 @@ protected void onCreate(Bundle savedInstanceState) { fragmentList.add(new DemoFragment().setIndex(2)); MyAdapter myAdapter = new MyAdapter(getSupportFragmentManager()); - ViewPager viewPager = (ViewPager) findViewById(R.id.viewPager); + ViewPager viewPager = findViewById(R.id.viewPager); viewPager.setAdapter(myAdapter); viewPager.setOnPageChangeListener(this); } diff --git a/app/src/main/java/cn/jzvd/demo/ListViewMultiHolderActivity.java b/app/src/main/java/cn/jzvd/demo/ListViewMultiHolderActivity.java index 539b25af5..47e44ec59 100755 --- a/app/src/main/java/cn/jzvd/demo/ListViewMultiHolderActivity.java +++ b/app/src/main/java/cn/jzvd/demo/ListViewMultiHolderActivity.java @@ -36,7 +36,7 @@ protected void onCreate(Bundle savedInstanceState) { getSupportActionBar().setTitle("MultiHolderListView"); - listView = (ListView) findViewById(R.id.listview); + listView = findViewById(R.id.listview); mAdapter = new VideoListAdapter(this); listView.setAdapter(mAdapter); @@ -113,7 +113,7 @@ public View getView(int position, View convertView, ViewGroup parent) { } else { viewHolder = new VideoHolder(); convertView = mInflater.inflate(R.layout.item_videoview, null); - viewHolder.jzVideoPlayer = (JZVideoPlayerStandard) convertView.findViewById(R.id.videoplayer); + viewHolder.jzVideoPlayer = convertView.findViewById(R.id.videoplayer); convertView.setTag(viewHolder); } @@ -132,7 +132,7 @@ public View getView(int position, View convertView, ViewGroup parent) { textViewHolder = new TextViewHolder(); LayoutInflater mInflater = LayoutInflater.from(context); convertView = mInflater.inflate(R.layout.item_textview, null); - textViewHolder.textView = (TextView) convertView.findViewById(R.id.textview); + textViewHolder.textView = convertView.findViewById(R.id.textview); convertView.setTag(textViewHolder); } } diff --git a/app/src/main/java/cn/jzvd/demo/ListViewNormalActivity.java b/app/src/main/java/cn/jzvd/demo/ListViewNormalActivity.java index 74f7abe31..5b0779dce 100644 --- a/app/src/main/java/cn/jzvd/demo/ListViewNormalActivity.java +++ b/app/src/main/java/cn/jzvd/demo/ListViewNormalActivity.java @@ -33,7 +33,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { getSupportActionBar().setTitle("NormalListView"); setContentView(R.layout.activity_listview_normal); - listView = (ListView) findViewById(R.id.listview); + listView = findViewById(R.id.listview); listView.setAdapter(new VideoListAdapter(this, VideoConstant.videoUrls[0], VideoConstant.videoTitles[0], diff --git a/app/src/main/java/cn/jzvd/demo/ListViewNormalAutoTinyActivity.java b/app/src/main/java/cn/jzvd/demo/ListViewNormalAutoTinyActivity.java index 25731788e..14a4c2ac6 100644 --- a/app/src/main/java/cn/jzvd/demo/ListViewNormalAutoTinyActivity.java +++ b/app/src/main/java/cn/jzvd/demo/ListViewNormalAutoTinyActivity.java @@ -30,7 +30,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { getSupportActionBar().setTitle("NormalListViewAutoTiny"); setContentView(R.layout.activity_listview_normal_auto_tiny); - listView = (ListView) findViewById(R.id.listview); + listView = findViewById(R.id.listview); listView.setAdapter(new VideoListAdapter(this, VideoConstant.videoUrls[0], VideoConstant.videoTitles[0], diff --git a/app/src/main/java/cn/jzvd/demo/MainActivity.java b/app/src/main/java/cn/jzvd/demo/MainActivity.java index 9fac8c0d9..528587343 100644 --- a/app/src/main/java/cn/jzvd/demo/MainActivity.java +++ b/app/src/main/java/cn/jzvd/demo/MainActivity.java @@ -31,11 +31,11 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_main); - mTinyWindow = (Button) findViewById(R.id.tiny_window); - mDirectFullscreen = (Button) findViewById(R.id.direct_fullscreen); - mListView = (Button) findViewById(R.id.listview); - mApi = (Button) findViewById(R.id.api); - mWebView = (Button) findViewById(R.id.webview); + mTinyWindow = findViewById(R.id.tiny_window); + mDirectFullscreen = findViewById(R.id.direct_fullscreen); + mListView = findViewById(R.id.listview); + mApi = findViewById(R.id.api); + mWebView = findViewById(R.id.webview); mTinyWindow.setOnClickListener(this); mListView.setOnClickListener(this); @@ -43,7 +43,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { mApi.setOnClickListener(this); mWebView.setOnClickListener(this); - myJZVideoPlayerStandard = (MyJZVideoPlayerStandard) findViewById(R.id.jz_video); + myJZVideoPlayerStandard = findViewById(R.id.jz_video); myJZVideoPlayerStandard.setUp("http://jzvd.nathen.cn/342a5f7ef6124a4a8faf00e738b8bee4/cf6d9db0bd4d41f59d09ea0a81e918fd-5287d2089db37e62345123a1be272f8b.mp4" , JZVideoPlayerStandard.SCREEN_LAYOUT_NORMAL, "饺子快长大"); Picasso.with(this) diff --git a/app/src/main/java/cn/jzvd/demo/OrientationActivity.java b/app/src/main/java/cn/jzvd/demo/OrientationActivity.java index b8b787a9a..c2f9594cb 100644 --- a/app/src/main/java/cn/jzvd/demo/OrientationActivity.java +++ b/app/src/main/java/cn/jzvd/demo/OrientationActivity.java @@ -26,7 +26,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { getSupportActionBar().setDisplayUseLogoEnabled(false); getSupportActionBar().setTitle("Orientation"); setContentView(R.layout.activity_orientation); - mJzVideoPlayerStandard = (JZVideoPlayerStandard) findViewById(R.id.jz_video); + mJzVideoPlayerStandard = findViewById(R.id.jz_video); mJzVideoPlayerStandard.setUp(VideoConstant.videoUrlList[0] , JZVideoPlayerStandard.SCREEN_LAYOUT_NORMAL, "饺子不信"); Picasso.with(this) diff --git a/app/src/main/java/cn/jzvd/demo/RecyclerViewNormalActivity.java b/app/src/main/java/cn/jzvd/demo/RecyclerViewNormalActivity.java index d31c5be54..23cb3cdf3 100644 --- a/app/src/main/java/cn/jzvd/demo/RecyclerViewNormalActivity.java +++ b/app/src/main/java/cn/jzvd/demo/RecyclerViewNormalActivity.java @@ -33,7 +33,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { getSupportActionBar().setTitle("NormalRecyclerView"); setContentView(R.layout.activity_recyclerview_content); - recyclerView = (RecyclerView) findViewById(R.id.recyclerview); + recyclerView = findViewById(R.id.recyclerview); recyclerView.setLayoutManager(new LinearLayoutManager(this)); adapterVideoList = new RecyclerViewVideoAdapter(this); diff --git a/app/src/main/java/cn/jzvd/demo/RecyclerViewVideoAdapter.java b/app/src/main/java/cn/jzvd/demo/RecyclerViewVideoAdapter.java index 2dfab5796..00a96ce95 100644 --- a/app/src/main/java/cn/jzvd/demo/RecyclerViewVideoAdapter.java +++ b/app/src/main/java/cn/jzvd/demo/RecyclerViewVideoAdapter.java @@ -54,7 +54,7 @@ class MyViewHolder extends RecyclerView.ViewHolder { public MyViewHolder(View itemView) { super(itemView); - jzVideoPlayer = (JZVideoPlayerStandard) itemView.findViewById(R.id.videoplayer); + jzVideoPlayer = itemView.findViewById(R.id.videoplayer); } } diff --git a/app/src/main/java/cn/jzvd/demo/UISmallChangeActivity.java b/app/src/main/java/cn/jzvd/demo/UISmallChangeActivity.java index 615c5825b..25badd7c3 100644 --- a/app/src/main/java/cn/jzvd/demo/UISmallChangeActivity.java +++ b/app/src/main/java/cn/jzvd/demo/UISmallChangeActivity.java @@ -35,7 +35,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { getSupportActionBar().setTitle("SmallChangeUI"); setContentView(R.layout.activity_ui_small_change); - jzVideoPlayerStandardWithShareButton = (JZVideoPlayerStandardShowShareButtonAfterFullscreen) findViewById(R.id.custom_videoplayer_standard_with_share_button); + jzVideoPlayerStandardWithShareButton = findViewById(R.id.custom_videoplayer_standard_with_share_button); jzVideoPlayerStandardWithShareButton.setUp(VideoConstant.videoUrlList[3], JZVideoPlayer.SCREEN_LAYOUT_NORMAL , "饺子想呼吸"); Picasso.with(this) @@ -43,21 +43,21 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { .into(jzVideoPlayerStandardWithShareButton.thumbImageView); - jzVideoPlayerStandardShowTitleAfterFullscreen = (JZVideoPlayerStandardShowTitleAfterFullscreen) findViewById(R.id.custom_videoplayer_standard_show_title_after_fullscreen); + jzVideoPlayerStandardShowTitleAfterFullscreen = findViewById(R.id.custom_videoplayer_standard_show_title_after_fullscreen); jzVideoPlayerStandardShowTitleAfterFullscreen.setUp(VideoConstant.videoUrlList[4], JZVideoPlayer.SCREEN_LAYOUT_NORMAL , "饺子想摇头"); Picasso.with(this) .load(VideoConstant.videoThumbList[4]) .into(jzVideoPlayerStandardShowTitleAfterFullscreen.thumbImageView); - jzVideoPlayerStandardShowTextureViewAfterAutoComplete = (JZVideoPlayerStandardShowTextureViewAfterAutoComplete) findViewById(R.id.custom_videoplayer_standard_show_textureview_aoto_complete); + jzVideoPlayerStandardShowTextureViewAfterAutoComplete = findViewById(R.id.custom_videoplayer_standard_show_textureview_aoto_complete); jzVideoPlayerStandardShowTextureViewAfterAutoComplete.setUp(VideoConstant.videoUrlList[5], JZVideoPlayer.SCREEN_LAYOUT_NORMAL , "饺子想旅行"); Picasso.with(this) .load(VideoConstant.videoThumbList[5]) .into(jzVideoPlayerStandardShowTextureViewAfterAutoComplete.thumbImageView); - jzVideoPlayerStandardAutoCompleteAfterFullscreen = (JZVideoPlayerStandardAutoCompleteAfterFullscreen) findViewById(R.id.custom_videoplayer_standard_aoto_complete); + jzVideoPlayerStandardAutoCompleteAfterFullscreen = findViewById(R.id.custom_videoplayer_standard_aoto_complete); jzVideoPlayerStandardAutoCompleteAfterFullscreen.setUp(VideoConstant.videoUrls[0][1], JZVideoPlayer.SCREEN_LAYOUT_NORMAL , "饺子没来"); Picasso.with(this) diff --git a/app/src/main/java/cn/jzvd/demo/VideoListAdapter.java b/app/src/main/java/cn/jzvd/demo/VideoListAdapter.java index 98d06a82b..2b89fdbcc 100755 --- a/app/src/main/java/cn/jzvd/demo/VideoListAdapter.java +++ b/app/src/main/java/cn/jzvd/demo/VideoListAdapter.java @@ -59,7 +59,7 @@ public View getView(int position, View convertView, ViewGroup parent) { } else { viewHolder = (ViewHolder) convertView.getTag(); } - viewHolder.jzVideoPlayer = (JZVideoPlayerStandard) convertView.findViewById(R.id.videoplayer); + viewHolder.jzVideoPlayer = convertView.findViewById(R.id.videoplayer); viewHolder.jzVideoPlayer.setUp( videoUrls[position], JZVideoPlayer.SCREEN_LAYOUT_LIST, videoTitles[position]); diff --git a/app/src/main/java/cn/jzvd/demo/WebViewActivity.java b/app/src/main/java/cn/jzvd/demo/WebViewActivity.java index 1ae95f118..37df6693d 100644 --- a/app/src/main/java/cn/jzvd/demo/WebViewActivity.java +++ b/app/src/main/java/cn/jzvd/demo/WebViewActivity.java @@ -31,7 +31,7 @@ protected void onCreate(@Nullable Bundle savedInstanceState) { getSupportActionBar().setDisplayUseLogoEnabled(false); getSupportActionBar().setTitle("WebView"); setContentView(R.layout.activity_webview); - mWebView = (WebView) findViewById(R.id.webview); + mWebView = findViewById(R.id.webview); mWebView.getSettings().setJavaScriptEnabled(true); mWebView.addJavascriptInterface(new JZCallBack(), "jzvd"); mWebView.loadUrl("file:///android_asset/jzvd.html"); From 903dd085943cd006c4e9a609e9b7de2fbb35a92e Mon Sep 17 00:00:00 2001 From: lipan <821537155@qq.com> Date: Tue, 31 Oct 2017 15:18:47 +0800 Subject: [PATCH 03/46] fix null point bug --- app/src/main/AndroidManifest.xml | 4 ++ .../main/java/cn/jzvd/demo/MainActivity.java | 2 +- .../java/cn/jzvd/demo/TinyWindowActivity.java | 39 ++++++++++++++++++ .../main/res/layout/activity_tiny_window.xml | 40 +++++++++++++++++++ .../java/cn/jzvd/JZVideoPlayerStandard.java | 2 +- 5 files changed, 85 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/cn/jzvd/demo/TinyWindowActivity.java create mode 100644 app/src/main/res/layout/activity_tiny_window.xml diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 2cc47f836..ec3bea71c 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -47,6 +47,10 @@ android:name=".ListViewMultiHolderActivity" android:configChanges="orientation|screenSize|keyboardHidden" android:screenOrientation="portrait" /> + + + + + + + + + +