Skip to content

Commit d0d3980

Browse files
committed
更新demo 支持加密视频播放
1 parent c738c28 commit d0d3980

File tree

16 files changed

+169
-101
lines changed

16 files changed

+169
-101
lines changed

.idea/misc.xml

Lines changed: 1 addition & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/modules.xml

Lines changed: 1 addition & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/src/main/java/com/tencent/liteav/demo/MainActivity.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616

1717
import com.tencent.liteav.demo.common.widget.expandableadapter.BaseExpandableRecyclerViewAdapter;
1818
import com.tencent.liteav.demo.lvb.liveplayer.LivePlayerActivity;
19-
import com.tencent.liteav.demo.lvb.liveplayer.LivePlayerSurfaceActivity;
2019
import com.tencent.liteav.demo.player.VodPlayerActivity;
2120
import com.tencent.liteav.demo.player.superplayer.SuperPlayerActivity;
2221
import com.tencent.rtmp.TXLiveBase;
@@ -159,7 +158,6 @@ private List<GroupBean> initGroupData() {
159158

160159
// 调试工具
161160
List<ChildBean> debugChildList = new ArrayList<>();
162-
debugChildList.add(new ChildBean("直播播放器 (Surface)", R.drawable.live, LivePlayerActivity.ACTIVITY_TYPE_LIVE_PLAY, LivePlayerSurfaceActivity.class));
163161
debugChildList.add(new ChildBean("点播播放器", R.drawable.play, LivePlayerActivity.ACTIVITY_TYPE_VOD_PLAY, VodPlayerActivity.class));
164162

165163
if (debugChildList.size() != 0) {

libsuperplayer/src/main/java/com/tencent/liteav/demo/play/SuperPlayerView.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,13 @@ private void playVodURL(String url) {
398398
mVodPlayer.setStartTime(0);
399399
mVodPlayer.setAutoPlay(true);
400400
mVodPlayer.setVodListener(this);
401+
if(mCurrentProtocol!=null && mCurrentProtocol.getToken()!=null){
402+
TXCLog.d(TAG,"TOKEN: "+mCurrentProtocol.getToken());
403+
mVodPlayer.setToken(mCurrentProtocol.getToken());
404+
}
405+
else {
406+
mVodPlayer.setToken(null);
407+
}
401408
int ret = mVodPlayer.startPlay(url);
402409
if (ret == 0) {
403410
mCurrentPlayState = SuperPlayerConst.PLAYSTATE_PLAYING;
@@ -1036,7 +1043,8 @@ public void onPlayEvent(TXVodPlayer player, int event, Bundle param) {
10361043
Collections.sort(bitrateItems); //masterPlaylist多清晰度,按照码率排序,从低到高
10371044
List<TCVideoQuality> videoQualities = new ArrayList<>();
10381045
int size = bitrateItems.size();
1039-
List<TCResolutionName> resolutionNames = mCurrentProtocol.getResolutionNameList();
1046+
1047+
List<TCResolutionName> resolutionNames = (mCurrentProtocol!=null) ? mCurrentProtocol.getResolutionNameList() : null;
10401048
for (int i = 0; i < size; i++) {
10411049
TXBitrateItem bitrateItem = bitrateItems.get(i);
10421050
TCVideoQuality quality;

libsuperplayer/src/main/java/com/tencent/liteav/demo/play/bean/TCAdaptiveStreamingInfo.java renamed to libsuperplayer/src/main/java/com/tencent/liteav/demo/play/bean/TCEncryptedStreamingInfo.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,14 @@
66
* 自适应码流信息
77
*/
88

9-
public class TCAdaptiveStreamingInfo {
10-
public int definition;
11-
public String videoPackage;
9+
public class TCEncryptedStreamingInfo {
1210
public String drmType;
1311
public String url;
1412

1513

1614
@Override
1715
public String toString() {
18-
return "TCAdaptiveStreamingInfo{" +
19-
"definition=" + definition +
20-
", videoPackage='" + videoPackage + '\'' +
16+
return "TCEncryptedStreamingInfo{" +
2117
", drmType='" + drmType + '\'' +
2218
", url='" + url + '\'' +
2319
'}';

libsuperplayer/src/main/java/com/tencent/liteav/demo/play/bean/TCResolutionName.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,17 @@
44
* 自适应码流视频画质别名
55
*/
66
public class TCResolutionName {
7-
public int minEdgeLength; // 最小边长px
87
public String name; // 画质名称
8+
public int width; //
9+
public int height;
10+
public String type; //类型 可能的取值有 video 和 audio
911

1012
@Override
1113
public String toString() {
1214
return "TCResolutionName{" +
13-
"minEdgeLength='" + minEdgeLength + '\'' +
15+
"width='" + width + '\'' +
16+
"height='" + height + '\'' +
17+
"type='" + type + '\'' +
1418
", name=" + name +
1519
'}';
1620
}

libsuperplayer/src/main/java/com/tencent/liteav/demo/play/protocol/IPlayInfoParser.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,26 @@
1212
*/
1313
public interface IPlayInfoParser {
1414
/**
15-
* 获取视频播放url
15+
* 获取未加密视频播放url,若没有获取sampleaes url
1616
*
1717
* @return url字符串
1818
*/
1919
String getUrl();
2020

21+
/**
22+
* 获取加密视频播放url
23+
*
24+
* @return url字符串
25+
*/
26+
String getEncyptedUrl(PlayInfoConstant.EncyptedUrlType type);
27+
28+
/**
29+
* 获取加密token
30+
*
31+
* @return token字符串
32+
*/
33+
String getToken();
34+
2135
/**
2236
* 获取视频名称
2337
*

libsuperplayer/src/main/java/com/tencent/liteav/demo/play/protocol/IPlayInfoProtocol.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,20 @@ public interface IPlayInfoProtocol {
3030
*/
3131
String getUrl();
3232

33+
/**
34+
* 获取加密视频播放url
35+
*
36+
* @return url字符串
37+
*/
38+
String getEncyptedUrl(PlayInfoConstant.EncyptedUrlType type);
39+
40+
/**
41+
* 获取加密token
42+
*
43+
* @return token字符串
44+
*/
45+
String getToken();
46+
3347
/**
3448
* 获取视频名称
3549
*
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.tencent.liteav.demo.play.protocol;
2+
3+
public class PlayInfoConstant {
4+
5+
public enum EncyptedUrlType {
6+
7+
SIMPLEAES("SimpleAES"),
8+
WIDEVINE("widevine");
9+
10+
EncyptedUrlType(String type){
11+
value = type;
12+
}
13+
14+
private String value;
15+
16+
public String getValue(){
17+
return value;
18+
}
19+
}
20+
}

libsuperplayer/src/main/java/com/tencent/liteav/demo/play/protocol/TCPlayInfoParserV2.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -375,6 +375,16 @@ public String getUrl() {
375375
return mUrl;
376376
}
377377

378+
@Override
379+
public String getEncyptedUrl(PlayInfoConstant.EncyptedUrlType type) {
380+
return null;
381+
}
382+
383+
@Override
384+
public String getToken() {
385+
return null;
386+
}
387+
378388
/**
379389
* 获取视频名称
380390
*

0 commit comments

Comments
 (0)