Commit 2fe6316b4c532fa87120e0c81556cd552942e0e1
Merge branch 'master' of bj.gitlab.cnlive.com:cnlive-team/CNLiveApp
Showing
19 changed files
with
122 additions
and
146 deletions
app/src/main/java/com/cnlive/gundam/main/ui/fragment/UGCListFragment.java
| ... | ... | @@ -6,7 +6,6 @@ import android.support.annotation.Nullable; |
| 6 | 6 | import android.support.v4.app.Fragment; |
| 7 | 7 | import android.support.v4.widget.SwipeRefreshLayout; |
| 8 | 8 | import android.support.v7.widget.LinearLayoutManager; |
| 9 | -import android.util.Log; | |
| 10 | 9 | import android.view.LayoutInflater; |
| 11 | 10 | import android.view.View; |
| 12 | 11 | import android.view.ViewGroup; |
| ... | ... | @@ -14,11 +13,11 @@ import android.widget.Toast; |
| 14 | 13 | |
| 15 | 14 | import com.cnlive.gundam.BR; |
| 16 | 15 | import com.cnlive.gundam.R; |
| 16 | +import com.cnlive.gundam.data.network.RetrofitUtil; | |
| 17 | +import com.cnlive.gundam.data.network.util.SignUtil; | |
| 17 | 18 | import com.cnlive.gundam.databinding.FragmentActiveListBinding; |
| 18 | 19 | import com.cnlive.gundam.main.model.ActiveInfo; |
| 19 | 20 | import com.cnlive.gundam.main.model.ActiveListModel; |
| 20 | -import com.cnlive.gundam.data.network.RetrofitUtil; | |
| 21 | -import com.cnlive.gundam.data.network.util.SignUtil; | |
| 22 | 21 | import com.cnlive.gundam.main.ui.adapter.DataBindingAdapter; |
| 23 | 22 | import com.cnlive.gundam.main.utils.ActivityJumpUtil; |
| 24 | 23 | import com.cnlive.libs.util.Config; |
| ... | ... | @@ -92,7 +91,6 @@ public class UGCListFragment extends Fragment implements SwipeRefreshLayout.OnRe |
| 92 | 91 | |
| 93 | 92 | @Override |
| 94 | 93 | public void onResponse(Call<ActiveListModel> call, Response<ActiveListModel> response) { |
| 95 | - Log.e("11111111111111", "onResponse: "+call.request().toString() ); | |
| 96 | 94 | binding.contentView.setRefreshing(false); |
| 97 | 95 | if (response.isSuccessful()) { |
| 98 | 96 | ActiveListModel model = response.body(); | ... | ... |
app/src/main/java/com/cnlive/gundam/stream/ui/activity/StreamActivity.java
| ... | ... | @@ -29,6 +29,7 @@ import com.cnlive.gundam.stream.model.ShowView; |
| 29 | 29 | import com.cnlive.gundam.stream.ui.adapter.SimpleAdapter; |
| 30 | 30 | import com.cnlive.gundam.stream.util.ChatConnect; |
| 31 | 31 | import com.cnlive.gundam.stream.util.TimerUtil; |
| 32 | +import com.cnlive.gundam.video.model.CNMessageModle; | |
| 32 | 33 | import com.cnlive.libs.stream.base.IStreamer; |
| 33 | 34 | import com.cnlive.libs.stream.model.ActivityConfig; |
| 34 | 35 | import com.cnlive.libs.stream.model.Filters; |
| ... | ... | @@ -39,9 +40,6 @@ import com.cnlive.libs.util.chat.model.CNMessage; |
| 39 | 40 | import com.cnlive.libs.util.chat.model.CNUserInfo; |
| 40 | 41 | import com.google.gson.Gson; |
| 41 | 42 | |
| 42 | -import org.json.JSONException; | |
| 43 | -import org.json.JSONObject; | |
| 44 | - | |
| 45 | 43 | import java.util.ArrayList; |
| 46 | 44 | import java.util.List; |
| 47 | 45 | |
| ... | ... | @@ -107,7 +105,6 @@ public class StreamActivity extends BaseStreamActivity implements ChatConnect.Ch |
| 107 | 105 | binding.setIsShow(showView); |
| 108 | 106 | binding.chatRecyclerView.setLayoutManager(new LinearLayoutManager(this)); |
| 109 | 107 | chatItemList = new ArrayList<>(); |
| 110 | - | |
| 111 | 108 | timerUtil = new TimerUtil(this); |
| 112 | 109 | |
| 113 | 110 | accelerometerSensor = new AccelerometerSensor(this); |
| ... | ... | @@ -135,7 +132,7 @@ public class StreamActivity extends BaseStreamActivity implements ChatConnect.Ch |
| 135 | 132 | ExtensionModel extensionModel = new ExtensionModel(channelName, coverImgUrl); |
| 136 | 133 | extensions = new Gson().toJson(extensionModel); |
| 137 | 134 | |
| 138 | - roomId = activityId; | |
| 135 | + roomId = channelId; | |
| 139 | 136 | } |
| 140 | 137 | |
| 141 | 138 | public void onClick(View view) { |
| ... | ... | @@ -409,24 +406,29 @@ public class StreamActivity extends BaseStreamActivity implements ChatConnect.Ch |
| 409 | 406 | @Override |
| 410 | 407 | public void onChatState(int what) { |
| 411 | 408 | |
| 409 | + | |
| 412 | 410 | } |
| 413 | 411 | |
| 414 | 412 | @Override |
| 415 | 413 | public void onChatMessage(CNMessage cnMessage) { |
| 416 | - //// TODO: 5/23/2017 Recyclerview添加数据 | |
| 417 | - String headUrl = cnMessage.getUserInfo().getHeadUrl() == null ? "" : cnMessage.getUserInfo().getHeadUrl(); | |
| 418 | - String userName = cnMessage.getUserInfo().getUserName() == null ? "" : cnMessage.getUserInfo().getUserName(); | |
| 419 | - String content = null; | |
| 420 | 414 | try { |
| 421 | - content = cnMessage.getContent() == null ? "" : (String) new JSONObject(cnMessage.getContent()).get("message"); | |
| 422 | - } catch (JSONException e) { | |
| 415 | + Gson gson = new Gson(); | |
| 416 | + CNMessageModle cnMessageModle = gson.fromJson(cnMessage.getContent(), CNMessageModle.class); | |
| 417 | + String messagecontent = cnMessageModle.getMessage().getContent(); | |
| 418 | + String messageType = cnMessageModle.getType(); | |
| 419 | + if (messageType.equals("giftType")) { | |
| 420 | + chatItemList.add(new ChatItem(cnMessage.getUserInfo().getHeadUrl(), cnMessage.getUserInfo().getUserName(), "送了" + messagecontent)); | |
| 421 | + } else if (messageType.equals("chatRoom")) { | |
| 422 | + chatItemList.add(new ChatItem(cnMessage.getUserInfo().getHeadUrl(), cnMessage.getUserInfo().getUserName(), messagecontent)); | |
| 423 | + | |
| 424 | + } else if (messageType.equals("joinType")) { | |
| 425 | + chatItemList.add(new ChatItem(cnMessage.getUserInfo().getHeadUrl(), cnMessage.getUserInfo().getUserName(), "加入")); | |
| 426 | + } | |
| 427 | + } catch (Exception e) { | |
| 423 | 428 | e.printStackTrace(); |
| 424 | 429 | } |
| 425 | - ChatItem chatItem = new ChatItem(headUrl, userName, content); | |
| 426 | - chatItemList.add(chatItem); | |
| 427 | 430 | chatAdapter = new SimpleAdapter(this, chatItemList, R.layout.item_chat, com.cnlive.gundam.BR.chat); |
| 428 | 431 | binding.setChatAdapter(chatAdapter); |
| 429 | - | |
| 430 | 432 | } |
| 431 | 433 | |
| 432 | 434 | private void getOnlinePerson() { | ... | ... |
app/src/main/java/com/cnlive/gundam/video/fragment/PlayerLiveFragment.java
| ... | ... | @@ -50,7 +50,8 @@ public class PlayerLiveFragment extends Fragment implements PlayerAccelerometerS |
| 50 | 50 | @Override |
| 51 | 51 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
| 52 | 52 | binding = DataBindingUtil.inflate(inflater, R.layout.fragment_player_live, container, false); |
| 53 | - getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.contentLayout, ChatRoomFragment.newInstance(), "chatRoomFragment").commit(); | |
| 53 | + program = (VideoListProgram) getArguments().getSerializable("program"); | |
| 54 | + getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.contentLayout, ChatRoomFragment.newInstance(program.getChannelId()), "chatRoomFragment").commit(); | |
| 54 | 55 | return binding.getRoot(); |
| 55 | 56 | } |
| 56 | 57 | ... | ... |
app/src/main/java/com/cnlive/gundam/video/fragment/PlayerUgcLiveFragment.java
| ... | ... | @@ -16,7 +16,7 @@ import android.widget.Toast; |
| 16 | 16 | import com.cnlive.gundam.R; |
| 17 | 17 | import com.cnlive.gundam.databinding.FragmentPlayerUgcLiveBinding; |
| 18 | 18 | import com.cnlive.gundam.main.model.VideoListProgram; |
| 19 | -import com.cnlive.gundam.video.fragment.chat.UgcLiveChatFragment; | |
| 19 | +import com.cnlive.gundam.video.fragment.chat.ChatRoomFragment; | |
| 20 | 20 | import com.cnlive.gundam.video.model.VideoModel; |
| 21 | 21 | import com.cnlive.gundam.video.utils.PlayerUtils; |
| 22 | 22 | import com.cnlive.gundam.video.view.BaseVideoView; |
| ... | ... | @@ -57,8 +57,8 @@ public class PlayerUgcLiveFragment extends Fragment implements BaseVideoView.OnU |
| 57 | 57 | @Override |
| 58 | 58 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
| 59 | 59 | binding = DataBindingUtil.inflate(inflater, R.layout.fragment_player_ugc_live, container, false); |
| 60 | - getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.contentLayout, UgcLiveChatFragment.newInstance(), "ugcLiveChatFragment").commit(); | |
| 61 | 60 | initData(); |
| 61 | + getActivity().getSupportFragmentManager().beginTransaction().replace(R.id.contentLayout, ChatRoomFragment.newInstance(id), "chatRoomFragment").commit(); | |
| 62 | 62 | return binding.getRoot(); |
| 63 | 63 | } |
| 64 | 64 | ... | ... |
app/src/main/java/com/cnlive/gundam/video/fragment/chat/ChatRoomFragment.java
| ... | ... | @@ -8,7 +8,6 @@ import android.support.v4.app.Fragment; |
| 8 | 8 | import android.support.v7.widget.GridLayoutManager; |
| 9 | 9 | import android.support.v7.widget.OrientationHelper; |
| 10 | 10 | import android.support.v7.widget.SwitchCompat; |
| 11 | -import android.util.Log; | |
| 12 | 11 | import android.view.LayoutInflater; |
| 13 | 12 | import android.view.View; |
| 14 | 13 | import android.view.ViewGroup; |
| ... | ... | @@ -48,14 +47,15 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback |
| 48 | 47 | private FragmentChatBinding fragmentChatBinding; |
| 49 | 48 | private ArrayList<GiftModle> giftArray; |
| 50 | 49 | private CommonAdapter<MessageContent> messageContentCommonAdapter; |
| 51 | - private String roomId = "ChatRoom06"; | |
| 52 | 50 | private MessageContentInfo messageContentInfo; |
| 53 | 51 | public SwitchCompat switchCompatBottom; |
| 54 | 52 | private BarrageLayout barrageLayout; |
| 53 | + private String roomId; | |
| 55 | 54 | |
| 56 | 55 | |
| 57 | - public static ChatRoomFragment newInstance() { | |
| 56 | + public static ChatRoomFragment newInstance(String id ) { | |
| 58 | 57 | Bundle args = new Bundle(); |
| 58 | + args.putString("roomID",id); | |
| 59 | 59 | ChatRoomFragment fragment = new ChatRoomFragment(); |
| 60 | 60 | fragment.setArguments(args); |
| 61 | 61 | return fragment; |
| ... | ... | @@ -66,6 +66,7 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback |
| 66 | 66 | @Override |
| 67 | 67 | public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { |
| 68 | 68 | fragmentChatBinding = DataBindingUtil.inflate(inflater, R.layout.fragment_chat, container, false); |
| 69 | + roomId = getArguments().getString("roomID"); | |
| 69 | 70 | return fragmentChatBinding.getRoot(); |
| 70 | 71 | |
| 71 | 72 | } |
| ... | ... | @@ -140,7 +141,6 @@ public class ChatRoomFragment extends Fragment implements InputUtil.SendCallback |
| 140 | 141 | @Override |
| 141 | 142 | public void onDestroy() { |
| 142 | 143 | super.onDestroy(); |
| 143 | - Log.v("fdfsfaf","dfasdfsafdfadf"); | |
| 144 | 144 | ChatUtil.disconnect(false); |
| 145 | 145 | } |
| 146 | 146 | ... | ... |
app/src/main/java/com/cnlive/gundam/video/fragment/chat/MessageContentInfo.java
| ... | ... | @@ -3,7 +3,6 @@ package com.cnlive.gundam.video.fragment.chat; |
| 3 | 3 | import android.content.Context; |
| 4 | 4 | import android.os.Handler; |
| 5 | 5 | import android.text.TextUtils; |
| 6 | -import android.util.Log; | |
| 7 | 6 | |
| 8 | 7 | import com.cnlive.gundam.user.auth.UserService; |
| 9 | 8 | import com.cnlive.gundam.video.barrage.BarrageBaseMessage; |
| ... | ... | @@ -34,19 +33,19 @@ public class MessageContentInfo { |
| 34 | 33 | private Context mContext; |
| 35 | 34 | private SendAndRecevieSucessCall mSendAndRecevieSucessCall; |
| 36 | 35 | private String roomId; |
| 37 | - private BarrageLayout barrageLayout; | |
| 36 | + private BarrageLayout barrageLayout; | |
| 38 | 37 | private String JoinType = "joinType"; |
| 39 | - private String ChatRoom ="chatRoom"; | |
| 40 | - private String giftType = "giftType"; | |
| 38 | + private String ChatRoom = "chatRoom"; | |
| 39 | + private String giftType = "giftType"; | |
| 41 | 40 | |
| 42 | 41 | |
| 43 | - public void setOnReceiveAndSendListener(BarrageLayout barrageLayout,String roomID, Context context, SendAndRecevieSucessCall sendAndRecevieSucessCall) { | |
| 42 | + public void setOnReceiveAndSendListener(BarrageLayout barrageLayout, String roomID, Context context, SendAndRecevieSucessCall sendAndRecevieSucessCall) { | |
| 44 | 43 | this.roomId = roomID; |
| 45 | 44 | this.mContext = context; |
| 46 | 45 | this.mSendAndRecevieSucessCall = sendAndRecevieSucessCall; |
| 47 | 46 | mHandler = new Handler(); |
| 48 | 47 | messageContentArrayList = new ArrayList<>(); |
| 49 | - this.barrageLayout =barrageLayout; | |
| 48 | + this.barrageLayout = barrageLayout; | |
| 50 | 49 | initListener(); |
| 51 | 50 | |
| 52 | 51 | } |
| ... | ... | @@ -66,12 +65,9 @@ public class MessageContentInfo { |
| 66 | 65 | |
| 67 | 66 | Gson gson = new Gson(); |
| 68 | 67 | CNMessageModle cnMessageModle = gson.fromJson(message.getContent(), CNMessageModle.class); |
| 69 | - String messagecontent =cnMessageModle.getMessage().getContent(); | |
| 68 | + String messagecontent = cnMessageModle.getMessage().getContent(); | |
| 70 | 69 | String messageType = cnMessageModle.getType(); |
| 71 | - | |
| 72 | - | |
| 73 | 70 | if (messageType.equals(giftType)) { |
| 74 | - | |
| 75 | 71 | barrageLayout.addMessage(new BarrageBaseMessage(message.getUserInfo().getUserName(), "送了" + messagecontent, "")); |
| 76 | 72 | messageContentArrayList.add(new MessageContent(message.getUserInfo().getUserName(), ": 送了" + messagecontent, message.getUserInfo().getHeadUrl(), true)); |
| 77 | 73 | } else if (messageType.equals(ChatRoom)) { |
| ... | ... | @@ -79,11 +75,9 @@ public class MessageContentInfo { |
| 79 | 75 | messageContentArrayList.add(new MessageContent(message.getUserInfo().getUserName(), messagecontent + " :", message.getUserInfo().getHeadUrl(), false)); |
| 80 | 76 | } else { |
| 81 | 77 | messageContentArrayList.add(new MessageContent(message.getUserInfo().getUserName(), " :" + messagecontent, message.getUserInfo().getHeadUrl(), true)); |
| 82 | - | |
| 83 | 78 | } |
| 84 | 79 | barrageLayout.addMessage(new BarrageBaseMessage(message.getUserInfo().getUserName(), messagecontent, "")); |
| 85 | 80 | |
| 86 | - | |
| 87 | 81 | } else if (messageType.equals(JoinType)) { |
| 88 | 82 | String userName = message.getUserInfo().getUserName(); |
| 89 | 83 | if (TextUtils.isEmpty(userName)) { |
| ... | ... | @@ -123,7 +117,7 @@ public class MessageContentInfo { |
| 123 | 117 | |
| 124 | 118 | Gson gson = new Gson(); |
| 125 | 119 | CNMessageModle cnMessageModle = gson.fromJson(message.getContent(), CNMessageModle.class); |
| 126 | - String messagecontent =cnMessageModle.getMessage().getContent(); | |
| 120 | + String messagecontent = cnMessageModle.getMessage().getContent(); | |
| 127 | 121 | String messageType = cnMessageModle.getType(); |
| 128 | 122 | |
| 129 | 123 | |
| ... | ... | @@ -152,14 +146,13 @@ public class MessageContentInfo { |
| 152 | 146 | onConnectListener = new IChat.OnConnectListener() { |
| 153 | 147 | @Override |
| 154 | 148 | public void onTokenIncorrect(String s) { |
| 155 | - | |
| 156 | 149 | } |
| 157 | 150 | |
| 158 | 151 | @Override |
| 159 | 152 | public void onSuccess(String s) { |
| 160 | 153 | joinChatRoom(); |
| 161 | 154 | |
| 162 | - } | |
| 155 | + } | |
| 163 | 156 | |
| 164 | 157 | |
| 165 | 158 | @Override |
| ... | ... | @@ -175,10 +168,9 @@ public class MessageContentInfo { |
| 175 | 168 | ChatUtil.joinChatRoom(roomId, 0, new IChat.OnOperationListener() { |
| 176 | 169 | @Override |
| 177 | 170 | public void onSuccess(int what, String extra) { |
| 178 | - CNMessageModle cnMessageModle = new CNMessageModle(JoinType,new MessageInfo("","","","","")); | |
| 179 | - Gson gson2=new Gson(); | |
| 180 | - String obj2=gson2.toJson(cnMessageModle); | |
| 181 | - Log.v("dfsd",obj2); | |
| 171 | + CNMessageModle cnMessageModle = new CNMessageModle(JoinType, new MessageInfo("", "", "", "", "")); | |
| 172 | + Gson gson2 = new Gson(); | |
| 173 | + String obj2 = gson2.toJson(cnMessageModle); | |
| 182 | 174 | ChatUtil.sendMessage(IChat.CHATROOM, roomId, obj2, onSendMessageListener); |
| 183 | 175 | } |
| 184 | 176 | |
| ... | ... | @@ -196,5 +188,4 @@ public class MessageContentInfo { |
| 196 | 188 | } |
| 197 | 189 | |
| 198 | 190 | |
| 199 | - | |
| 200 | 191 | } | ... | ... |
app/src/main/java/com/cnlive/gundam/video/fragment/chat/UgcLiveChatFragment.java deleted
100644 → 0
| 1 | -package com.cnlive.gundam.video.fragment.chat; | |
| 2 | - | |
| 3 | -import android.os.Bundle; | |
| 4 | -import android.support.annotation.Nullable; | |
| 5 | -import android.support.v7.widget.SwitchCompat; | |
| 6 | -import android.view.LayoutInflater; | |
| 7 | -import android.view.View; | |
| 8 | -import android.view.ViewGroup; | |
| 9 | - | |
| 10 | -import com.cnlive.gundam.R; | |
| 11 | -import com.cnlive.gundam.video.view.PlayerControllerView; | |
| 12 | - | |
| 13 | -/** | |
| 14 | - * @author 陈硕 | |
| 15 | - * @time 2017/6/29 19:36 | |
| 16 | - * @desc ${TODD} | |
| 17 | - */ | |
| 18 | -public class UgcLiveChatFragment extends ChatRoomFragment { | |
| 19 | - | |
| 20 | - public static UgcLiveChatFragment newInstance() { | |
| 21 | - Bundle args = new Bundle(); | |
| 22 | - UgcLiveChatFragment fragment = new UgcLiveChatFragment(); | |
| 23 | - fragment.setArguments(args); | |
| 24 | - return fragment; | |
| 25 | - } | |
| 26 | - | |
| 27 | - @Nullable | |
| 28 | - @Override | |
| 29 | - public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) { | |
| 30 | - return super.onCreateView(inflater, container, savedInstanceState); | |
| 31 | - } | |
| 32 | - | |
| 33 | - | |
| 34 | - @Override | |
| 35 | - public void onViewCreated(View view, @Nullable Bundle savedInstanceState) { | |
| 36 | - super.onViewCreated(view, savedInstanceState); | |
| 37 | - PlayerControllerView viewById = getActivity().findViewById(R.id.controllerView); | |
| 38 | - viewById.setonswitchCompatChangeListene(new PlayerControllerView.SwitchCompatChangeListener() { | |
| 39 | - @Override | |
| 40 | - public void onSwitchCompatChange(SwitchCompat barrageTop) { | |
| 41 | - barrageTop.setVisibility(View.INVISIBLE); | |
| 42 | - } | |
| 43 | - }); | |
| 44 | - } | |
| 45 | -} |
app/src/main/java/com/cnlive/gundam/video/view/BaseVideoView.java
| ... | ... | @@ -49,6 +49,8 @@ public abstract class BaseVideoView extends RelativeLayout implements |
| 49 | 49 | protected static boolean isLive; |
| 50 | 50 | //记录当前视频是否能播 |
| 51 | 51 | protected boolean canPlay = true; |
| 52 | + //记录当前视频状态是否结束 | |
| 53 | + protected boolean isStatusEnd = false; | |
| 52 | 54 | //本地缓存数据工具类 |
| 53 | 55 | private SharedPreferencesHelper sharedPreferencesHelper; |
| 54 | 56 | //播放进度保存至本地缓存的标识前缀 |
| ... | ... | @@ -108,7 +110,7 @@ public abstract class BaseVideoView extends RelativeLayout implements |
| 108 | 110 | if (Build.VERSION.SDK_INT >= 23) { |
| 109 | 111 | int checkCallPhonePermission = ContextCompat.checkSelfPermission(getContext(), Manifest.permission.READ_PHONE_STATE); |
| 110 | 112 | if (checkCallPhonePermission != PackageManager.PERMISSION_GRANTED) { |
| 111 | - if(ugcLivePermissionListener != null) | |
| 113 | + if (ugcLivePermissionListener != null) | |
| 112 | 114 | ugcLivePermissionListener.onShouldRequestPermission(); |
| 113 | 115 | } else { |
| 114 | 116 | addUgcLiveStatus(); |
| ... | ... | @@ -133,14 +135,14 @@ public abstract class BaseVideoView extends RelativeLayout implements |
| 133 | 135 | /** |
| 134 | 136 | * 设置UGC LIVE的直播状态监听 |
| 135 | 137 | */ |
| 136 | - public void setUgcLiveStatusPermissionListener(OnUgcLiveStatusPermissionListener l){ | |
| 138 | + public void setUgcLiveStatusPermissionListener(OnUgcLiveStatusPermissionListener l) { | |
| 137 | 139 | ugcLivePermissionListener = l; |
| 138 | 140 | } |
| 139 | 141 | |
| 140 | 142 | /** |
| 141 | 143 | * 添加UGC LIVE的直播状态监听 |
| 142 | 144 | */ |
| 143 | - public void addUgcLiveStatus(){ | |
| 145 | + public void addUgcLiveStatus() { | |
| 144 | 146 | VideoStatusUtil.setOnVideoPlayStatusCallback(mOnVideoStatusCallback); |
| 145 | 147 | VideoStatusUtil.init(videoModel.getId()); |
| 146 | 148 | } |
| ... | ... | @@ -213,7 +215,6 @@ public abstract class BaseVideoView extends RelativeLayout implements |
| 213 | 215 | * @param rate |
| 214 | 216 | */ |
| 215 | 217 | public void switchVideoRate(String rate) { |
| 216 | - //TODO 换成无缝切换 | |
| 217 | 218 | curRate = rate; |
| 218 | 219 | if (binding.controllerView != null) |
| 219 | 220 | binding.controllerView.setSwitchRateType(PlayerControllerView.SWITCH_RATE_START, curRate); |
| ... | ... | @@ -252,7 +253,7 @@ public abstract class BaseVideoView extends RelativeLayout implements |
| 252 | 253 | isPrepareSeek = true; |
| 253 | 254 | iMediaPlayer.seekTo(curPlayPosition); |
| 254 | 255 | } else { |
| 255 | - if (canPlay && !iMediaPlayer.getPlayState()) { | |
| 256 | + if (!iMediaPlayer.getPlayState()) { | |
| 256 | 257 | setPlayState(true); |
| 257 | 258 | isPlay = true; |
| 258 | 259 | } |
| ... | ... | @@ -310,22 +311,27 @@ public abstract class BaseVideoView extends RelativeLayout implements |
| 310 | 311 | switch (status) { |
| 311 | 312 | case IVideoStatus.MEDIA_STATUS_LIVING: |
| 312 | 313 | //直播中' |
| 313 | - canPlay = true; | |
| 314 | - if (!binding.videoView.getPlayState()) { | |
| 315 | - binding.videoView.reload(); | |
| 316 | - binding.infoView.show(PlayerInfoView.SHOW_BUFFERING); | |
| 314 | + if (!isStatusEnd) { | |
| 315 | + canPlay = true; | |
| 316 | + isPlay = true; | |
| 317 | + setPlayState(true); | |
| 317 | 318 | } |
| 318 | 319 | break; |
| 319 | 320 | case IVideoStatus.MEDIA_STATUS_LEAVE: |
| 320 | 321 | //主播暂时离开 |
| 321 | - canPlay = false; | |
| 322 | - binding.videoView.stop(); | |
| 323 | - binding.infoView.show(PlayerInfoView.SHOW_UGC_LIVE_STATUS, getContext().getString(R.string.player_status_leave)); | |
| 322 | + if (!isStatusEnd) { | |
| 323 | + canPlay = false; | |
| 324 | + isPlay = false; | |
| 325 | + setPlayState(false); | |
| 326 | + binding.infoView.show(PlayerInfoView.SHOW_UGC_LIVE_STATUS, getContext().getString(R.string.player_status_leave)); | |
| 327 | + } | |
| 324 | 328 | break; |
| 325 | 329 | case IVideoStatus.MEDIA_STATUS_END: |
| 326 | 330 | //直播结束 |
| 327 | 331 | canPlay = false; |
| 328 | - binding.videoView.stop(); | |
| 332 | + isPlay = false; | |
| 333 | + isStatusEnd = true; | |
| 334 | + binding.videoView.release(); | |
| 329 | 335 | binding.infoView.show(PlayerInfoView.SHOW_UGC_LIVE_STATUS, getContext().getString(R.string.player_status_end)); |
| 330 | 336 | break; |
| 331 | 337 | } |
| ... | ... | @@ -344,7 +350,7 @@ public abstract class BaseVideoView extends RelativeLayout implements |
| 344 | 350 | } |
| 345 | 351 | |
| 346 | 352 | //ugc live 监听直播状态得需要android.permission.READ_PHONE_STATE |
| 347 | - public interface OnUgcLiveStatusPermissionListener{ | |
| 353 | + public interface OnUgcLiveStatusPermissionListener { | |
| 348 | 354 | void onShouldRequestPermission(); |
| 349 | 355 | } |
| 350 | 356 | } | ... | ... |
app/src/main/res/layout/fragment_player_ugc_live.xml
app/src/main/res/layout/layout_player_controller_live_l.xml
| ... | ... | @@ -144,7 +144,7 @@ |
| 144 | 144 | <RelativeLayout |
| 145 | 145 | android:id="@+id/bottomLayout" |
| 146 | 146 | android:layout_width="match_parent" |
| 147 | - android:layout_height="wrap_content" | |
| 147 | + android:layout_height="40dp" | |
| 148 | 148 | android:background="#44000000" |
| 149 | 149 | android:visibility="@{showController.get() ? View.VISIBLE : View.GONE}"> |
| 150 | 150 | |
| ... | ... | @@ -152,33 +152,43 @@ |
| 152 | 152 | android:id="@+id/playBtn" |
| 153 | 153 | android:layout_width="30dp" |
| 154 | 154 | android:layout_height="30dp" |
| 155 | + android:layout_centerVertical="true" | |
| 155 | 156 | android:layout_marginRight="5dp" |
| 157 | + android:layout_marginLeft="10dp" | |
| 156 | 158 | android:onClick="@{playerControllerView.onClick}" |
| 157 | 159 | android:src="@{isPlay ? @drawable/player_play : @drawable/player_pause}" /> |
| 158 | 160 | |
| 159 | - <TextView | |
| 160 | - android:id="@+id/rate" | |
| 161 | + <RelativeLayout | |
| 161 | 162 | android:layout_width="wrap_content" |
| 162 | - android:layout_height="wrap_content" | |
| 163 | - android:layout_alignParentRight="true" | |
| 164 | - android:layout_centerVertical="true" | |
| 165 | - android:layout_marginRight="10dp" | |
| 166 | - android:onClick="@{playerControllerView.onClick}" | |
| 167 | - android:text="@{VideoRateUtil.getRateText(rateType.get())}" | |
| 168 | - android:textColor="@android:color/white" | |
| 169 | - android:visibility="@{hasRate.get() ? View.VISIBLE : View.GONE}" /> | |
| 163 | + android:layout_height="match_parent" | |
| 164 | + android:layout_alignParentRight="true"> | |
| 170 | 165 | |
| 171 | - <android.support.v7.widget.SwitchCompat | |
| 172 | - android:id="@+id/barrage_top" | |
| 173 | - android:layout_width="wrap_content" | |
| 174 | - android:layout_height="wrap_content" | |
| 175 | - android:layout_centerVertical="true" | |
| 176 | - android:background="@null" | |
| 177 | - android:textIsSelectable="false" | |
| 178 | - android:layout_alignParentRight="true" | |
| 179 | - android:thumb="@drawable/switch_thumb" | |
| 180 | - app:switchMinWidth="30dp" | |
| 181 | - app:track="@drawable/switch_track" /> | |
| 166 | + <TextView | |
| 167 | + android:id="@+id/rate" | |
| 168 | + android:layout_width="wrap_content" | |
| 169 | + android:layout_height="wrap_content" | |
| 170 | + android:layout_alignParentRight="true" | |
| 171 | + android:layout_centerVertical="true" | |
| 172 | + android:layout_marginRight="10dp" | |
| 173 | + android:onClick="@{playerControllerView.onClick}" | |
| 174 | + android:text="@{VideoRateUtil.getRateText(rateType.get())}" | |
| 175 | + android:textColor="@android:color/white" | |
| 176 | + android:visibility="@{hasRate.get() ? View.VISIBLE : View.GONE}" /> | |
| 177 | + | |
| 178 | + <android.support.v7.widget.SwitchCompat | |
| 179 | + android:id="@+id/barrage_top" | |
| 180 | + android:layout_width="wrap_content" | |
| 181 | + android:layout_height="wrap_content" | |
| 182 | + android:layout_centerVertical="true" | |
| 183 | + android:background="@null" | |
| 184 | + android:textIsSelectable="false" | |
| 185 | + android:layout_marginRight="10dp" | |
| 186 | + android:layout_toLeftOf="@+id/rate" | |
| 187 | + android:thumb="@drawable/switch_thumb" | |
| 188 | + app:switchMinWidth="15dp" | |
| 189 | + app:track="@drawable/switch_track" /> | |
| 190 | + | |
| 191 | + </RelativeLayout> | |
| 182 | 192 | |
| 183 | 193 | </RelativeLayout> |
| 184 | 194 | ... | ... |
app/src/main/res/layout/layout_player_controller_live_p.xml
| ... | ... | @@ -52,7 +52,7 @@ |
| 52 | 52 | <RelativeLayout |
| 53 | 53 | android:id="@+id/bottomLayout" |
| 54 | 54 | android:layout_width="match_parent" |
| 55 | - android:layout_height="wrap_content" | |
| 55 | + android:layout_height="40dp" | |
| 56 | 56 | android:background="#44000000" |
| 57 | 57 | android:layout_alignParentBottom="true" |
| 58 | 58 | android:visibility="@{showController.get() ? View.VISIBLE : View.GONE}"> |
| ... | ... | @@ -62,15 +62,17 @@ |
| 62 | 62 | android:layout_width="30dp" |
| 63 | 63 | android:layout_height="30dp" |
| 64 | 64 | android:layout_marginRight="5dp" |
| 65 | + android:layout_marginLeft="10dp" | |
| 66 | + android:layout_centerVertical="true" | |
| 65 | 67 | android:src="@{isPlay ? @drawable/player_play : @drawable/player_pause}" |
| 66 | 68 | android:onClick="@{playerControllerView.onClick}"/> |
| 67 | 69 | |
| 68 | - | |
| 69 | - | |
| 70 | 70 | <ImageView |
| 71 | 71 | android:id="@+id/fullScreen" |
| 72 | - android:layout_width="30dp" | |
| 73 | - android:layout_height="30dp" | |
| 72 | + android:layout_width="25dp" | |
| 73 | + android:layout_height="25dp" | |
| 74 | + android:layout_centerVertical="true" | |
| 75 | + android:layout_marginRight="10dp" | |
| 74 | 76 | android:src="@drawable/player_full_screen" |
| 75 | 77 | android:layout_alignParentRight="true" |
| 76 | 78 | android:onClick="@{playerControllerView.onClick}"/> | ... | ... |
app/src/main/res/layout/layout_player_controller_ugc_live_l.xml
| 1 | 1 | <?xml version="1.0" encoding="utf-8"?> |
| 2 | 2 | <layout xmlns:android="http://schemas.android.com/apk/res/android" |
| 3 | - xmlns:app="http://schemas.android.com/apk/res-auto" | |
| 4 | - > | |
| 3 | + xmlns:app="http://schemas.android.com/apk/res-auto"> | |
| 5 | 4 | |
| 6 | 5 | <data> |
| 7 | 6 | |
| ... | ... | @@ -9,7 +8,7 @@ |
| 9 | 8 | |
| 10 | 9 | <import type="android.databinding.ObservableBoolean" /> |
| 11 | 10 | |
| 12 | - <import type="com.cnlive.gundam.video.view.PlayerControllerView"/> | |
| 11 | + <import type="com.cnlive.gundam.video.view.PlayerControllerView" /> | |
| 13 | 12 | |
| 14 | 13 | <import type="android.view.View" /> |
| 15 | 14 | |
| ... | ... | @@ -27,7 +26,7 @@ |
| 27 | 26 | |
| 28 | 27 | <variable |
| 29 | 28 | name="playerControllerView" |
| 30 | - type="PlayerControllerView"/> | |
| 29 | + type="PlayerControllerView" /> | |
| 31 | 30 | |
| 32 | 31 | </data> |
| 33 | 32 | |
| ... | ... | @@ -47,8 +46,8 @@ |
| 47 | 46 | android:layout_width="30dp" |
| 48 | 47 | android:layout_height="30dp" |
| 49 | 48 | android:layout_marginLeft="10dp" |
| 50 | - android:src="@drawable/player_back" | |
| 51 | - android:onClick="@{playerControllerView.onClick}"/> | |
| 49 | + android:onClick="@{playerControllerView.onClick}" | |
| 50 | + android:src="@drawable/player_back" /> | |
| 52 | 51 | |
| 53 | 52 | <TextView |
| 54 | 53 | android:id="@+id/title" |
| ... | ... | @@ -75,9 +74,8 @@ |
| 75 | 74 | android:layout_height="30dp" |
| 76 | 75 | android:layout_marginRight="5dp" |
| 77 | 76 | android:onClick="@{playerControllerView.onClick}" |
| 78 | - android:src="@{isPlay ? @drawable/player_play : @drawable/player_pause}" /> | |
| 79 | - | |
| 80 | - | |
| 77 | + android:src="@{isPlay ? @drawable/player_play : @drawable/player_pause}" | |
| 78 | + android:visibility="gone" /> | |
| 81 | 79 | |
| 82 | 80 | </RelativeLayout> |
| 83 | 81 | ... | ... |
app/src/main/res/layout/layout_player_controller_ugc_live_p.xml
| ... | ... | @@ -63,6 +63,7 @@ |
| 63 | 63 | android:layout_width="30dp" |
| 64 | 64 | android:layout_height="30dp" |
| 65 | 65 | android:layout_marginRight="5dp" |
| 66 | + android:visibility="gone" | |
| 66 | 67 | android:onClick="@{playerControllerView.onClick}" |
| 67 | 68 | android:src="@{isPlay ? @drawable/player_play : @drawable/player_pause}"/> |
| 68 | 69 | ... | ... |
app/src/main/res/layout/layout_player_controller_ugc_vod_l.xml
| ... | ... | @@ -92,6 +92,7 @@ |
| 92 | 92 | android:layout_width="30dp" |
| 93 | 93 | android:layout_height="30dp" |
| 94 | 94 | android:layout_marginRight="5dp" |
| 95 | + android:layout_marginLeft="10dp" | |
| 95 | 96 | android:onClick="@{playerControllerView.onClick}" |
| 96 | 97 | android:src="@{isPlay ? @drawable/player_play : @drawable/player_pause}" /> |
| 97 | 98 | ... | ... |
app/src/main/res/layout/layout_player_controller_ugc_vod_p.xml
| ... | ... | @@ -60,7 +60,7 @@ |
| 60 | 60 | <RelativeLayout |
| 61 | 61 | android:id="@+id/bottomLayout" |
| 62 | 62 | android:layout_width="match_parent" |
| 63 | - android:layout_height="wrap_content" | |
| 63 | + android:layout_height="40dp" | |
| 64 | 64 | android:background="#44000000" |
| 65 | 65 | android:layout_alignParentBottom="true" |
| 66 | 66 | android:visibility="@{showController.get() ? View.VISIBLE : View.GONE}"> |
| ... | ... | @@ -70,6 +70,8 @@ |
| 70 | 70 | android:layout_width="30dp" |
| 71 | 71 | android:layout_height="30dp" |
| 72 | 72 | android:layout_marginRight="5dp" |
| 73 | + android:layout_marginLeft="10dp" | |
| 74 | + android:layout_centerVertical="true" | |
| 73 | 75 | android:onClick="@{playerControllerView.onClick}" |
| 74 | 76 | android:src="@{isPlay ? @drawable/player_play : @drawable/player_pause}"/> |
| 75 | 77 | ... | ... |
app/src/main/res/layout/layout_player_controller_vod_l.xml
| ... | ... | @@ -179,6 +179,7 @@ |
| 179 | 179 | android:layout_width="30dp" |
| 180 | 180 | android:layout_height="30dp" |
| 181 | 181 | android:layout_marginRight="5dp" |
| 182 | + android:layout_marginLeft="10dp" | |
| 182 | 183 | android:onClick="@{playerControllerView.onClick}" |
| 183 | 184 | android:src="@{isPlay ? @drawable/player_play : @drawable/player_pause}" /> |
| 184 | 185 | ... | ... |
app/src/main/res/layout/layout_player_controller_vod_p.xml
| ... | ... | @@ -61,7 +61,7 @@ |
| 61 | 61 | <RelativeLayout |
| 62 | 62 | android:id="@+id/bottomLayout" |
| 63 | 63 | android:layout_width="match_parent" |
| 64 | - android:layout_height="wrap_content" | |
| 64 | + android:layout_height="40dp" | |
| 65 | 65 | android:background="#44000000" |
| 66 | 66 | android:layout_alignParentBottom="true" |
| 67 | 67 | android:visibility="@{showController.get() ? View.VISIBLE : View.GONE}"> |
| ... | ... | @@ -71,8 +71,10 @@ |
| 71 | 71 | android:layout_width="30dp" |
| 72 | 72 | android:layout_height="30dp" |
| 73 | 73 | android:layout_marginRight="5dp" |
| 74 | + android:layout_marginLeft="10dp" | |
| 74 | 75 | android:src="@{isPlay ? @drawable/player_play : @drawable/player_pause}" |
| 75 | - android:onClick="@{playerControllerView.onClick}"/> | |
| 76 | + android:onClick="@{playerControllerView.onClick}" | |
| 77 | + android:layout_centerVertical="true"/> | |
| 76 | 78 | |
| 77 | 79 | <TextView |
| 78 | 80 | android:id="@+id/curTime" |
| ... | ... | @@ -106,10 +108,12 @@ |
| 106 | 108 | |
| 107 | 109 | <ImageView |
| 108 | 110 | android:id="@+id/fullScreen" |
| 109 | - android:layout_width="30dp" | |
| 110 | - android:layout_height="30dp" | |
| 111 | + android:layout_width="25dp" | |
| 112 | + android:layout_height="25dp" | |
| 111 | 113 | android:src="@drawable/player_full_screen" |
| 112 | 114 | android:layout_alignParentRight="true" |
| 115 | + android:layout_centerVertical="true" | |
| 116 | + android:layout_marginRight="10dp" | |
| 113 | 117 | android:onClick="@{playerControllerView.onClick}"/> |
| 114 | 118 | |
| 115 | 119 | </RelativeLayout> | ... | ... |
app/src/main/res/layout/layout_player_ugc_info.xml
| ... | ... | @@ -168,13 +168,14 @@ |
| 168 | 168 | android:layout_height="match_parent" |
| 169 | 169 | android:visibility="@{showType.get() == PlayerInfoView.SHOW_UGC_LIVE_STATUS ? View.VISIBLE : View.GONE}" |
| 170 | 170 | tools:visibility="gone" |
| 171 | - android:background="#000000"> | |
| 171 | + android:background="@color/play_status_bg"> | |
| 172 | 172 | |
| 173 | 173 | <TextView |
| 174 | 174 | android:layout_width="wrap_content" |
| 175 | 175 | android:layout_height="wrap_content" |
| 176 | 176 | android:text="@{statusMsg.get()}" |
| 177 | 177 | android:gravity="center" |
| 178 | + android:background="@drawable/player_btn_bg" | |
| 178 | 179 | android:textColor="@android:color/white" |
| 179 | 180 | android:layout_centerInParent="true"/> |
| 180 | 181 | ... | ... |