Skip to content

Commit

Permalink
Merge pull request #94 from ksvc/v3.0.4-41875
Browse files Browse the repository at this point in the history
update to v3.0.4-41875
  • Loading branch information
wang12 authored Aug 31, 2018
2 parents 6fea37b + 18c7c5e commit a2ecdcb
Show file tree
Hide file tree
Showing 36 changed files with 1,560 additions and 3 deletions.
Binary file added KSYLiveDemo/app/src/main/assets/Stickers/0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added KSYLiveDemo/app/src/main/assets/Stickers/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added KSYLiveDemo/app/src/main/assets/Stickers/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added KSYLiveDemo/app/src/main/assets/Stickers/3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added KSYLiveDemo/app/src/main/assets/Stickers/4.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added KSYLiveDemo/app/src/main/assets/Stickers/5.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added KSYLiveDemo/app/src/main/assets/Stickers/6.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added KSYLiveDemo/app/src/main/assets/Stickers/7.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added KSYLiveDemo/app/src/main/assets/Stickers/8.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -446,6 +446,11 @@ protected void onStreamerInfo(int what, int msg1, int msg2) {
case StreamerConstants.KSY_STREAMER_EST_BW_DROP:
Log.d(TAG, "BW drop to " + msg1 / 1000 + "kpbs");
break;
case StreamerConstants.KSY_STREAMER_PREVIEW_VIEW_SIZE_CHANGED:
// 如果你的预览View尺寸会动态变化,则会收到该回调。
// 要保证预览View比例变化时,预览、推流画面不变形,需要在该回调中再次配置预览、推流分辨率。
Log.d(TAG, "The set preview view size changed to: " + msg1 + "x" + msg2);
break;
default:
break;
}
Expand Down Expand Up @@ -528,6 +533,7 @@ protected void startCameraPreviewWithPermCheck() {
String[] permissions = {Manifest.permission.CAMERA,
Manifest.permission.RECORD_AUDIO,
Manifest.permission.READ_EXTERNAL_STORAGE,
Manifest.permission.WRITE_EXTERNAL_STORAGE,
Manifest.permission.READ_PHONE_STATE};
ActivityCompat.requestPermissions(this, permissions,
PERMISSION_REQUEST_CAMERA_AUDIOREC);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
import android.widget.Toast;

import com.ksyun.media.streamer.capture.camera.CameraTouchHelper;
import com.ksyun.media.streamer.demo.sticker.window.StickerWindow;
import com.ksyun.media.streamer.kit.StreamerConstants;
import com.ksyun.media.streamer.util.gles.GLRender;
import com.lht.paintview.PaintView;
Expand Down Expand Up @@ -85,12 +86,15 @@ public class StdCameraActivity extends BaseCameraActivity {
protected LinearLayout mFunctionDetailLayout;
@BindView(R.id.start_record_tv)
protected TextView mRecordingText;
@BindView(R.id.sticker_window)
protected StickerWindow mStickerWindow;

protected Fragment mEmptyFragment;
protected WaterMarkFragment mWaterMarkFragment;
protected StreamFuncFragment mStreamFuncFragment;
protected AudioFuncFragment mAudioFuncFragment;
protected VideoFilterFragment mVideoFilterFragment;
protected StickerFragment mStickerFragment;

protected volatile boolean mRecording;
protected int mLastRotation;
Expand Down Expand Up @@ -156,12 +160,14 @@ protected void createFragments() {
mStreamFuncFragment = new StreamFuncFragment();
mAudioFuncFragment = new AudioFuncFragment();
mVideoFilterFragment = new VideoFilterFragment();
mStickerFragment = new StickerFragment();
FragmentTransaction transaction = getFragmentManager().beginTransaction();
transaction.add(R.id.function_detail, mEmptyFragment);
transaction.add(R.id.function_detail, mWaterMarkFragment);
transaction.add(R.id.function_detail, mStreamFuncFragment);
transaction.add(R.id.function_detail, mAudioFuncFragment);
transaction.add(R.id.function_detail, mVideoFilterFragment);
transaction.add(R.id.function_detail, mStickerFragment);
hideFragments(transaction);
transaction.commit();
}
Expand All @@ -172,6 +178,7 @@ protected void hideFragments(FragmentTransaction transaction) {
transaction.hide(mStreamFuncFragment);
transaction.hide(mAudioFuncFragment);
transaction.hide(mVideoFilterFragment);
transaction.hide(mStickerFragment);
}

@Override
Expand All @@ -181,7 +188,7 @@ protected void initUI() {

// 功能选择下拉框
createFragments();
String[] items = new String[]{"水印设置", "推流设置", "音频设置", "视频滤镜"};
String[] items = new String[]{"水印设置", "推流设置", "音频设置", "视频滤镜", "添加贴纸"};
ArrayAdapter<String> adapter = new ArrayAdapter<>(this,
android.R.layout.simple_spinner_item, items);
adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
Expand Down Expand Up @@ -211,6 +218,9 @@ public void onItemSelected(AdapterView<?> parent, View view, int position, long
case 3:
fragment = mVideoFilterFragment;
break;
case 4:
fragment = mStickerFragment;
break;
default:
fragment = mEmptyFragment;
break;
Expand Down Expand Up @@ -301,6 +311,9 @@ protected void onStreamerInfo(int what, int msg1, int msg2) {
mRecording = false;
stopChronometer();
break;
case StreamerConstants.KSY_STREAMER_PREVIEW_VIEW_SIZE_CHANGED:
mStickerFragment.onViewSizeChanged();
break;
default:
break;
}
Expand Down Expand Up @@ -410,6 +423,13 @@ protected void handleOnPause() {
}
}

@Override
public void onBackPressed() {
if(!mStickerFragment.onBackPressed()){
super.onBackPressed();
}
}

@Override
protected void onDestroy() {
super.onDestroy();
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package com.ksyun.media.streamer.demo;

import com.ksyun.live.demo.R;
import android.app.Fragment;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.TextView;

import com.ksyun.media.streamer.demo.sticker.window.StickerWindow;
import com.ksyun.media.streamer.kit.KSYStreamer;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnCheckedChanged;
import butterknife.OnClick;
import butterknife.Unbinder;

/**
* Fragment for Sticker add.
*/
public class StickerFragment extends Fragment {

protected Unbinder mUnbinder;

@BindView(R.id.cb_sticker)
protected CheckBox mShowCheckBox;
@BindView(R.id.tv_sticker)
protected TextView mStickerButton;
protected StickerWindow mStickerWindow;
protected StdCameraActivity mActivity;

@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.sticker_fragment, container, false);
mUnbinder = ButterKnife.bind(this, view);
mActivity = (StdCameraActivity) getActivity();
mStickerWindow = mActivity.mStickerWindow;
mStickerWindow.bindKSYStreamer(mActivity.mStreamer);
return view;
}

@OnCheckedChanged(R.id.cb_sticker)
protected void onStickerChecked(boolean isChecked) {
mStickerButton.setEnabled(isChecked);
mStickerWindow.setVisibility(isChecked ? View.VISIBLE : View.GONE);
if (isChecked) {
mStickerWindow.showEditSticker(false);
mStickerWindow.showSticker();
} else {
mStickerWindow.hideSticker();
}
}

@OnClick(R.id.tv_sticker)
protected void onStickerClick() {
mStickerWindow.showEditSticker(mShowCheckBox.isChecked());
}


public boolean onBackPressed() {
if (mStickerWindow.isEdit()) {
mStickerWindow.showEditSticker(false);
mStickerWindow.showSticker();
return true;
}
return false;
}

protected void onViewSizeChanged() {
if (mShowCheckBox.isChecked()) {
mStickerWindow.hideSticker();
mStickerWindow.showSticker();
}
}

@Override
public void onDestroyView() {
super.onDestroyView();
if (mStickerWindow != null) {
mStickerWindow.unBindKSYStreamer();
}
mUnbinder.unbind();
}
}
Loading

0 comments on commit a2ecdcb

Please sign in to comment.