Skip to content
This repository has been archived by the owner on Dec 28, 2021. It is now read-only.

Commit

Permalink
改进下载B站视频逻辑
Browse files Browse the repository at this point in the history
  • Loading branch information
grandiloquent committed Oct 30, 2021
1 parent 57fc229 commit 040f4bb
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 26 deletions.
2 changes: 1 addition & 1 deletion app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ android {
minSdkVersion 24
targetSdkVersion 30
versionCode 1
versionName "1.1.1"
versionName "1.1.2"
externalNativeBuild {
cmake {
arguments '-DANDROID_STL=c++_shared'
Expand Down
10 changes: 0 additions & 10 deletions app/src/main/java/euphoria/psycho/PlayerActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
import android.opengl.GLES20;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.Surface;
import android.view.TextureView;
import android.view.TextureView.SurfaceTextureListener;
Expand Down Expand Up @@ -273,17 +272,13 @@ private void onBufferingUpdate(MediaPlayer mediaPlayer, int i) {
}

private void onCompletion(MediaPlayer mediaPlayer) {
Log.e("B5aOx2", "onCompletion");

}

private boolean onError(MediaPlayer mediaPlayer, int i, int i1) {
Log.e("B5aOx2", "onError " + i);
return true;
}

private boolean onInfo(MediaPlayer mediaPlayer, int i, int i1) {
Log.e("B5aOx2", "onInfo");
return true;
}

Expand Down Expand Up @@ -314,7 +309,6 @@ private void onPlayPause(View view) {
}

private void onPrepared(MediaPlayer mediaPlayer) {
Log.e("B5aOx2", "onPrepared");
mDuration.setText(DateTimeShare.getStringForTime(mStringBuilder, mFormatter, mediaPlayer.getDuration()));
mTimeBar.setDuration(mediaPlayer.getDuration());
mMediaPlayer.start();
Expand Down Expand Up @@ -345,12 +339,9 @@ private void onRoot(View view) {
}

private void onSeekComplete(MediaPlayer mediaPlayer) {
Log.e("B5aOx2", "onSeekComplete");
}

private void onTimedMetaDataAvailable(MediaPlayer mediaPlayer, TimedMetaData timedMetaData) {
Log.e("B5aOx2", "onTimedMetaDataAvailable");

}

private void onVideoSizeChanged(MediaPlayer mediaPlayer, int videoWidth, int videoHeight) {
Expand All @@ -372,7 +363,6 @@ private void play() throws IOException {
mMediaPlayer.setDataSource(this, Uri.parse(mPlayList.get(mPlayIndex)), headers);
mMediaPlayer.prepareAsync();
} else {
Log.e("B5aOx2", String.format("play, %s", mPlayList.get(mPlayIndex)));
mMediaPlayer.setDataSource(mPlayList.get(mPlayIndex));
mMediaPlayer.prepareAsync();
}
Expand Down
28 changes: 16 additions & 12 deletions app/src/main/java/euphoria/psycho/explorer/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class MainActivity extends Activity implements ClientInterface {
private WebView mWebView;
private BookmarkDatabase mBookmarkDatabase;
private String mVideoUrl;
private String[] mVideoList;

public BookmarkDatabase getBookmarkDatabase() {
return mBookmarkDatabase;
Expand Down Expand Up @@ -79,7 +80,6 @@ private void initialize() {
checkUnfinishedVideoTasks(this);
checkUpdate();
// tryPlayVideo(this);

}

@Override
Expand Down Expand Up @@ -108,6 +108,15 @@ public Context getContext() {
return this;
}

@Override
public String[] getVideoList() {
return mVideoList;
}

public void setVideoList(String[] videoList) {
mVideoList = videoList;
}

@Override
public void onBackPressed() {
// When the user press the back button,
Expand All @@ -134,17 +143,6 @@ public void onRequestPermissionsResult(int requestCode, String[] permissions, in
initialize();
}

@Override
public String[] getVideoList() {
return mVideoList;
}

private String[] mVideoList;

public void setVideoList(String[] videoList) {
mVideoList = videoList;
}

@Override
public void onVideoUrl(String uri) {
mVideoUrl = uri;
Expand All @@ -167,6 +165,12 @@ public boolean shouldOverrideUrlLoading(String uri) {
if (XiGua.handle(uri, this)) {
return true;
}
// if (mWebView.getUrl().contains("xvideos.com")) {
// Pattern pattern = Pattern.compile("xvideos\\.com/video\\d+");
// if (pattern.matcher(uri).find()) {
// XVideos.fetchVideos(uri);
// }
// }
return Ck52.handle(uri, this);
}

Expand Down
6 changes: 3 additions & 3 deletions app/src/main/res/values-zh-rCN/strings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
<string name="start_downloading_the_b_station_video">开始下载B站视频</string>
<string name="video_downloaded_successfully">已成功下载视频</string>
<string name="start_merging_videos">开始合并视频</string>
<string name="videos_successfully_merged">已成功合并视频</string>
<string name="ready_to_download_station_b_video">准备下载B站视频</string>
<string name="download_failed">下载失败</string>
<string name="videos_successfully_merged">已成功合并视频</string>
<string name="ready_to_download_station_b_video">准备下载B站视频</string>
<string name="download_failed">下载失败</string>
</resources>

0 comments on commit 040f4bb

Please sign in to comment.