Skip to content

Commit

Permalink
完善m3u8中ts分片合并的功能
Browse files Browse the repository at this point in the history
Signed-off-by: JeffMony <[email protected]>
  • Loading branch information
JeffMony committed Sep 30, 2020
1 parent f03c664 commit 7088852
Show file tree
Hide file tree
Showing 32 changed files with 218 additions and 415 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ VideoDownloadConfig config = new VideoDownloadManager.Build(this)
.setTimeOut(DownloadConstants.READ_TIMEOUT, DownloadConstants.CONN_TIMEOUT)
.setConcurrentCount(DownloadConstants.CONCURRENT)
.setIgnoreCertErrors(true)
.setShouldM3U8Merged(true)
.buildConfig();
VideoDownloadManager.getInstance().initConfig(config);
```
Expand Down
14 changes: 0 additions & 14 deletions app/src/main/java/com/jeffmony/videodemo/MainActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,6 @@

import com.jeffmony.videodemo.download.DownloadSettingsActivity;
import com.jeffmony.videodemo.download.VideoDownloadListActivity;
import com.jeffmony.videodemo.merge.MergeDownloadFileActivity;
import com.jeffmony.videodemo.transcode.VideoTranscodeActivity;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -27,8 +25,6 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe

private Button mDownloadSettingBtn;
private Button mDownloadListBtn;
private Button mMergeM3U8FileBtn;
private Button mVideoTranscodeBtn;

@Override
protected void onCreate(Bundle savedInstanceState) {
Expand All @@ -41,13 +37,9 @@ protected void onCreate(Bundle savedInstanceState) {
private void initViews() {
mDownloadSettingBtn = (Button) findViewById(R.id.download_settings_btn);
mDownloadListBtn = (Button) findViewById(R.id.download_list_btn);
mMergeM3U8FileBtn = (Button) findViewById(R.id.merge_download_file_btn);
mVideoTranscodeBtn = (Button) findViewById(R.id.video_transcode_btn);

mDownloadSettingBtn.setOnClickListener(this);
mDownloadListBtn.setOnClickListener(this);
mMergeM3U8FileBtn.setOnClickListener(this);
mVideoTranscodeBtn.setOnClickListener(this);
}

private void requestPermissions() {
Expand Down Expand Up @@ -95,12 +87,6 @@ public void onClick(View v) {
} else if (v == mDownloadListBtn) {
Intent intent = new Intent(this, VideoDownloadListActivity.class);
startActivity(intent);
} else if (v == mMergeM3U8FileBtn) {
Intent intent = new Intent(this, MergeDownloadFileActivity.class);
startActivity(intent);
} else if (v == mVideoTranscodeBtn) {
Intent intent = new Intent(this, VideoTranscodeActivity.class);
startActivity(intent);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,12 @@ public class DownloadSettingsActivity extends AppCompatActivity implements View.
private RadioButton mBtn5;
private RadioButton mBtn11;
private RadioButton mBtn12;
private RadioButton mBtn13;
private RadioButton mBtn14;

private int mConcurrentNum = 3;
private boolean mIgnoreCertErrors = true;
private boolean mShouldM3U8Merged = false;

private Handler mHandler = new Handler() {
@Override
Expand All @@ -59,17 +62,19 @@ protected void onCreate(@Nullable Bundle savedInstanceState) {
}

private void initViews() {
mStoreLocText = (TextView) findViewById(R.id.store_loc_txt);
mStoreSizeText = (TextView) findViewById(R.id.store_size);
mOpenFileText = (TextView) findViewById(R.id.open_file_txt);
mClearDownloadText = (TextView) findViewById(R.id.clear_download_cache);
mBtn1 = (RadioButton) findViewById(R.id.btn1);
mBtn2 = (RadioButton) findViewById(R.id.btn2);
mBtn3 = (RadioButton) findViewById(R.id.btn3);
mBtn4 = (RadioButton) findViewById(R.id.btn4);
mBtn5 = (RadioButton) findViewById(R.id.btn5);
mBtn11 = (RadioButton) findViewById(R.id.btn11);
mBtn12 = (RadioButton) findViewById(R.id.btn12);
mStoreLocText = findViewById(R.id.store_loc_txt);
mStoreSizeText = findViewById(R.id.store_size);
mOpenFileText = findViewById(R.id.open_file_txt);
mClearDownloadText = findViewById(R.id.clear_download_cache);
mBtn1 = findViewById(R.id.btn1);
mBtn2 = findViewById(R.id.btn2);
mBtn3 = findViewById(R.id.btn3);
mBtn4 = findViewById(R.id.btn4);
mBtn5 = findViewById(R.id.btn5);
mBtn11 = findViewById(R.id.btn11);
mBtn12 = findViewById(R.id.btn12);
mBtn13 = findViewById(R.id.btn13);
mBtn14 = findViewById(R.id.btn14);

mStoreLocText.setText(VideoDownloadManager.getInstance().getDownloadPath());
mOpenFileText.setOnClickListener(this);
Expand All @@ -81,6 +86,8 @@ private void initViews() {
mBtn5.setOnClickListener(this);
mBtn11.setOnClickListener(this);
mBtn12.setOnClickListener(this);
mBtn13.setOnClickListener(this);
mBtn14.setOnClickListener(this);
}

@Override
Expand Down Expand Up @@ -113,12 +120,21 @@ public void onClick(View v) {
} else if (v == mBtn11) {
mBtn11.setChecked(true);
mBtn12.setChecked(false);
mIgnoreCertErrors = true;
mShouldM3U8Merged = true;
} else if (v == mBtn12) {
mBtn11.setChecked(false);
mBtn12.setChecked(true);
mShouldM3U8Merged = false;
} else if (v == mBtn13) {
mBtn13.setChecked(true);
mBtn14.setChecked(false);
mIgnoreCertErrors = true;
} else if (v == mBtn14) {
mBtn13.setChecked(false);
mBtn14.setChecked(true);
mIgnoreCertErrors = false;
}
VideoDownloadManager.getInstance().setShouldM3U8Merged(mShouldM3U8Merged);
VideoDownloadManager.getInstance().setConcurrentCount(mConcurrentNum);
VideoDownloadManager.getInstance().setIgnoreAllCertErrors(mIgnoreCertErrors);
}
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

42 changes: 39 additions & 3 deletions app/src/main/res/layout/activity_download_settings.xml
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@
android:padding="5dp"
android:background="@color/colorPrimaryDark"
android:textColor="@color/white"
android:text="是否忽略证书"
android:text="下载完成是否合并ts分片"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:layout_width="wrap_content"
Expand All @@ -159,14 +159,14 @@
<RadioButton
android:id="@+id/btn11"
android:textColor="@color/black"
android:checked="true"
android:text=""
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

<RadioButton
android:id="@+id/btn12"
android:textColor="@color/black"
android:checked="true"
android:text=""
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
Expand All @@ -183,7 +183,7 @@
android:padding="5dp"
android:background="@color/colorPrimaryDark"
android:textColor="@color/white"
android:text="移动网络下是否暂停下载"
android:text="是否忽略证书"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:layout_width="wrap_content"
Expand All @@ -207,6 +207,42 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RadioGroup>

<TextView
android:layout_marginTop="10dp"
android:background="@color/black"
android:layout_width="match_parent"
android:layout_height="2px" />

<TextView
android:textSize="18sp"
android:padding="5dp"
android:background="@color/colorPrimaryDark"
android:textColor="@color/white"
android:text="移动网络下是否暂停下载"
android:layout_marginTop="10dp"
android:layout_marginLeft="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<RadioGroup
android:layout_marginLeft="10dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<RadioButton
android:id="@+id/btn15"
android:textColor="@color/black"
android:checked="true"
android:text=""
android:layout_width="wrap_content"
android:layout_height="wrap_content" />

<RadioButton
android:id="@+id/btn16"
android:textColor="@color/black"
android:text=""
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RadioGroup>
</LinearLayout>

</ScrollView>
20 changes: 0 additions & 20 deletions app/src/main/res/layout/activity_main.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,26 +39,6 @@
android:layout_width="180dp"
android:layout_marginTop="20dp"
android:layout_height="wrap_content" />

<Button
android:background="@color/colorPrimaryDark"
android:id="@+id/merge_download_file_btn"
android:text="合并M3U8文件"
android:textSize="18sp"
android:textColor="@color/white"
android:layout_width="180dp"
android:layout_marginTop="20dp"
android:layout_height="wrap_content" />

<Button
android:background="@color/colorPrimaryDark"
android:id="@+id/video_transcode_btn"
android:text="TS转换为MP4"
android:textSize="18sp"
android:textColor="@color/white"
android:layout_width="180dp"
android:layout_marginTop="20dp"
android:layout_height="wrap_content" />
</LinearLayout>

</RelativeLayout>
Loading

0 comments on commit 7088852

Please sign in to comment.