Toggle navigation
Toggle navigation
此项目
正在载入...
Sign in
huangxinbao
/
Android_Sdk
转到一个项目
Toggle navigation
项目
群组
代码片段
帮助
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
huangxinbao
2017-05-02 22:01:20 +0800
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
7eab6325e1a760a8fa6b9ce4066aafe35afe2220
7eab6325
1 parent
48340839
Modify push video will play their own problems
显示空白字符变更
内嵌
并排对比
正在显示
16 个修改的文件
包含
239 行增加
和
502 行删除
MyApplication/.idea/copyright/profiles_settings.xml
MyApplication/.idea/misc.xml
MyApplication/XdyDemo/build.gradle
MyApplication/XdyDemo/src/main/java/com/mang/xdy/demo/MainActivity.java
MyApplication/XdyDemo/src/main/java/com/mang/xdy/demo/activity/VideoPlayActivity.java
MyApplication/XdyDemo/src/main/res/layout/activity_main.xml
MyApplication/XdyDemo/src/main/res/layout/activity_video_play.xml
MyApplication/XdyDemo/src/main/res/layout/home_media_controller.xml
MyApplication/xdy/src/main/java/com/mang/xdy/api/XdyInterface.java
MyApplication/xdy/src/main/java/com/mang/xdy/cache/ACache.java
MyApplication/xdy/src/main/java/com/mang/xdy/common/Constants.java
MyApplication/xdy/src/main/java/com/mang/xdy/core/XdyPlayerCore.java
MyApplication/xdy/src/main/java/com/mang/xdy/core/XdySdk.java
MyApplication/xdy/src/main/java/com/mang/xdy/ss.java
MyApplication/xdy/src/main/java/com/mang/xdy/utils/JsonUtil.java
MyApplication/xdy/src/main/java/com/mang/xdy/utils/XdyStringUtils.java
MyApplication/.idea/copyright/profiles_settings.xml
查看文件 @
7eab632
MyApplication/.idea/misc.xml
查看文件 @
7eab632
<?xml version="1.0" encoding="UTF-8"?>
<project
version=
"4"
>
<component
name=
"EntryPointsManager"
>
<entry_points
version=
"2.0"
/>
</component>
<component
name=
"NullableNotNullManager"
>
<option
name=
"myDefaultNullable"
value=
"android.support.annotation.Nullable"
/>
<option
name=
"myDefaultNotNull"
value=
"android.support.annotation.NonNull"
/>
<option
name=
"myNullables"
>
<value>
<list
size=
"4"
>
<item
index=
"0"
class=
"java.lang.String"
itemvalue=
"org.jetbrains.annotations.Nullable"
/>
<item
index=
"1"
class=
"java.lang.String"
itemvalue=
"javax.annotation.Nullable"
/>
<item
index=
"2"
class=
"java.lang.String"
itemvalue=
"edu.umd.cs.findbugs.annotations.Nullable"
/>
<item
index=
"3"
class=
"java.lang.String"
itemvalue=
"android.support.annotation.Nullable"
/>
</list>
</value>
</option>
<option
name=
"myNotNulls"
>
<value>
<list
size=
"4"
>
<item
index=
"0"
class=
"java.lang.String"
itemvalue=
"org.jetbrains.annotations.NotNull"
/>
<item
index=
"1"
class=
"java.lang.String"
itemvalue=
"javax.annotation.Nonnull"
/>
<item
index=
"2"
class=
"java.lang.String"
itemvalue=
"edu.umd.cs.findbugs.annotations.NonNull"
/>
<item
index=
"3"
class=
"java.lang.String"
itemvalue=
"android.support.annotation.NonNull"
/>
</list>
</value>
</option>
</component>
<component
name=
"ProjectLevelVcsManager"
settingsEditedManually=
"false"
>
<OptionsSetting
value=
"true"
id=
"Add"
/>
<OptionsSetting
value=
"true"
id=
"Remove"
/>
...
...
MyApplication/XdyDemo/build.gradle
查看文件 @
7eab632
...
...
@@ -10,7 +10,6 @@ android {
targetSdkVersion
22
versionCode
1
versionName
"1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
...
...
MyApplication/XdyDemo/src/main/java/com/mang/xdy/demo/MainActivity.java
查看文件 @
7eab632
...
...
@@ -11,10 +11,8 @@ import android.widget.EditText;
import
com.google.gson.Gson
;
import
com.mang.xdy.demo.activity.VideoPlayActivity
;
import
com.mang.xdy.demo.bean.JoinClass
;
import
com.mang.xdy.demo.bean.JoinClassBean
;
import
com.mang.xdy.demo.utils.ToastUtil
;
import
com.mang.xdy.utils.XdyLogUtil
;
import
java.util.ArrayList
;
...
...
@@ -36,8 +34,6 @@ public class MainActivity extends AppCompatActivity {
Button
btnHomeEnterClass
;
@BindView
(
R
.
id
.
btn_home_enter_publisher
)
Button
btn_home_enter_publisher
;
@BindView
(
R
.
id
.
btn_home_enter_publisherAudio
)
Button
btn_home_enter_publisherAudio
;
/*一进来就要初始化,让后再调 加入课堂*/
@Override
protected
void
onCreate
(
Bundle
savedInstanceState
)
{
...
...
@@ -46,7 +42,7 @@ public class MainActivity extends AppCompatActivity {
ButterKnife
.
bind
(
this
);
}
@OnClick
({
R
.
id
.
btn_home_enter_class
,
R
.
id
.
btn_home_enter_publisher
,
R
.
id
.
btn_home_enter_publisherAudio
})
@OnClick
({
R
.
id
.
btn_home_enter_class
,
R
.
id
.
btn_home_enter_publisher
})
public
void
onViewClicked
(
View
view
)
{
if
(
TextUtils
.
isEmpty
(
joinClass
())){
return
;
...
...
@@ -70,11 +66,6 @@ public class MainActivity extends AppCompatActivity {
intents
.
putStringArrayListExtra
(
"init"
,
arrayList
);
startActivity
(
intents
);
break
;
case
R
.
id
.
btn_home_enter_publisherAudio
:
// Intent intent_audio=new Intent(MainActivity.this, AudioPublisherActivity.class);
// intent_audio.putExtra("init",joinClass());
// startActivity(intent_audio);
break
;
}
}
private
String
classId
=
""
;
...
...
MyApplication/XdyDemo/src/main/java/com/mang/xdy/demo/activity/VideoPlayActivity.java
查看文件 @
7eab632
package
com
.
mang
.
xdy
.
demo
.
activity
;
;
import
android.Manifest
;
import
android.annotation.SuppressLint
;
import
android.app.ProgressDialog
;
import
android.app.Service
;
import
android.content.Context
;
import
android.content.DialogInterface
;
import
android.graphics.PixelFormat
;
import
android.hardware.display.VirtualDisplay
;
import
android.media.projection.MediaProjection
;
import
android.media.projection.MediaProjectionManager
;
import
android.content.pm.PackageManager
;
import
android.os.Bundle
;
import
android.os.Handler
;
import
android.os.Message
;
import
android.support.design.widget.TabLayout
;
import
android.support.v4.app.ActivityCompat
;
import
android.support.v4.content.PermissionChecker
;
import
android.support.v7.app.AlertDialog
;
import
android.support.v7.app.AppCompatActivity
;
import
android.text.TextUtils
;
import
android.util.DisplayMetrics
;
import
android.util.Log
;
import
android.view.Gravity
;
import
android.view.SurfaceHolder
;
import
android.view.SurfaceView
;
import
android.view.View
;
import
android.view.ViewGroup
;
import
android.view.WindowManager
;
import
android.widget.Button
;
import
android.widget.FrameLayout
;
import
android.widget.ImageButton
;
import
android.widget.ImageView
;
import
android.widget.RelativeLayout
;
import
android.widget.SeekBar
;
import
android.widget.TextView
;
import
android.widget.Toast
;
import
com.google.gson.Gson
;
import
com.mang.xdy.bean.VideoPlayBean
;
...
...
@@ -58,9 +53,6 @@ import com.pili.pldroid.player.AVOptions;
import
com.pili.pldroid.player.PLMediaPlayer
;
import
com.pili.pldroid.player.widget.PLVideoTextureView
;
import
com.pili.pldroid.player.widget.PLVideoView
;
import
com.videoengine.NTRenderer
;
import
org.greenrobot.eventbus.EventBus
;
import
org.json.JSONException
;
import
org.json.JSONObject
;
...
...
@@ -77,8 +69,8 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList
private
final
static
String
TAG
=
"VideoPlayActivity"
;
@BindView
(
R
.
id
.
img_playVideo_novideo
)
ImageView
img_playVideo_novideo
;
@BindView
(
R
.
id
.
btn_videoPlay_exit
)
Button
btn_videoPlay_exit
;
@BindView
(
R
.
id
.
img_videoPlay_start
)
ImageView
img_videoPlay_start
;
private
String
username
=
""
;
private
String
userpwd
=
""
;
private
SimpleFragmentPagerAdapter
pagerAdapter
;
...
...
@@ -87,15 +79,10 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList
private
TabLayout
tabLayout
;
@BindView
(
R
.
id
.
surfaceview_playVideo
)
SurfaceView
surfaceviewPlayVideo
;
@BindView
(
R
.
id
.
fra_videoPlay_publish
)
FrameLayout
frameLayout_publish
;
@BindView
(
R
.
id
.
btn_videoPlay_stopPublish
)
Button
btn_videoPlay_stopPublish
;
/*推流*/
// @BindView(R.id.surfaceview_playVideo_text)
SurfaceView
mSurfaceView
;
@BindView
(
R
.
id
.
img_videoPlay_stopPublish
)
ImageView
btn_videoPlay_stopPublish
;
@BindView
(
R
.
id
.
sur_plaVideo_publish
)
SurfaceView
surfaceView_publish
;
private
String
initClass
=
""
;
private
XdySdk
xdySdk
;
private
LoginDialog
mLoginDialog
;
...
...
@@ -108,17 +95,22 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList
/*mcu断开或者网络原因为false*/
private
boolean
isDefaultExit
=
true
;
private
AlertDialog
mErrorDialog
;
private
ACache
aCache
;
//
TODO 默认回放
//
是否是回放状态,
private
boolean
replay
=
false
;
SurfaceHolder
sh
;
@BindView
(
R
.
id
.
img_videoPlay_back
)
ImageView
mImageView_Back
;
@BindView
(
R
.
id
.
tv_videoPlay_className
)
TextView
mTextView_ClassName
;
/*课堂名字*/
private
String
className
;
private
Handler
mmHandler
=
new
Handler
()
{
@Override
public
void
handleMessage
(
Message
msg
)
{
super
.
handleMessage
(
msg
);
ResponseEntity
responseEntity
=
(
ResponseEntity
)
msg
.
obj
;
switch
(
responseEntity
.
getType
())
{
case
Constants
.
CLASS_EXIT
:
ToastUtil
.
showToast
(
"退出课堂"
,
VideoPlayActivity
.
this
);
progressDialogDismiss
();
...
...
@@ -139,16 +131,22 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList
ToastUtil
.
showToastshort
(
"加入课堂成功"
,
VideoPlayActivity
.
this
);
String
userJson
=
responseEntity
.
getParam
();
SPUtil
.
putString
(
VideoPlayActivity
.
this
,
Constants
.
CLASS_JOIN_SUCCESS
,
userJson
);
// JSONObject jsonObject = null;
// try {
// jsonObject = new JSONObject(userJson);
// replay = jsonObject.optBoolean("isRecordPlayBack");
// } catch (JSONException e) {
// e.printStackTrace();
// }
JSONObject
jsonObject
=
null
;
try
{
jsonObject
=
new
JSONObject
(
userJson
);
seek
=
jsonObject
.
optLong
(
"recordPlaybackMaxTime"
);
className
=
jsonObject
.
optString
(
"className"
);
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
if
(!
TextUtils
.
isEmpty
(
className
)){
mTextView_ClassName
.
setText
(
className
);
}
if
(
replay
)
{
initRecordSeek
(
userJson
);
}
break
;
case
Constants
.
VIDEO_PLAY
:
//播放视频
...
...
@@ -192,7 +190,6 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList
setContentView
(
R
.
layout
.
activity_video_play
);
ButterKnife
.
bind
(
this
);
aCache
=
ACache
.
get
(
this
);
// XdySdk.init(this);
xdySdk
=
XdySdk
.
getXdyInstance
();
xdySdk
.
add
(
this
);
init
();
...
...
@@ -215,76 +212,50 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList
if
(!
replay
){
mVideoView
.
setVisibility
(
View
.
GONE
);
mMediaContainer
.
setVisibility
(
View
.
GONE
);
// btn_videoPlay_exit.setVisibility(View.VISIBLE);
img_videoPlay_start
.
setVisibility
(
View
.
VISIBLE
);
// btn_videoPlay_stopPublish.setVisibility(View.VISIBLE);
}
else
{
surfaceviewPlayVideo
.
setVisibility
(
View
.
GONE
);
initReplay
();
}
// initClass = getIntent().getStringExtra("init");
if
(!
replay
){
xdySdk
.
api
(
"init"
,
initClass
);
}
else
{
xdySdk
.
api
(
"initRecordPlayback"
,
initClass
);
// xdySdk.api("startRecordPlayback", "");
}
currentTime
=
0
;
btn_videoPlay_stopPublish
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
xdySdk
.
api
(
"stopPublishVideo"
,
""
);
img_videoPlay_start
.
setEnabled
(
true
);
btn_videoPlay_stopPublish
.
setEnabled
(
false
);
btn_videoPlay_stopPublish
.
setVisibility
(
View
.
GONE
);
img_videoPlay_start
.
setVisibility
(
View
.
VISIBLE
);
surfaceView_publish
.
setVisibility
(
View
.
GONE
);
}
});
btn_videoPlay_exit
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
img_videoPlay_start
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
if
(
mSurfaceView
==
null
)
{
mSurfaceView
=
NTRenderer
.
CreateRenderer
(
VideoPlayActivity
.
this
,
false
);
}
btn_videoPlay_stopPublish
.
setVisibility
(
View
.
VISIBLE
);
btn_videoPlay_exit
.
setVisibility
(
View
.
GONE
);
btn_videoPlay_exit
.
setEnabled
(
false
);
// mSurfaceView=new SurfaceView(VideoPlayActivity.this);
SurfaceHolder
sh
=
mSurfaceView
.
getHolder
();;
sh
.
setFormat
(
PixelFormat
.
TRANSPARENT
);
mSurfaceView
.
setZOrderOnTop
(
true
);
frameLayout_publish
.
addView
(
mSurfaceView
);
xdySdk
.
api
(
"publishVideo"
,
""
,
mSurfaceView
,
VideoPlayActivity
.
this
);
img_videoPlay_start
.
setVisibility
(
View
.
GONE
);
surfaceView_publish
.
setVisibility
(
View
.
VISIBLE
);
img_videoPlay_start
.
setEnabled
(
false
);
btn_videoPlay_stopPublish
.
setEnabled
(
true
);
sh
=
surfaceView_publish
.
getHolder
();
surfaceView_publish
.
setZOrderMediaOverlay
(
true
);
xdySdk
.
api
(
"publishVideo"
,
""
,
surfaceView_publish
,
VideoPlayActivity
.
this
);
isVideoMode
=
true
;
// mmHandler.post(new Runnable() {
// @Override
// public void run() {
// initSmall();
// }
// });
// xdySdk.api("leaveClass", "");
//
// xdySdk.remove(VideoPlayActivity.this);
// xdySdk.removeAll();
// UIUtils.closeDialog(mLoginDialog);
// VideoPlayActivity.super.onBackPressed();
// exit();
// String id="initRecordPlayback";
// String param="{\n" +
// " \"classId\": 391813551,\n" +
// " \"portal\": \"112.126.80.182:90\",\n" +
// " \"userRole\": \"normal\",\n" +
// " \"userName\": \"\",\n" +
// " \"userId\": 0\n" +
// "}";
// String ss=XdyStringUtils.stringToJson(param,true);
// xdySdk.api(id,ss);
// mHandler.postDelayed(new Runnable() {
// @Override
// public void run() {
// xdySdk.api("startRecordPlayback", "");
// }
// }, 200);
}
});
mImageView_Back
.
setOnClickListener
(
new
View
.
OnClickListener
()
{
@Override
public
void
onClick
(
View
v
)
{
exit_dialog
();
}
});
}
...
...
@@ -294,7 +265,6 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList
viewPager
.
setAdapter
(
pagerAdapter
);
viewPager
.
setOnRplayTouchListener
(
this
);
tabLayout
=
(
TabLayout
)
findViewById
(
R
.
id
.
sliding_tabs
);
// tabLayout.setupWithViewPager(viewPager);
tabLayout
.
setupWithViewPager
(
viewPager
,
false
);
tabLayout
.
setTabMode
(
TabLayout
.
MODE_FIXED
);
}
...
...
@@ -330,23 +300,6 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList
}
//加入课堂
public
void
joinClass
(
String
rsponse
,
boolean
isShowPwd
)
{
JoinClass
joinClass
=
new
JoinClass
();
joinClass
.
setHasCamera
(
false
);
joinClass
.
setHasMicrophone
(
false
);
joinClass
.
setUserName
(
username
);
if
(!
isShowPwd
)
{
joinClass
.
setPassword
(
"123321"
);
}
else
{
joinClass
.
setPassword
(
userpwd
);
}
String
temp
=
new
Gson
().
toJson
(
joinClass
);
String
jsonParmp
=
XdyStringUtils
.
stringToJson
(
temp
,
true
);
XdyLogUtil
.
e
(
"加入课堂"
,
jsonParmp
);
xdySdk
.
api
(
"joinClass"
,
jsonParmp
);
}
//加入课堂
public
void
joinClass
(
String
username
,
String
userpwd
,
boolean
isShowPwd
)
{
JoinClass
joinClass
=
new
JoinClass
();
joinClass
.
setHasCamera
(
false
);
...
...
@@ -369,12 +322,16 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList
* @param response
*/
public
void
playVideo
(
String
response
)
{
progressDialogDismiss
();
if
(
replay
){
playRecord
(
response
);
}
else
{
if
(!
checkPermission
()){
return
;
}
xdySdk
.
api
(
"playVideo"
,
response
+
""
,
surfaceviewPlayVideo
,
VideoPlayActivity
.
this
);
// img_playVideo_novideo.setVisibility(View.GONE);
img_playVideo_novideo
.
setImageResource
(
R
.
mipmap
.
no_video
);
...
...
@@ -387,11 +344,15 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList
* @param response
*/
public
void
playAudio
(
String
response
)
{
if
(
replay
){
playRecord
(
response
);
img_playVideo_novideo
.
setImageResource
(
R
.
mipmap
.
audio_mode
);
img_playVideo_novideo
.
setVisibility
(
View
.
VISIBLE
);
}
else
{
if
(!
checkPermission
()){
return
;
}
xdySdk
.
api
(
"playAudio"
,
response
,
null
,
VideoPlayActivity
.
this
);
img_playVideo_novideo
.
setImageResource
(
R
.
mipmap
.
audio_mode
);
img_playVideo_novideo
.
setVisibility
(
View
.
VISIBLE
);
...
...
@@ -401,6 +362,10 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList
@Override
public
void
onBackPressed
()
{
exit_dialog
();
}
public
void
exit_dialog
(){
final
AlertDialog
alertDialog
=
new
AlertDialog
.
Builder
(
this
)
.
setTitle
(
"退出"
)
.
setMessage
(
"是否离开课堂"
)
...
...
@@ -418,13 +383,10 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList
//如果收到class_exit 就执行,退出界面
UIUtils
.
closeDialog
(
mLoginDialog
);
exit
();
// progressDialogShow();
}
})
.
create
();
alertDialog
.
show
();
}
/**
...
...
@@ -488,7 +450,10 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList
}
else
{
stopAudio
();
}
xdySdk
.
api
(
"pauseRecordPlayback"
,
""
);
if
(
replay
)
{
xdySdk
.
api
(
"pauseRecordPlayback"
,
""
);
}
// xdySdk.onPublisherPause();
}
@Override
...
...
@@ -499,7 +464,10 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList
}
else
{
playAudio
(
playVideoOrAudioId
);
}
xdySdk
.
api
(
"startRecordPlayback"
,
""
);
if
(
replay
)
{
xdySdk
.
api
(
"startRecordPlayback"
,
""
);
}
// xdySdk.onPublisherResume();
}
/**
...
...
@@ -584,6 +552,38 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList
mErrorDialog
.
show
();
}
private
boolean
isCameraCheckFirst
=
true
;
private
boolean
isAudioCheckFirst
=
true
;
private
boolean
checkPermission
()
{
// try {
// int pRecordAudio = PermissionChecker.checkCallingOrSelfPermission(this, "android.permission.RECORD_AUDIO");
// int pCamera = PermissionChecker.checkCallingOrSelfPermission(this, "android.permission.CAMERA");
// if(pRecordAudio != PackageManager.PERMISSION_GRANTED) {
// Log.e(TAG,"do not have AudioRecord permission, please check");
// Toast.makeText(this,"do not have AudioRecord permission, please check", Toast.LENGTH_LONG).show();
// if(isCameraCheckFirst){
// //settingPermission();
// isCameraCheckFirst=false;
// }
// ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.CAMERA},
// 1);
// return false;
// }
// if(pCamera != PackageManager.PERMISSION_GRANTED) {
// Log.e(TAG,"do not have CAMERA permission, please check");
// Toast.makeText(this,"do not have CAMERA permission, please check", Toast.LENGTH_LONG).show();
// if(isAudioCheckFirst){
// //settingPermission();
// isAudioCheckFirst=false;
// }
// return false;
//
// }
// } catch (Exception e) {
// e.printStackTrace();
// }
return
true
;
}
@Override
public
void
observerUpData
(
String
type
,
String
parameter
)
{
XdyLogUtil
.
e
(
TAG
+
"observer:"
,
Thread
.
currentThread
().
getId
()
+
"type:"
+
type
);
...
...
@@ -594,97 +594,19 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList
}
/******************************悬浮********************************/
/**
* 窗口管理者
*/
private
WindowManager
mWindowManager
;
// desk capture
private
int
mScreenDensity
;
private
int
sreenWindowWidth
;
private
int
screenWindowHeight
;
private
VirtualDisplay
mVirtualDisplay
;
private
MediaProjectionManager
mMediaProjectionManager
;
private
MediaProjection
mMediaProjection
;
private
SurfaceView
bgSurfaceView
;
@SuppressWarnings
(
"deprecation"
)
@SuppressLint
(
"NewApi"
)
private
void
createScreenEnvironment
()
{
sreenWindowWidth
=
mWindowManager
.
getDefaultDisplay
().
getWidth
();
screenWindowHeight
=
mWindowManager
.
getDefaultDisplay
().
getHeight
();
// if (sreenWindowWidth > 800) {
// if (screenResolution == SCREEN_RESOLUTION_STANDARD) {
// sreenWindowWidth = align(sreenWindowWidth / 2, 16);
// screenWindowHeight = align(screenWindowHeight / 2, 16);
// } else {
// sreenWindowWidth = align(sreenWindowWidth * 2 / 5, 16);
// screenWindowHeight = align(screenWindowHeight * 2 / 5, 16);
// }
// }
Log
.
i
(
TAG
,
"mWindowWidth : "
+
sreenWindowWidth
+
",mWindowHeight : "
+
screenWindowHeight
);
DisplayMetrics
displayMetrics
=
new
DisplayMetrics
();
mWindowManager
.
getDefaultDisplay
().
getMetrics
(
displayMetrics
);
mScreenDensity
=
displayMetrics
.
densityDpi
;
// densityDpi mImageReader = ImageReader.newInstance(sreenWindowWidth,
// screenWindowHeight, 0x1, 2);
mMediaProjectionManager
=
(
MediaProjectionManager
)
getSystemService
(
Context
.
MEDIA_PROJECTION_SERVICE
);
}
public
void
initSmall
(){
mWindowManager
=
(
WindowManager
)
getSystemService
(
Service
.
WINDOW_SERVICE
);
// if (pushType == PUSH_TYPE_CAMERA) {
// intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK
// | Intent.FLAG_ACTIVITY_SINGLE_TOP);
// PendingIntent contentIntent = PendingIntent.getActivity(this,
// 0, intent, 0);
//
// Intent bIntent = new Intent(this, BackgroudService.class);
// PendingIntent deleteIntent = PendingIntentnt.getService(this, 0,
// bIntent, 0);
//
//// notification = new Notification.Builder(this)
//// .setContentTitle("后台采集中。。").setAutoCancel(true)
//// .setDeleteIntent(deleteIntent)
//// .setContentIntent(contentIntent).build();
//
//// startForeground(android.os.Process.myPid(), notification);
bgSurfaceView
=
new
SurfaceView
(
this
);
bgSurfaceView
.
setZOrderMediaOverlay
(
true
);
WindowManager
.
LayoutParams
layoutParams
=
new
WindowManager
.
LayoutParams
(
1
,
1
,
WindowManager
.
LayoutParams
.
TYPE_SYSTEM_OVERLAY
,
WindowManager
.
LayoutParams
.
FLAG_WATCH_OUTSIDE_TOUCH
,
PixelFormat
.
TRANSLUCENT
);
layoutParams
.
gravity
=
Gravity
.
LEFT
|
Gravity
.
BOTTOM
;
ImageView
initPic
=
new
ImageView
(
VideoPlayActivity
.
this
);
initPic
.
setLayoutParams
(
new
FrameLayout
.
LayoutParams
(
ViewGroup
.
LayoutParams
.
MATCH_PARENT
,
ViewGroup
.
LayoutParams
.
MATCH_PARENT
));
initPic
.
setScaleType
(
ImageView
.
ScaleType
.
CENTER_CROP
);
initPic
.
setImageResource
(
R
.
mipmap
.
no_video
);
mWindowManager
.
addView
(
bgSurfaceView
,
layoutParams
);
// xdySdk.api("publishVideo", "", bgSurfaceView, VideoPlayActivity.this);
// bgSurfaceView.getHolder().addCallback(this);
}
/*************************************** 回放***************************************************/
private
static
final
int
FADE_OUT
=
1
;
private
static
final
int
SHOW_PROGRESS
=
2
;
private
boolean
mShowing
;
private
boolean
mDragging
;
private
RelativeLayout
mMediaControllerRight
;
// @BindView(R.id.iv_operation_video)
// ImageView operationIcon;
// private PLMediaPlayer mMediaPlayer;
private
boolean
pause
=
true
;
/**
* 退出标记
*/
private
boolean
quit
;
private
boolean
isOver
;
@BindView
(
R
.
id
.
fl_media
)
FrameLayout
mMediaContainer
;
@BindView
(
R
.
id
.
iv_operation_play
)
...
...
@@ -788,11 +710,6 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList
@Override
public
boolean
onInfo
(
PLMediaPlayer
plMediaPlayer
,
int
i
,
int
i1
)
{
// boolean videoMode = mPresenter.isVideoMode();
// if (videoMode && PLMediaPlayer.MEDIA_INFO_VIDEO_RENDERING_START == i) {
//// initPic.setVisibility(View.INVISIBLE);
// }
return
false
;
}
...
...
@@ -917,12 +834,6 @@ public class VideoPlayActivity extends AppCompatActivity implements ObserverList
mShowing
=
false
;
}
}
private
boolean
pause
=
true
;
/**
* 退出标记
*/
private
boolean
quit
;
private
boolean
isOver
;
public
void
updatePausePlay
()
{
if
(
pause
)
mPauseButton
.
setImageResource
(
R
.
mipmap
.
play
);
...
...
@@ -948,27 +859,15 @@ private boolean pause=true;
case
Constants
.
RECORD_SEEK
:
isOver
=
false
;
pause
=
false
;
// int keyFrameSeek = jsonObject.optInt("keyFrameSeekTime");
// mRootView.seek(keyFrameSeek);
break
;
case
Constants
.
RECORD_STOP
:
pause
=
true
;
// //停止后 录制回放要进行初始化
if
(!
quit
)
{
//回放结束了
// isOver = true;
// if (currentTime < recordPlaybackMaxTime)
// currentTime++;
// xdySdk.api("initRecordPlayback", initClass);
// int classId = AccountUtils.getUser().getClassId();
// mModel.initRecordPlayback(classId, portal, userRole, userId);
// //停止视频
stopVideo
();
currentTime
=
0
;
resetSeekBar
();
// docView.clear();
// chatView.clearChatHistory();
// currentPlayAudio = null;
// currentPlayVideo = null;
EventBus
.
getDefault
().
post
(
"doc"
);
EventBus
.
getDefault
().
post
(
"chat"
);
}
...
...
@@ -991,22 +890,7 @@ private boolean pause=true;
*/
public
void
initRecordSeek
(
String
response
){
JSONObject
jsonObject
=
null
;
try
{
jsonObject
=
new
JSONObject
(
response
);
seek
=
jsonObject
.
optLong
(
"recordPlaybackMaxTime"
);
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
// if (mVideoView.isPlaying()) {
// mVideoView.stopPlayback();
// }
// if (replay && seek > 0) {
// mVideoView.seekTo(seek * 1000);
setProgress
();
//
mHandler
.
postDelayed
(
new
Runnable
()
{
@Override
public
void
run
()
{
...
...
@@ -1019,30 +903,15 @@ private boolean pause=true;
private
void
handleTime
(
String
pa
)
{
try
{
JSONObject
jsonObject
=
new
JSONObject
(
pa
);
//防止时间超了
currentTime
=
jsonObject
.
optInt
(
"classTimestamp"
);
boolean
isRe
=
jsonObject
.
optBoolean
(
"recordStatus"
);
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
setProgress
();
}
// public void setProcess(){
// if (mEndTime != null)
// mEndTime.setText(generateTime(seek));
// if (mCurrentTime != null) {
// mCurrentTime.setText(generateTime(currentTime));
// }
// if (mSeekBar != null){
//// mSeekBar.setProgress(generateTime(currentTime));
// }
// }
public
boolean
getRecordStatus
()
{
return
pause
;
}
...
...
@@ -1074,17 +943,13 @@ private boolean pause=true;
img_playVideo_novideo
.
setVisibility
(
View
.
GONE
);
if
(
mVideoView
.
isPlaying
())
{
mVideoView
.
stopPlayback
();
// mVideoView.pause();
}
mVideoView
.
setVideoPath
(
videoPlayBean
.
getReplay
());
//TODO 这个地方需要调整进度的话
XdyLogUtil
.
e
(
"播放精度哈哈哈哈哈"
,
""
+
videoPlayBean
.
getSeek
());
if
(
replay
&&
videoPlayBean
.
getSeek
()
>
0
)
{
mVideoView
.
seekTo
(
videoPlayBean
.
getSeek
()
*
1000
);
}
mVideoView
.
start
();
XdyLogUtil
.
e
(
"录制回放播放视频的了"
,
""
+
videoPlayBean
.
getReplay
());
}
}
...
...
@@ -1140,6 +1005,5 @@ private boolean pause=true;
public
void
seekRecordPlayback
(
long
time
)
{
TimeEntity
timeEntity
=
new
TimeEntity
(
time
);
xdySdk
.
api
(
"seekRecordPlayback"
,
new
Gson
().
toJson
(
timeEntity
));
}
}
...
...
MyApplication/XdyDemo/src/main/res/layout/activity_main.xml
查看文件 @
7eab632
...
...
@@ -16,7 +16,7 @@
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:hint=
"请输入课堂号"
android:text=
"
391813551"
/>
android:text=
"
1332699420"
/>
<TextView
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
...
...
@@ -64,11 +64,4 @@
android:text=
"录制回放"
/>
<Button
android:id=
"@+id/btn_home_enter_publisherAudio"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:text=
"推音频"
android:visibility=
"gone"
/>
</LinearLayout>
...
...
MyApplication/XdyDemo/src/main/res/layout/activity_video_play.xml
查看文件 @
7eab632
...
...
@@ -6,15 +6,6 @@
android:layout_height=
"match_parent"
android:orientation=
"vertical"
tools:context=
"com.mang.xdy.demo.activity.VideoPlayActivity"
>
<FrameLayout
android:id=
"@+id/fl_videoview_container"
android:layout_width=
"match_parent"
android:layout_height=
"1dp"
android:visibility=
"gone"
>
</FrameLayout>
<RelativeLayout
android:layout_width=
"match_parent"
android:layout_height=
"@dimen/ui_DIMEN_500.0PX"
>
...
...
@@ -28,10 +19,8 @@
android:layout_width=
"match_parent"
android:layout_height=
"match_parent"
/>
<!--<FrameLayout-->
<!--android:layout_width="match_parent"-->
<!--android:layout_height="match_parent">-->
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id=
"@+id/img_playVideo_novideo"
android:layout_width=
"match_parent"
...
...
@@ -39,25 +28,89 @@
android:background=
"@mipmap/novideo"
/>
<FrameLayout
android:layout_width=
"
wrap_content"
android:layout_width=
"
match_parent"
android:layout_height=
"wrap_content"
>
<FrameLayout
android:id=
"@+id/fra_videoPlay_publish"
android:layout_width=
"150dp"
android:layout_gravity=
"right|bottom"
android:layout_height=
"100dp"
>
<Button
android:id=
"@+id/btn_videoPlay_exit"
</FrameLayout>
<LinearLayout
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"开始推流"
android:visibility=
"gone"
android:orientation=
"vertical"
android:layout_alignParentRight=
"true"
android:id=
"@+id/linearLayout"
>
/>
</FrameLayout>
</LinearLayout>
<RelativeLayout
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignParentRight=
"true"
android:layout_alignParentBottom=
"true"
android:layout_below=
"@+id/linearLayout"
android:layout_alignParentLeft=
"true"
android:layout_alignParentStart=
"true"
>
<RelativeLayout
android:id=
"@+id/avg_videoPlay_back"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
android:layout_alignParentLeft=
"true"
android:layout_alignParentStart=
"true"
android:layout_alignParentTop=
"true"
android:paddingLeft=
"@dimen/ui_DIMEN_20.0PX"
android:paddingRight=
"@dimen/ui_DIMEN_20.0PX"
>
</FrameLayout>
<ImageView
android:id=
"@+id/img_videoPlay_back"
android:layout_width=
"wrap_content"
android:layout_height=
"@dimen/ui_titlebar_height"
android:paddingRight=
"20dp"
android:paddingLeft=
"15dp"
android:src=
"@mipmap/back"
/>
<TextView
android:id=
"@+id/tv_videoPlay_className"
style=
"@style/ui_wrapTvBaseStyle"
android:layout_height=
"@dimen/ui_titlebar_height"
android:layout_centerHorizontal=
"true"
android:gravity=
"center"
android:textColor=
"@color/white"
tools:text=
"hahaha"
android:textSize=
"@dimen/ui_DIMEN_34.0PX"
/>
</RelativeLayout>
<SurfaceView
android:id=
"@+id/sur_plaVideo_publish"
android:layout_width=
"120dp"
android:layout_height=
"150dp"
android:visibility=
"gone"
tools:visibility=
"visible"
android:layout_alignParentRight=
"true"
android:layout_alignParentBottom=
"true"
/>
<ImageView
android:id=
"@+id/img_videoPlay_start"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_marginRight=
"25dp"
android:layout_marginBottom=
"20dp"
android:visibility=
"gone"
tools:visibility=
"visible"
android:layout_alignParentRight=
"true"
android:layout_alignParentBottom=
"true"
android:background=
"@mipmap/camerap_normal2x"
/>
<ImageView
android:id=
"@+id/img_videoPlay_stopPublish"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:layout_alignBottom=
"@+id/sur_plaVideo_publish"
android:enabled=
"false"
android:background=
"@mipmap/hangup_normal2x"
android:visibility=
"gone"
android:layout_marginRight=
"25dp"
android:layout_marginBottom=
"20dp"
tools:visibility=
"visible"
android:layout_alignParentRight=
"true"
/>
</RelativeLayout>
</RelativeLayout>
<SurfaceView
android:id=
"@+id/surfaceview_playVideo_text"
...
...
@@ -66,24 +119,15 @@
android:visibility=
"gone"
/>
<FrameLayout
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
>
<Button
android:id=
"@+id/btn_videoPlay_stopPublish"
android:layout_width=
"wrap_content"
android:layout_height=
"wrap_content"
android:text=
"结束按钮"
android:visibility=
"gone"
/>
android:orientation=
"horizontal"
>
</FrameLayout>
<android.support.design.widget.TabLayout
android:id=
"@+id/sliding_tabs"
android:layout_width=
"match_parent"
android:layout_height=
"wrap_content"
/>
<!--</FrameLayout>-->
<com.mang.xdy.demo.widget.view.NoScrollViewPager
android:id=
"@+id/viewpager"
android:layout_width=
"match_parent"
...
...
@@ -96,7 +140,6 @@
android:layout_height=
"wrap_content"
android:layout_alignParentBottom=
"true"
>
<include
layout=
"@layout/home_media_controller"
android:layout_width=
"match_parent"
...
...
MyApplication/XdyDemo/src/main/res/layout/home_media_controller.xml
查看文件 @
7eab632
...
...
@@ -41,8 +41,6 @@
android:gravity=
"end"
tools:text=
"12:00:12"
/>
<TextView
android:id=
"@+id/tv_end_time"
style=
"@style/ui_wrapTvBaseStyle"
...
...
@@ -51,7 +49,6 @@
android:textColor=
"@color/white"
tools:text=
"12:00"
/>
<SeekBar
android:id=
"@+id/sb_live"
style=
"@style/home_seek_bar"
...
...
MyApplication/xdy/src/main/java/com/mang/xdy/api/XdyInterface.java
已删除
100644 → 0
查看文件 @
4834083
//package com.mang.xdy.api;
//
//import android.content.Context;
//
//
//import com.mang.xdy.common.Constants;
//import com.mang.xdy.core.XdyCore;
//import com.mang.xdy.utils.XdyLogUtil;
//
///**
// * 对外调用的接口
// * Created by abao on 2017/3/31.
// */
//public class XdyInterface {
// /**
// * 用户初始化,还是调用各种方法,都需要统一的对外给出监听事件
// */
// private static XdyCore mXdyCore;
// private static XdyInterface mXdyInterface;
//
// /**
// * 对外提供的异步消息接收接口(可以多个吗?)
// */
// public interface OnXdyAsyncMessageLitener{
// /**
// *
// * @param type 接收到的数据类型
// * @param response 返回数据
// */
// void onXdyAsyncMessageReceiver(String type,String response);
// }
// private static OnXdyAsyncMessageLitener mOnXdyAsyncMessageLitener;
//
// /**
// * 设置监听
// */
// public void setOnXdyAsyncMessageLitener(OnXdyAsyncMessageLitener onXdyAsyncMessageLitener){
// mOnXdyAsyncMessageLitener=onXdyAsyncMessageLitener;
// }
// private XdyInterface(){}
// /**
// * 初始化
// * @param context
// */
// public static void init(Context context){
// if(context==null){
// throw new IllegalArgumentException(Constants.ERROR_CONTENT_NULL);
// }
// mXdyCore = XdyCore.getInstance(context);
// mXdyCore.setXdyAsyncMessageListener(new XdyCore.OnXdyAsyncMessageListener() {
// @Override
// public void getSdyAsyncMessageListener(String id, String parameter) {
// XdyLogUtil.e(null,""+"xdy init success");
// if(mOnXdyAsyncMessageLitener!=null){
// mOnXdyAsyncMessageLitener.onXdyAsyncMessageReceiver(id,parameter);
// }
// }
// });
// }
//
// /**
// * 接收用户传递进来的参数
// */
// public static void setAsyncApi(String type,String argument){
// judgeCore();
// mXdyCore.native2js(type,argument);
// }
// /*判断是否被初始化*/
// public static void judgeCore(){
// if(mXdyCore==null){
// throw new IllegalArgumentException(Constants.ERROR_XDYCORE_INIT);
// }
//
// }
// public static XdyInterface getXdyInstance(){
// if(mXdyInterface==null){
// synchronized (XdyInterface.class){
// mXdyInterface=new XdyInterface();
// }
// }
// return mXdyInterface;
// }
//}
MyApplication/xdy/src/main/java/com/mang/xdy/cache/ACache.java
查看文件 @
7eab632
package
com
.
mang
.
xdy
.
cache
;
/**
* Copyright (c) 2012-2013, Michael Yang 杨福海 (www.yangfuhai.com).
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import
android.content.Context
;
import
android.graphics.Bitmap
;
...
...
MyApplication/xdy/src/main/java/com/mang/xdy/common/Constants.java
查看文件 @
7eab632
...
...
@@ -196,7 +196,7 @@ public interface Constants {
/**
* 断线重连时间间隔
*/
long
TIME_NET_ERROR_RECONNECTION
=
6
000
;
long
TIME_NET_ERROR_RECONNECTION
=
5
000
;
/**********************************以下实现为自定义code 先定义后实现*********************************************************************/
/**
...
...
MyApplication/xdy/src/main/java/com/mang/xdy/core/XdyPlayerCore.java
查看文件 @
7eab632
...
...
@@ -157,6 +157,7 @@ public class XdyPlayerCore {
libPlayer
.
SmartPlayerClose
(
playerHandle
);
playerHandle
=
0
;
}
isPlaying
=
false
;
}
/**
* 停止播放,重置正在播放标识
...
...
MyApplication/xdy/src/main/java/com/mang/xdy/core/XdySdk.java
查看文件 @
7eab632
...
...
@@ -55,6 +55,7 @@ public class XdySdk implements SubjectListener{
private
static
MsgManage
mMsgManage
;
public
static
String
TAG
=
"xdysdk"
;
/*当前播放视频的id*/
private
String
currentPlayId
=
""
;
/*缓存管理*/
private
static
ACache
aCache
;
...
...
@@ -73,6 +74,8 @@ public class XdySdk implements SubjectListener{
private
List
<
ObserverListener
>
observerListenerList
=
new
ArrayList
<
ObserverListener
>();
/*推流地址*/
private
String
publish_url
=
""
;
/*保存nodeid ,自己的唯一标识*/
private
int
nodeId
=
0
;
@Override
public
void
add
(
ObserverListener
observerListener
)
{
...
...
@@ -94,29 +97,6 @@ public class XdySdk implements SubjectListener{
}
}
}
/**
* 对外提供的异步消息接收接口)
*/
public
interface
OnXdyAsyncMessageLitener
{
/**
*
* @param type 接收到的数据类型
* @param response 返回数据
*/
void
onXdyAsyncMessageReceiver
(
String
type
,
String
response
);
}
private
OnXdyAsyncMessageLitener
mOnXdyAsyncMessageLitener
;
/**
* 设置监听
*/
public
void
setOnXdyAsyncMessageLitener
(
OnXdyAsyncMessageLitener
onXdyAsyncMessageLitener
){
judgeCore
();
mOnXdyAsyncMessageLitener
=
onXdyAsyncMessageLitener
;
}
private
XdySdk
(){}
private
static
Handler
handler
=
new
Handler
(){
...
...
@@ -191,15 +171,11 @@ public class XdySdk implements SubjectListener{
judgeString
(
type
);
switch
(
type
)
{
case
Constants
.
PLAY_AUDIO
:
//播放音频
/**
* 判断mediaId (仅播放需要)通过取得value 如果为空的话表示输入的数据有误
*
*/
//判断mediaId (仅播放需要)通过取得value 如果为空的话表示输入的数据有误
String
json_audio
=
aCache
.
getAsString
(
mediaId
);
if
(
TextUtils
.
isEmpty
(
json_audio
)){
//TODO/给出相应的提示表示没有 这个id
XdyLogUtil
.
e
(
TAG
,
"Play Audio Can not find this
AudioId"
);
XdyLogUtil
.
e
(
TAG
,
"Play Audio Can not find this
mediaId"
);
return
;
}
currentPlayId
=
mediaId
;
...
...
@@ -207,7 +183,7 @@ public class XdySdk implements SubjectListener{
if
(
audioPlayBean
!=
null
)
{
String
play_url_audio
=
""
;
if
(
isRecordPlayBack
){
play_url_audio
=
audioPlayBean
.
getReplay
();
//如果是回放给出。m3u8的id用户 用户需要自己获取play_url_audio=audioPlayBean.getReplay();
}
else
{
play_url_audio
=
audioPlayBean
.
getRtmpUrl
()
;
if
(
mXdyPlayerCore
==
null
)
{
...
...
@@ -224,14 +200,11 @@ public class XdySdk implements SubjectListener{
break
;
case
Constants
.
PLAY_VIDEO
:
//播放视频
/**
* 判断mediaId (仅播放需要)通过取得value 如果为空的话表示输入的数据有误
*
*/
// 判断mediaId (仅播放需要)通过取得value 如果为空的话表示输入的数据有误
String
json_video
=
aCache
.
getAsString
(
mediaId
);
if
(
TextUtils
.
isEmpty
(
json_video
)){
///给出相应的提示表示没有 这个id
XdyLogUtil
.
e
(
TAG
,
"Play Video Can not find this
VideoId"
);
XdyLogUtil
.
e
(
TAG
,
"Play Video Can not find this
mediaId"
);
return
;
}
currentPlayId
=
mediaId
;
...
...
@@ -239,7 +212,7 @@ public class XdySdk implements SubjectListener{
if
(
videoPlayBean
!=
null
){
String
play_url_video
=
""
;
if
(
isRecordPlayBack
){
play_url_video
=
videoPlayBean
.
getReplay
();
// play_url_video=videoPlayBean.getReplay();
}
else
{
play_url_video
=
videoPlayBean
.
getRtmpUrl
();
if
(
mXdyPlayerCore
==
null
)
{
...
...
@@ -257,13 +230,11 @@ public class XdySdk implements SubjectListener{
}
break
;
case
Constants
.
PUBLISH_VIDEO
:
//打开推流视频
/**
* 用户发起这个推流的请求的时候,
* 1,去获取推流地址
* 2,判断地址时候有用,有用的话打开播放器,开启推流的过程
* 3,推流成功告知后台,和用户
*
*/
getPublishPathVideo
();
mSurfaceView_Publish
=
surfaceView
;
...
...
@@ -335,6 +306,7 @@ public class XdySdk implements SubjectListener{
try
{
jsonObject
=
new
JSONObject
(
response
);
isRecordPlayBack
=
jsonObject
.
optBoolean
(
"isRecordPlayBack"
);
nodeId
=
jsonObject
.
optInt
(
"nodeId"
);
}
catch
(
JSONException
e
)
{
e
.
printStackTrace
();
}
...
...
@@ -346,7 +318,6 @@ public class XdySdk implements SubjectListener{
// String publishPath=XdyStringUtils.stringToJson(response);
String
publishPath
=
response
;
GetPublishPathReceiveBean
getPublishPathReceiveBean
=
JsonUtil
.
parseJsonToBean
(
publishPath
,
GetPublishPathReceiveBean
.
class
);
if
(
getPublishPathReceiveBean
!=
null
)
{
//可以推流了
if
(
getPublishPathReceiveBean
.
getCode
()
==
0
)
{
...
...
@@ -364,6 +335,9 @@ public class XdySdk implements SubjectListener{
}
if
(
mXdyPublisherCore
==
null
)
{
mXdyPublisherCore
=
new
XdyPublisherCore
(
1
,
1
,
mActivity
);
}
else
{
//todo 如果不为空的话是已经播放过,得清理上次的
mXdyPlayerCore
.
onPause
();
}
publish_url
=
video_url
;
isPublisher
=
true
;
...
...
@@ -377,7 +351,11 @@ public class XdySdk implements SubjectListener{
}
}
else
{
//给出提示
mMsgManage
.
getPublishVideoPathError
();
//TODO
handleListener
(
Constants
.
ERROR_CODE
,
"{\n"
+
" \"code\": 804,\n"
+
" \"reson\": \"推流失败\"\n"
+
"}"
);
}
break
;
case
Constants
.
AUDIO_GET_PUBLISH_PATH
:
...
...
@@ -401,8 +379,12 @@ public class XdySdk implements SubjectListener{
XdyLogUtil
.
e
(
TAG
,
"activity is null"
);
return
;
}
if
(
mXdyPublisherCore
==
null
)
mXdyPublisherCore
=
new
XdyPublisherCore
(
1
,
0
,
mActivity
);
if
(
mXdyPublisherCore
==
null
)
{
mXdyPublisherCore
=
new
XdyPublisherCore
(
1
,
0
,
mActivity
);
}
else
{
//todo 如果不为空的话是已经播放过,得清理上次的
mXdyPlayerCore
.
onPause
();
}
mXdyPublisherCore
.
publisherAudio
(
audio_url
,
new
EventHande_Publish
());
publish_url
=
audio_url
;
isPublisher
=
true
;
...
...
@@ -411,7 +393,11 @@ public class XdySdk implements SubjectListener{
PlayerUtils
.
setPublishSendSuccessAudio
(
audio_url
);
}
else
{
//给出提示
mMsgManage
.
getPublishVideoPathError
();
//TODO
handleListener
(
Constants
.
ERROR_CODE
,
"{\n"
+
" \"code\": 804,\n"
+
" \"reson\": \"推流失败\"\n"
+
"}"
);
}
break
;
case
Constants
.
PUBLISH_AUDIO
:
...
...
@@ -454,17 +440,22 @@ public class XdySdk implements SubjectListener{
String
video
=
response
;
VideoPlayBean
videoPlayBean
=
JsonUtil
.
parseJsonToBean
(
video
,
VideoPlayBean
.
class
);
if
(
videoPlayBean
!=
null
)
{
if
(
videoPlayBean
.
getMediaId
()!=
videoPlayBean
.
getFromNodeId
())
{
// if(videoPlayBean.getMediaId()!=videoPlayBean.getFromNodeId()) {
if
(
nodeId
!=
videoPlayBean
.
getFromNodeId
())
{
//过滤自己推送的video
aCache
.
put
(
videoPlayBean
.
getMediaId
()
+
""
,
video
);
handleListener
(
type
,
videoPlayBean
.
getMediaId
()
+
""
);
}
}
else
{
XdyLogUtil
.
e
(
TAG
,
"video play json error"
);
}
break
;
case
Constants
.
AUDIO_PLAY
:
String
audio
=
response
;
AudioPlayBean
audioPlayBean
=
JsonUtil
.
parseJsonToBean
(
audio
,
AudioPlayBean
.
class
);
if
(
audioPlayBean
!=
null
){
if
(
audioPlayBean
.
getMediaId
()!=
audioPlayBean
.
getFromNodeId
())
{
// if(audioPlayBean.getMediaId()!=audioPlayBean.getFromNodeId()) {
if
(
nodeId
!=
audioPlayBean
.
getFromNodeId
())
{
aCache
.
put
(
audioPlayBean
.
getMediaId
()
+
""
,
audio
);
handleListener
(
type
,
audioPlayBean
.
getMediaId
()
+
""
);
}
...
...
@@ -483,7 +474,7 @@ public class XdySdk implements SubjectListener{
if
(
isPublisher
)
{
if
(!
NetWorkUtils
.
isNetworkConnected
(
mContext
)){
//todo判断是否有网络,没有网络的话就让其退出
// TOdo 延迟
10秒,
// TOdo 延迟
5秒,
// onPublisherStop();
handler
.
sendEmptyMessageDelayed
(
Constants
.
LEAVE_CLASS_CODE
,
Constants
.
TIME_NET_ERROR_RECONNECTION
);
}
...
...
@@ -517,9 +508,7 @@ public class XdySdk implements SubjectListener{
* @param parameter
*/
private
void
handleListener
(
String
type
,
String
parameter
){
if
(
mOnXdyAsyncMessageLitener
!=
null
){
mOnXdyAsyncMessageLitener
.
onXdyAsyncMessageReceiver
(
type
,
parameter
);
}
XdyLogUtil
.
e
(
TAG
,
"type:"
+
type
+
"parameter:"
+
parameter
);
for
(
ObserverListener
o:
observerListenerList
){
o
.
observerUpData
(
type
,
parameter
);
}
...
...
@@ -551,6 +540,7 @@ public class XdySdk implements SubjectListener{
if
(
mXdyJsCore
!=
null
&&!
isRecordPlayBack
)
{
mXdyJsCore
.
init
(
mContext
);
}
onPublisherStop
();
}
/**
...
...
@@ -598,7 +588,7 @@ public class XdySdk implements SubjectListener{
}
/**
*
onResume 调用,目前是空方法
*
* TODO 只有一个boolean
* 开始isPublish 为false
* 开始推流初始化后onresume 就是开始
...
...
MyApplication/xdy/src/main/java/com/mang/xdy/ss.java
已删除
100644 → 0
查看文件 @
4834083
package
com
.
mang
.
xdy
;
/**
* Created by abao on 2017/3/30.
*/
public
class
ss
{
}
MyApplication/xdy/src/main/java/com/mang/xdy/utils/JsonUtil.java
查看文件 @
7eab632
...
...
@@ -17,7 +17,7 @@ import java.util.Map;
/**
* 封装的是使用Gson解析json的方法
*
* @author
Administrator
* @author
abao
*/
public
class
JsonUtil
{
...
...
MyApplication/xdy/src/main/java/com/mang/xdy/utils/XdyStringUtils.java
查看文件 @
7eab632
...
...
@@ -31,14 +31,6 @@ public class XdyStringUtils {
}
public
static
String
stringToJson
(
String
s
){
// StringBuffer sb = new StringBuffer();
// for(int i=0; i<s.length(); i++){
// char c =s.charAt(i);
// switch(c){
//// case'\"': sb.append(""); break;
// case'\'': sb.append(""); break;
// default: sb.append(c);
// }}
String
resString
=
""
;
if
(!
TextUtils
.
isEmpty
(
s
)&&
s
.
length
()>
2
)
{
String
temp
=
s
.
replace
(
"\\"
,
""
);
...
...
请
注册
或
登录
后发表评论