Commit 0ac7070d4ef52577160e912e909e40cb82fa8e83

Authored by 谷俊
0 parents

提交demo

Showing 63 changed files with 1848 additions and 0 deletions
.gitignore 0 → 100644
  1 +++ a/.gitignore
  1 +*.iml
  2 +.gradle
  3 +/local.properties
  4 +/.idea/workspace.xml
  5 +/.idea/libraries
  6 +.DS_Store
  7 +/build
  8 +/captures
... ...
.idea/.name 0 → 100644
  1 +++ a/.idea/.name
  1 +CNLiveVideoDemo
0 2 \ No newline at end of file
... ...
.idea/compiler.xml 0 → 100644
  1 +++ a/.idea/compiler.xml
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project version="4">
  3 + <component name="CompilerConfiguration">
  4 + <resourceExtensions />
  5 + <wildcardResourcePatterns>
  6 + <entry name="!?*.java" />
  7 + <entry name="!?*.form" />
  8 + <entry name="!?*.class" />
  9 + <entry name="!?*.groovy" />
  10 + <entry name="!?*.scala" />
  11 + <entry name="!?*.flex" />
  12 + <entry name="!?*.kt" />
  13 + <entry name="!?*.clj" />
  14 + <entry name="!?*.aj" />
  15 + </wildcardResourcePatterns>
  16 + <annotationProcessing>
  17 + <profile default="true" name="Default" enabled="false">
  18 + <processorPath useClasspath="true" />
  19 + </profile>
  20 + </annotationProcessing>
  21 + </component>
  22 +</project>
0 23 \ No newline at end of file
... ...
.idea/copyright/profiles_settings.xml 0 → 100644
  1 +++ a/.idea/copyright/profiles_settings.xml
  1 +<component name="CopyrightManager">
  2 + <settings default="" />
  3 +</component>
0 4 \ No newline at end of file
... ...
.idea/encodings.xml 0 → 100644
  1 +++ a/.idea/encodings.xml
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project version="4">
  3 + <component name="Encoding">
  4 + <file url="PROJECT" charset="UTF-8" />
  5 + </component>
  6 +</project>
0 7 \ No newline at end of file
... ...
.idea/gradle.xml 0 → 100644
  1 +++ a/.idea/gradle.xml
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project version="4">
  3 + <component name="GradleSettings">
  4 + <option name="linkedExternalProjectsSettings">
  5 + <GradleProjectSettings>
  6 + <option name="distributionType" value="DEFAULT_WRAPPED" />
  7 + <option name="externalProjectPath" value="$PROJECT_DIR$" />
  8 + <option name="modules">
  9 + <set>
  10 + <option value="$PROJECT_DIR$" />
  11 + <option value="$PROJECT_DIR$/app" />
  12 + </set>
  13 + </option>
  14 + <option name="myModules">
  15 + <set>
  16 + <option value="$PROJECT_DIR$" />
  17 + <option value="$PROJECT_DIR$/app" />
  18 + </set>
  19 + </option>
  20 + </GradleProjectSettings>
  21 + </option>
  22 + </component>
  23 +</project>
0 24 \ No newline at end of file
... ...
.idea/misc.xml 0 → 100644
  1 +++ a/.idea/misc.xml
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project version="4">
  3 + <component name="ProjectLevelVcsManager" settingsEditedManually="false">
  4 + <OptionsSetting value="true" id="Add" />
  5 + <OptionsSetting value="true" id="Remove" />
  6 + <OptionsSetting value="true" id="Checkout" />
  7 + <OptionsSetting value="true" id="Update" />
  8 + <OptionsSetting value="true" id="Status" />
  9 + <OptionsSetting value="true" id="Edit" />
  10 + <ConfirmationsSetting value="0" id="Add" />
  11 + <ConfirmationsSetting value="0" id="Remove" />
  12 + </component>
  13 + <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
  14 + <output url="file://$PROJECT_DIR$/build/classes" />
  15 + </component>
  16 + <component name="ProjectType">
  17 + <option name="id" value="Android" />
  18 + </component>
  19 +</project>
0 20 \ No newline at end of file
... ...
.idea/modules.xml 0 → 100644
  1 +++ a/.idea/modules.xml
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project version="4">
  3 + <component name="ProjectModuleManager">
  4 + <modules>
  5 + <module fileurl="file://$PROJECT_DIR$/CNLiveVideoDemo.iml" filepath="$PROJECT_DIR$/CNLiveVideoDemo.iml" />
  6 + <module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
  7 + </modules>
  8 + </component>
  9 +</project>
0 10 \ No newline at end of file
... ...
.idea/runConfigurations.xml 0 → 100644
  1 +++ a/.idea/runConfigurations.xml
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project version="4">
  3 + <component name="RunConfigurationProducerService">
  4 + <option name="ignoredProducers">
  5 + <set>
  6 + <option value="org.jetbrains.plugins.gradle.execution.test.runner.AllInPackageGradleConfigurationProducer" />
  7 + <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestClassGradleConfigurationProducer" />
  8 + <option value="org.jetbrains.plugins.gradle.execution.test.runner.TestMethodGradleConfigurationProducer" />
  9 + </set>
  10 + </option>
  11 + </component>
  12 +</project>
0 13 \ No newline at end of file
... ...
.idea/vcs.xml 0 → 100644
  1 +++ a/.idea/vcs.xml
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<project version="4">
  3 + <component name="VcsDirectoryMappings">
  4 + <mapping directory="$PROJECT_DIR$" vcs="Git" />
  5 + </component>
  6 +</project>
0 7 \ No newline at end of file
... ...
app/.gitignore 0 → 100644
  1 +++ a/app/.gitignore
  1 +/build
... ...
app/build.gradle 0 → 100644
  1 +++ a/app/build.gradle
  1 +apply plugin: 'com.android.application'
  2 +
  3 +android {
  4 + compileSdkVersion 24
  5 + buildToolsVersion "24.0.0"
  6 +
  7 + defaultConfig {
  8 + applicationId "com.cnlive.demo.video"
  9 + minSdkVersion 16
  10 + targetSdkVersion 22
  11 + versionCode 1
  12 + versionName "1.0"
  13 + }
  14 + buildTypes {
  15 + release {
  16 + minifyEnabled false
  17 + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  18 + }
  19 + debug {
  20 + minifyEnabled true
  21 + proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
  22 + }
  23 + }
  24 +}
  25 +
  26 +dependencies {
  27 + compile fileTree(dir: 'libs', include: ['*.jar'])
  28 + testCompile 'junit:junit:4.12'
  29 + compile 'com.android.support:appcompat-v7:24.0.0'
  30 +}
... ...
app/libs/libcnliveutil.jar 0 → 100644
No preview for this file type
app/libs/libcnlivevideo.jar 0 → 100644
No preview for this file type
app/proguard-rules.pro 0 → 100644
  1 +++ a/app/proguard-rules.pro
  1 +# Add project specific ProGuard rules here.
  2 +# By default, the flags in this file are appended to flags specified
  3 +# in D:\tools\android_sdk/tools/proguard/proguard-android.txt
  4 +# You can edit the include path and order by changing the proguardFiles
  5 +# directive in build.gradle.
  6 +#
  7 +# For more details, see
  8 +# http://developer.android.com/guide/developing/tools/proguard.html
  9 +
  10 +# Add any project specific keep options here:
  11 +
  12 +# If your project uses WebView with JS, uncomment the following
  13 +# and specify the fully qualified class name to the JavaScript interface
  14 +# class:
  15 +#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
  16 +# public *;
  17 +#}
  18 +-keepattributes Signature
  19 +
  20 +-dontwarn com.cnlive.**
  21 +-keep class com.cnlive.** {*;}
  22 +-dontwarn com.ksyun.**
  23 +-keep class com.ksyun.** { *;}
  24 +-dontwarn com.ksy.**
  25 +-keep class com.ksy.** { *;}
0 26 \ No newline at end of file
... ...
app/src/androidTest/java/com/cnlive/demo/video/ApplicationTest.java 0 → 100644
  1 +++ a/app/src/androidTest/java/com/cnlive/demo/video/ApplicationTest.java
  1 +package com.cnlive.demo.video;
  2 +
  3 +import android.app.Application;
  4 +import android.test.ApplicationTestCase;
  5 +
  6 +/**
  7 + * <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
  8 + */
  9 +public class ApplicationTest extends ApplicationTestCase<Application> {
  10 + public ApplicationTest() {
  11 + super(Application.class);
  12 + }
  13 +}
0 14 \ No newline at end of file
... ...
app/src/main/AndroidManifest.xml 0 → 100644
  1 +++ a/app/src/main/AndroidManifest.xml
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<manifest xmlns:android="http://schemas.android.com/apk/res/android"
  3 + package="com.cnlive.demo.video">
  4 +
  5 + <uses-permission android:name="android.permission.INTERNET" />
  6 + <uses-permission android:name="android.permission.WAKE_LOCK" />
  7 + <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
  8 + <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
  9 + <uses-permission android:name="android.permission.READ_PHONE_STATE"/>
  10 + <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
  11 +
  12 + <application
  13 + android:name=".CNLiveApplication"
  14 + android:allowBackup="true"
  15 + android:icon="@mipmap/ic_launcher"
  16 + android:label="@string/app_name"
  17 + android:supportsRtl="true"
  18 + android:theme="@style/AppTheme">
  19 + <activity android:name=".MainActivity">
  20 + <intent-filter>
  21 + <action android:name="android.intent.action.MAIN" />
  22 +
  23 + <category android:name="android.intent.category.LAUNCHER" />
  24 + </intent-filter>
  25 + </activity>
  26 +
  27 + <activity
  28 + android:name=".CNPlayerActivity"
  29 + android:configChanges="keyboardHidden|screenSize|orientation"
  30 + android:screenOrientation="portrait" />
  31 +
  32 + <activity
  33 + android:name=".PlayerActivity"
  34 + android:configChanges="keyboardHidden|screenSize|orientation"
  35 + android:screenOrientation="portrait"/>
  36 + <activity
  37 + android:name=".CNBarrageActivity"
  38 + android:configChanges="keyboardHidden|screenSize|orientation"
  39 + android:screenOrientation="portrait"/>
  40 +
  41 + </application>
  42 +
  43 +</manifest>
0 44 \ No newline at end of file
... ...
app/src/main/java/com/cnlive/demo/video/CNBarrageActivity.java 0 → 100644
  1 +++ a/app/src/main/java/com/cnlive/demo/video/CNBarrageActivity.java
  1 +package com.cnlive.demo.video;
  2 +
  3 +import android.app.Activity;
  4 +import android.os.Bundle;
  5 +import android.view.View;
  6 +
  7 +import com.cnlive.demo.video.barrage.BarrageBaseMessage;
  8 +import com.cnlive.demo.video.barrage.BarrageBaseView;
  9 +import com.cnlive.demo.video.barrage.BarrageGiftMessage;
  10 +import com.cnlive.demo.video.barrage.BarrageGiftView;
  11 +import com.cnlive.libs.video.barrage.BarrageLayout;
  12 +
  13 +/**
  14 + * Created by gujun on 2016/8/10.
  15 + */
  16 +public class CNBarrageActivity extends Activity implements View.OnClickListener{
  17 +
  18 + private BarrageLayout barrageLayout, barrageGiftLayout;
  19 +
  20 + @Override
  21 + protected void onCreate(Bundle savedInstanceState) {
  22 + super.onCreate(savedInstanceState);
  23 + setContentView(R.layout.activity_barrage);
  24 + barrageLayout = (BarrageLayout) findViewById(R.id.barrage);
  25 + if (barrageLayout != null) barrageLayout.init(BarrageBaseView.class, 400, 10, 10, 4);
  26 +
  27 + barrageGiftLayout = (BarrageLayout) findViewById(R.id.barrage_gift);
  28 + if (barrageGiftLayout != null) barrageGiftLayout.init(BarrageGiftView.class, 400, 4, 10, 6);
  29 +
  30 + findViewById(R.id.addMessage).setOnClickListener(this);
  31 + findViewById(R.id.addGiftMessage).setOnClickListener(this);
  32 + }
  33 +
  34 + @Override
  35 + public void onClick(View view) {
  36 + switch (view.getId()){
  37 + case R.id.addMessage:
  38 + barrageLayout.addMessage(new BarrageBaseMessage());
  39 + break;
  40 + case R.id.addGiftMessage:
  41 + barrageGiftLayout.addMessage(new BarrageGiftMessage());
  42 + break;
  43 + }
  44 + }
  45 +}
... ...
app/src/main/java/com/cnlive/demo/video/CNLiveApplication.java 0 → 100644
  1 +++ a/app/src/main/java/com/cnlive/demo/video/CNLiveApplication.java
  1 +package com.cnlive.demo.video;
  2 +
  3 +import android.app.Application;
  4 +
  5 +import com.cnlive.libs.util.Config;
  6 +
  7 +/**
  8 + * Created by gujun on 2016/8/9.
  9 + */
  10 +public class CNLiveApplication extends Application {
  11 + @Override
  12 + public void onCreate() {
  13 + super.onCreate();
  14 + //TODO 换成项目申请的对应的key
  15 + // 设置SDK AppID 及SpKey
  16 + Config.init(this, "60_irn9edco29", "69fe70bda67e059286ad509d9f5377f815955645b52f94");
  17 + }
  18 +}
... ...
app/src/main/java/com/cnlive/demo/video/CNPlayerActivity.java 0 → 100644
  1 +++ a/app/src/main/java/com/cnlive/demo/video/CNPlayerActivity.java
  1 +package com.cnlive.demo.video;
  2 +
  3 +import android.app.Activity;
  4 +import android.os.Bundle;
  5 +import android.os.Handler;
  6 +import android.os.Message;
  7 +import android.text.TextUtils;
  8 +import android.util.Log;
  9 +import android.view.View;
  10 +import android.widget.ImageView;
  11 +import android.widget.SeekBar;
  12 +import android.widget.TextView;
  13 +import android.widget.Toast;
  14 +
  15 +import com.cnlive.libs.video.player.CNMediaPlayerView;
  16 +import com.cnlive.libs.video.util.CNMediaPlayerCallBack;
  17 +import com.cnlive.libs.video.util.CNMediaPlayerType;
  18 +import com.cnlive.libs.video.util.OnPlayStateListener;
  19 +import com.ksyun.media.player.IMediaPlayer;
  20 +import com.ksyun.media.player.KSYMediaPlayer;
  21 +
  22 +import java.util.List;
  23 +import java.util.Map;
  24 +
  25 +/**
  26 + * Created by gujun on 2016/8/1.
  27 + */
  28 +public class CNPlayerActivity extends Activity implements View.OnClickListener, SeekBar.OnSeekBarChangeListener,OnPlayStateListener,CNMediaPlayerCallBack {
  29 + private static final String TAG = "CNPlayerActivity";
  30 +
  31 + private final int UPDATE_SEEKBAR = 1;
  32 +
  33 + private boolean isPlay = false;
  34 + private int mVideoProgress = 0;
  35 +
  36 + private CNMediaPlayerView cnPlayerView;
  37 + private SeekBar videoProgressBar;
  38 + private TextView videoTime;
  39 + private ImageView playerPlayPause;
  40 + private String id;
  41 +
  42 + private Handler mHandler = new Handler() {
  43 + @Override
  44 + public void handleMessage(Message msg) {
  45 + super.handleMessage(msg);
  46 + switch (msg.what) {
  47 + case UPDATE_SEEKBAR:
  48 + setVideoProgress(0);
  49 + break;
  50 + }
  51 + }
  52 + };
  53 +
  54 + private IMediaPlayer.OnBufferingUpdateListener mOnBufferingUpdateListener = new IMediaPlayer.OnBufferingUpdateListener() {
  55 +
  56 + @Override
  57 + public void onBufferingUpdate(IMediaPlayer iMediaPlayer, int percent) {
  58 + long duration = cnPlayerView.getDuration();
  59 + long progress = duration * percent / 100;
  60 + if(videoProgressBar != null) videoProgressBar.setSecondaryProgress((int)progress);
  61 + }
  62 + };
  63 +
  64 + private IMediaPlayer.OnPreparedListener mOnPrepareListener = new IMediaPlayer.OnPreparedListener() {
  65 + @Override
  66 + public void onPrepared(IMediaPlayer iMediaPlayer) {
  67 + setPlayState(true);
  68 + isPlay = true;
  69 + }
  70 + };
  71 +
  72 + private IMediaPlayer.OnCompletionListener mOnCompletionListener = new IMediaPlayer.OnCompletionListener() {
  73 + @Override
  74 + public void onCompletion(IMediaPlayer iMediaPlayer) {
  75 + Toast.makeText(CNPlayerActivity.this, "OnCompletionListener, play complete.", Toast.LENGTH_LONG).show();
  76 + isPlay = false;
  77 + if (playerPlayPause != null)
  78 + playerPlayPause.setImageResource(R.drawable.cnlive_video_play);
  79 + if (mHandler != null)
  80 + mHandler.removeMessages(UPDATE_SEEKBAR);
  81 + }
  82 + };
  83 +
  84 + private IMediaPlayer.OnInfoListener mOnInfoListener = new IMediaPlayer.OnInfoListener() {
  85 + @Override
  86 + public boolean onInfo(IMediaPlayer iMediaPlayer, int what, int extra) {
  87 + switch (what) {
  88 + case KSYMediaPlayer.MEDIA_INFO_BUFFERING_START:
  89 + Log.d(TAG, "Buffering Start.");
  90 + break;
  91 + case KSYMediaPlayer.MEDIA_INFO_BUFFERING_END:
  92 + Log.d(TAG, "Buffering End.");
  93 + break;
  94 + case KSYMediaPlayer.MEDIA_INFO_AUDIO_RENDERING_START:
  95 + Toast.makeText(CNPlayerActivity.this, "Audio Rendering Start", Toast.LENGTH_SHORT).show();
  96 + break;
  97 + case KSYMediaPlayer.MEDIA_INFO_VIDEO_RENDERING_START:
  98 + Toast.makeText(CNPlayerActivity.this, "Video Rendering Start", Toast.LENGTH_SHORT).show();
  99 + break;
  100 + case KSYMediaPlayer.MEDIA_INFO_RELOADED:
  101 + Log.d(TAG, "Reload Success");
  102 + break;
  103 + }
  104 + return false;
  105 + }
  106 + };
  107 +
  108 + private IMediaPlayer.OnErrorListener mOnErrorListener = new IMediaPlayer.OnErrorListener() {
  109 + @Override
  110 + public boolean onError(IMediaPlayer mp, int what, int extra) {
  111 + switch (what) {
  112 + case KSYMediaPlayer.MEDIA_ERROR_UNKNOWN:
  113 + Log.e(TAG, "OnErrorListener, Error Unknown:" + what + ",extra:" + extra);
  114 + break;
  115 + default:
  116 + Log.e(TAG, "OnErrorListener, Error:" + what + ",extra:" + extra);
  117 + }
  118 + Toast.makeText(CNPlayerActivity.this,"播放错误:what="+what+",,,extra="+extra,Toast.LENGTH_LONG).show();
  119 +
  120 + return false;
  121 + }
  122 + };
  123 +
  124 + private IMediaPlayer.OnSeekCompleteListener mOnSeekCompleteListener = new IMediaPlayer.OnSeekCompleteListener() {
  125 + @Override
  126 + public void onSeekComplete(IMediaPlayer iMediaPlayer) {
  127 +
  128 + }
  129 + };
  130 +
  131 + private IMediaPlayer.OnVideoSizeChangedListener mOnVideoSizeChangedListener = new IMediaPlayer.OnVideoSizeChangedListener() {
  132 + @Override
  133 + public void onVideoSizeChanged(IMediaPlayer mp, int width, int height, int sarNum, int sarDen) {
  134 +
  135 + }
  136 + };
  137 +
  138 + @Override
  139 + protected void onCreate(Bundle savedInstanceState) {
  140 + super.onCreate(savedInstanceState);
  141 + setContentView(R.layout.activity_cnplayer);
  142 + init();
  143 + }
  144 +
  145 + private void init() {
  146 + id = getIntent().getStringExtra("id");
  147 + videoProgressBar = (SeekBar) findViewById(R.id.videoProgressBar);
  148 + if (videoProgressBar != null) videoProgressBar.setOnSeekBarChangeListener(this);
  149 + videoTime = (TextView) findViewById(R.id.time);
  150 + playerPlayPause = (ImageView) findViewById(R.id.playerPlayPause);
  151 + playerPlayPause.setOnClickListener(this);
  152 + cnPlayerView = (CNMediaPlayerView) findViewById(R.id.cnPlayerView);
  153 + cnPlayerView.setKeepScreenOn(true);
  154 + initVideo();
  155 + }
  156 +
  157 + private void initVideo() {
  158 + cnPlayerView.build();
  159 + cnPlayerView.setOnBufferingUpdateListener(mOnBufferingUpdateListener);
  160 + cnPlayerView.setOnCompletionListener(mOnCompletionListener);
  161 + cnPlayerView.setOnPreparedListener(mOnPrepareListener);
  162 + cnPlayerView.setOnInfoListener(mOnInfoListener);
  163 + cnPlayerView.setOnErrorListener(mOnErrorListener);
  164 + cnPlayerView.setOnSeekCompleteListener(mOnSeekCompleteListener);
  165 + cnPlayerView.setOnVideoSizeChangedListener(mOnVideoSizeChangedListener);
  166 + cnPlayerView.setOnPlayStateListener(this);
  167 + cnPlayerView.setScreenOnWhilePlaying(true);
  168 + cnPlayerView.setBufferTimeMax(5);
  169 + if(TextUtils.isEmpty(id))
  170 + id = "d849bb4277be42799df3ffc21654d949";
  171 + cnPlayerView.initPlayer(id, "live",this);
  172 +// cnPlayerView.initPlayer("174e6c5f3d9e4ddeb739feed1906fa11", "vod",this);
  173 + }
  174 +
  175 + @Override
  176 + protected void onPause() {
  177 + super.onPause();
  178 + if (cnPlayerView != null && cnPlayerView.isPlaying()) {
  179 + setPlayState(false);
  180 + }
  181 + }
  182 +
  183 + @Override
  184 + protected void onResume() {
  185 + super.onResume();
  186 + if (cnPlayerView != null && !cnPlayerView.isPlaying() && isPlay) {
  187 + setPlayState(true);
  188 + }
  189 + }
  190 +
  191 + @Override
  192 + protected void onDestroy() {
  193 + if (mHandler != null)
  194 + mHandler.removeMessages(UPDATE_SEEKBAR);
  195 + stopPlayBack();
  196 + super.onDestroy();
  197 + }
  198 +
  199 + private void stopPlayBack() {
  200 + if (cnPlayerView != null) {
  201 + cnPlayerView.stop();
  202 + cnPlayerView.release();
  203 + }
  204 + }
  205 +
  206 + public int setVideoProgress(int currentProgress) {
  207 +
  208 + if (cnPlayerView == null)
  209 + return -1;
  210 +
  211 + long time = currentProgress > 0 ? currentProgress : cnPlayerView.getCurrentPosition();
  212 + long length = cnPlayerView.getDuration();
  213 +
  214 + // Update all view elements
  215 + if (videoProgressBar != null) {
  216 + videoProgressBar.setMax((int) length);
  217 + videoProgressBar.setProgress((int) time);
  218 + }
  219 +
  220 + if (time >= 0) {
  221 + String progress = Util.stringForTime(time / 1000) + "/" + Util.stringForTime(length / 1000);
  222 + if (videoTime != null)
  223 + videoTime.setText(progress);
  224 + }
  225 +
  226 + Message msg = new Message();
  227 + msg.what = UPDATE_SEEKBAR;
  228 +
  229 + if (mHandler != null) {
  230 + mHandler.removeMessages(UPDATE_SEEKBAR);
  231 + mHandler.sendMessageDelayed(msg, 1000);
  232 + }
  233 +
  234 + return (int) time;
  235 + }
  236 +
  237 + @Override
  238 + public void onClick(View v) {
  239 + switch (v.getId()){
  240 + case R.id.playerPlayPause:
  241 + if (cnPlayerView != null) {
  242 + isPlay = !isPlay;
  243 + setPlayState(isPlay);
  244 + }
  245 + break;
  246 + }
  247 + }
  248 +
  249 + private void setPlayState(boolean isPlay) {
  250 + if (isPlay) cnPlayerView.start();
  251 + else cnPlayerView.pause();
  252 + }
  253 +
  254 + protected void updateProgress(boolean isPlay) {
  255 + if (isPlay) setVideoProgress(0);
  256 + else if (mHandler != null) mHandler.removeMessages(UPDATE_SEEKBAR);
  257 + }
  258 +
  259 + @Override
  260 + public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
  261 + if (fromUser) {
  262 + mVideoProgress = progress;
  263 + }
  264 + }
  265 +
  266 + @Override
  267 + public void onStartTrackingTouch(SeekBar seekBar) {
  268 +
  269 + }
  270 +
  271 + @Override
  272 + public void onStopTrackingTouch(SeekBar seekBar) {
  273 + cnPlayerView.seekTo(mVideoProgress);
  274 + setVideoProgress(mVideoProgress);
  275 + }
  276 +
  277 + @Override
  278 + public void onPlayState(boolean isPlay) {
  279 + if (isPlay) playerPlayPause.setImageResource(R.drawable.cnlive_video_pause);
  280 + else playerPlayPause.setImageResource(R.drawable.cnlive_video_play);
  281 + updateProgress(isPlay);
  282 + }
  283 +
  284 + /**
  285 + * initPlayer ()的请求回调
  286 + * @param completeFlag 判断回调状态
  287 + * @param ext 回调状态说明
  288 + * @param viewAndRate 回调返回的视角及播放码率 map的
  289 + * key: 当前视频拥有的视角view1:视角一 ; view2:视角二; view3:视角三; view4:视角四
  290 + * Value:当前视角对应的拥有的码率列表rate1:流畅; rate2:标清; rate3:高清; rate4:超清。
  291 + */
  292 + @Override
  293 + public void initMediaPlayerComplete(int completeFlag, String ext, Map<String, List<String>> viewAndRate) {
  294 + switch (completeFlag){
  295 + case CNMediaPlayerType.TYPE_LOAD_DATA_SUCCESS:
  296 + //TODO 根据返回的视角和码率信息 做相应的ui展示并将ui设置的视角和码率通过如下方法传回sdk进行播放(切换视角和码率也同样调用startPlay(String,String))
  297 + if(cnPlayerView != null){
  298 + cnPlayerView.startPlay("view1","rate2");
  299 + }
  300 + Toast.makeText(this,"回调成功:"+ext,Toast.LENGTH_LONG).show();
  301 + break;
  302 + case CNMediaPlayerType.TYPE_LOAD_DATA_ERROR_AUTHENTICATE:
  303 + Toast.makeText(this,"鉴权失败:"+ext,Toast.LENGTH_LONG).show();
  304 + break;
  305 + case CNMediaPlayerType.TYPE_LOAD_DATA_ERROR_NET:
  306 + Toast.makeText(this,"网络异常",Toast.LENGTH_LONG).show();
  307 + break;
  308 + case CNMediaPlayerType.TYPE_LOAD_DATA_ERROR:
  309 + Toast.makeText(this,"加载数据失败",Toast.LENGTH_LONG).show();
  310 + break;
  311 + }
  312 + }
  313 +}
... ...
app/src/main/java/com/cnlive/demo/video/MainActivity.java 0 → 100644
  1 +++ a/app/src/main/java/com/cnlive/demo/video/MainActivity.java
  1 +package com.cnlive.demo.video;
  2 +
  3 +import android.content.Intent;
  4 +import android.support.v7.app.AppCompatActivity;
  5 +import android.os.Bundle;
  6 +import android.text.TextUtils;
  7 +import android.view.View;
  8 +import android.widget.EditText;
  9 +
  10 +public class MainActivity extends AppCompatActivity implements View.OnClickListener{
  11 + private EditText editText;
  12 +
  13 + @Override
  14 + protected void onCreate(Bundle savedInstanceState) {
  15 + super.onCreate(savedInstanceState);
  16 + setContentView(R.layout.activity_main);
  17 + editText = (EditText) findViewById(R.id.activedId);
  18 + findViewById(R.id.play).setOnClickListener(this);
  19 + findViewById(R.id.playCnlive).setOnClickListener(this);
  20 + findViewById(R.id.barrageBtn).setOnClickListener(this);
  21 + }
  22 +
  23 + @Override
  24 + public void onClick(View view) {
  25 + switch (view.getId()){
  26 + case R.id.play:
  27 + startActivity(new Intent(this,PlayerActivity.class));
  28 + break;
  29 + case R.id.playCnlive:
  30 + Intent intent = new Intent(this,CNPlayerActivity.class);
  31 + intent.putExtra("id",editText.getText().toString());
  32 + startActivity(intent);
  33 + break;
  34 + case R.id.barrageBtn:
  35 + startActivity(new Intent(this,CNBarrageActivity.class));
  36 + break;
  37 + }
  38 + }
  39 +}
... ...
app/src/main/java/com/cnlive/demo/video/PlayerActivity.java 0 → 100644
  1 +++ a/app/src/main/java/com/cnlive/demo/video/PlayerActivity.java
  1 +package com.cnlive.demo.video;
  2 +
  3 +import android.app.Activity;
  4 +import android.os.Bundle;
  5 +import android.os.Handler;
  6 +import android.os.Message;
  7 +import android.util.Log;
  8 +import android.view.View;
  9 +import android.widget.ImageView;
  10 +import android.widget.SeekBar;
  11 +import android.widget.TextView;
  12 +import android.widget.Toast;
  13 +
  14 +import com.cnlive.libs.video.player.CNMediaPlayerView;
  15 +import com.cnlive.libs.video.util.OnPlayStateListener;
  16 +import com.ksyun.media.player.IMediaPlayer;
  17 +import com.ksyun.media.player.KSYMediaPlayer;
  18 +
  19 +import java.io.IOException;
  20 +
  21 +/**
  22 + * Created by gujun on 2016/8/1.
  23 + */
  24 +public class PlayerActivity extends Activity implements View.OnClickListener, SeekBar.OnSeekBarChangeListener,OnPlayStateListener {
  25 + private static final String TAG = "PlayerActivity";
  26 +
  27 + private final int UPDATE_SEEKBAR = 1;
  28 +
  29 + private boolean isPlay = false;
  30 + private int mVideoProgress = 0;
  31 +
  32 + private CNMediaPlayerView cnPlayerView;
  33 + private SeekBar videoProgressBar;
  34 + private TextView videoTime;
  35 + private ImageView playerPlayPause;
  36 +
  37 + private Handler mHandler = new Handler() {
  38 + @Override
  39 + public void handleMessage(Message msg) {
  40 + super.handleMessage(msg);
  41 + switch (msg.what) {
  42 + case UPDATE_SEEKBAR:
  43 + setVideoProgress(0);
  44 + break;
  45 + }
  46 + }
  47 + };
  48 +
  49 + private IMediaPlayer.OnBufferingUpdateListener mOnBufferingUpdateListener = new IMediaPlayer.OnBufferingUpdateListener() {
  50 +
  51 + @Override
  52 + public void onBufferingUpdate(IMediaPlayer iMediaPlayer, int percent) {
  53 + long duration = cnPlayerView.getDuration();
  54 + long progress = duration * percent / 100;
  55 + if(videoProgressBar != null) videoProgressBar.setSecondaryProgress((int)progress);
  56 + }
  57 + };
  58 +
  59 + private IMediaPlayer.OnPreparedListener mOnPrepareListener = new IMediaPlayer.OnPreparedListener() {
  60 + @Override
  61 + public void onPrepared(IMediaPlayer iMediaPlayer) {
  62 + setPlayState(true);
  63 + isPlay = true;
  64 + }
  65 + };
  66 +
  67 + private IMediaPlayer.OnCompletionListener mOnCompletionListener = new IMediaPlayer.OnCompletionListener() {
  68 + @Override
  69 + public void onCompletion(IMediaPlayer iMediaPlayer) {
  70 + Toast.makeText(PlayerActivity.this, "OnCompletionListener, play complete.", Toast.LENGTH_LONG).show();
  71 + isPlay = false;
  72 + if (playerPlayPause != null)
  73 + playerPlayPause.setImageResource(R.drawable.cnlive_video_play);
  74 + if (mHandler != null)
  75 + mHandler.removeMessages(UPDATE_SEEKBAR);
  76 + }
  77 + };
  78 +
  79 + private IMediaPlayer.OnInfoListener mOnInfoListener = new IMediaPlayer.OnInfoListener() {
  80 + @Override
  81 + public boolean onInfo(IMediaPlayer iMediaPlayer, int what, int extra) {
  82 + switch (what) {
  83 + case KSYMediaPlayer.MEDIA_INFO_BUFFERING_START:
  84 + Log.d(TAG, "Buffering Start.");
  85 + break;
  86 + case KSYMediaPlayer.MEDIA_INFO_BUFFERING_END:
  87 + Log.d(TAG, "Buffering End.");
  88 + break;
  89 + case KSYMediaPlayer.MEDIA_INFO_AUDIO_RENDERING_START:
  90 + Toast.makeText(PlayerActivity.this, "Audio Rendering Start", Toast.LENGTH_SHORT).show();
  91 + break;
  92 + case KSYMediaPlayer.MEDIA_INFO_VIDEO_RENDERING_START:
  93 + Toast.makeText(PlayerActivity.this, "Video Rendering Start", Toast.LENGTH_SHORT).show();
  94 + break;
  95 + case KSYMediaPlayer.MEDIA_INFO_RELOADED:
  96 + Log.d(TAG, "Reload Success");
  97 + setPlayState(true);
  98 + isPlay = true;
  99 + break;
  100 + }
  101 + return false;
  102 + }
  103 + };
  104 +
  105 + private IMediaPlayer.OnErrorListener mOnErrorListener = new IMediaPlayer.OnErrorListener() {
  106 + @Override
  107 + public boolean onError(IMediaPlayer mp, int what, int extra) {
  108 + switch (what) {
  109 + case KSYMediaPlayer.MEDIA_ERROR_UNKNOWN:
  110 + Log.e(TAG, "OnErrorListener, Error Unknown:" + what + ",extra:" + extra);
  111 + break;
  112 + default:
  113 + Log.e(TAG, "OnErrorListener, Error:" + what + ",extra:" + extra);
  114 + }
  115 +
  116 + return false;
  117 + }
  118 + };
  119 +
  120 + private IMediaPlayer.OnSeekCompleteListener mOnSeekCompleteListener = new IMediaPlayer.OnSeekCompleteListener() {
  121 + @Override
  122 + public void onSeekComplete(IMediaPlayer iMediaPlayer) {
  123 +
  124 + }
  125 + };
  126 +
  127 + private IMediaPlayer.OnVideoSizeChangedListener mOnVideoSizeChangedListener = new IMediaPlayer.OnVideoSizeChangedListener() {
  128 + @Override
  129 + public void onVideoSizeChanged(IMediaPlayer mp, int width, int height, int sarNum, int sarDen) {
  130 +
  131 + }
  132 + };
  133 +
  134 + @Override
  135 + protected void onCreate(Bundle savedInstanceState) {
  136 + super.onCreate(savedInstanceState);
  137 + setContentView(R.layout.activity_cnplayer);
  138 + init();
  139 + }
  140 +
  141 + private void init() {
  142 + videoProgressBar = (SeekBar) findViewById(R.id.videoProgressBar);
  143 + if (videoProgressBar != null) videoProgressBar.setOnSeekBarChangeListener(this);
  144 + videoTime = (TextView) findViewById(R.id.time);
  145 + playerPlayPause = (ImageView) findViewById(R.id.playerPlayPause);
  146 + playerPlayPause.setOnClickListener(this);
  147 + cnPlayerView = (CNMediaPlayerView) findViewById(R.id.cnPlayerView);
  148 + cnPlayerView.setKeepScreenOn(true);
  149 + initVideo();
  150 + }
  151 +
  152 + private void initVideo() {
  153 + cnPlayerView.build();
  154 + cnPlayerView.setOnBufferingUpdateListener(mOnBufferingUpdateListener);
  155 + cnPlayerView.setOnCompletionListener(mOnCompletionListener);
  156 + cnPlayerView.setOnPreparedListener(mOnPrepareListener);
  157 + cnPlayerView.setOnInfoListener(mOnInfoListener);
  158 + cnPlayerView.setOnErrorListener(mOnErrorListener);
  159 + cnPlayerView.setOnSeekCompleteListener(mOnSeekCompleteListener);
  160 + cnPlayerView.setOnVideoSizeChangedListener(mOnVideoSizeChangedListener);
  161 + cnPlayerView.setOnPlayStateListener(this);
  162 + cnPlayerView.setScreenOnWhilePlaying(true);
  163 + cnPlayerView.setBufferTimeMax(5);
  164 + try {
  165 + cnPlayerView.setDataSource("http://img.ksbbs.com/asset/Mon_1605/0ec8cc80112a2d6.mp4");
  166 + cnPlayerView.prepareAsync();
  167 + } catch (IOException e) {
  168 + e.printStackTrace();
  169 + }
  170 + }
  171 +
  172 + @Override
  173 + protected void onPause() {
  174 + super.onPause();
  175 + if (cnPlayerView != null && cnPlayerView.isPlaying()) {
  176 + setPlayState(false);
  177 + }
  178 + }
  179 +
  180 + @Override
  181 + protected void onResume() {
  182 + super.onResume();
  183 + if (cnPlayerView != null && !cnPlayerView.isPlaying() && isPlay) {
  184 + setPlayState(true);
  185 + }
  186 + }
  187 +
  188 + @Override
  189 + protected void onDestroy() {
  190 + if (mHandler != null)
  191 + mHandler.removeMessages(UPDATE_SEEKBAR);
  192 + stopPlayBack();
  193 + super.onDestroy();
  194 + }
  195 +
  196 + private void stopPlayBack() {
  197 + if (cnPlayerView != null) {
  198 + cnPlayerView.stop();
  199 + cnPlayerView.release();
  200 + }
  201 + }
  202 +
  203 + public int setVideoProgress(int currentProgress) {
  204 +
  205 + if (cnPlayerView == null)
  206 + return -1;
  207 +
  208 + long time = currentProgress > 0 ? currentProgress : cnPlayerView.getCurrentPosition();
  209 + long length = cnPlayerView.getDuration();
  210 +
  211 + // Update all view elements
  212 + if (videoProgressBar != null) {
  213 + videoProgressBar.setMax((int) length);
  214 + videoProgressBar.setProgress((int) time);
  215 + }
  216 +
  217 + if (time >= 0) {
  218 + String progress = Util.stringForTime(time / 1000) + "/" + Util.stringForTime(length / 1000);
  219 + if (videoTime != null)
  220 + videoTime.setText(progress);
  221 + }
  222 +
  223 + Message msg = new Message();
  224 + msg.what = UPDATE_SEEKBAR;
  225 +
  226 + if (mHandler != null) {
  227 + mHandler.removeMessages(UPDATE_SEEKBAR);
  228 + mHandler.sendMessageDelayed(msg, 1000);
  229 + }
  230 +
  231 + return (int) time;
  232 + }
  233 +
  234 + @Override
  235 + public void onClick(View v) {
  236 + switch (v.getId()){
  237 + case R.id.playerPlayPause:
  238 + if (cnPlayerView != null) {
  239 + isPlay = !isPlay;
  240 + setPlayState(isPlay);
  241 + }
  242 + break;
  243 + }
  244 + }
  245 +
  246 + private void setPlayState(boolean isPlay) {
  247 + if (isPlay) cnPlayerView.start();
  248 + else cnPlayerView.pause();
  249 + }
  250 +
  251 + protected void updateProgress(boolean isPlay) {
  252 + if (isPlay) setVideoProgress(0);
  253 + else if (mHandler != null) mHandler.removeMessages(UPDATE_SEEKBAR);
  254 + }
  255 +
  256 + @Override
  257 + public void onProgressChanged(SeekBar seekBar, int progress, boolean fromUser) {
  258 + if (fromUser) {
  259 + mVideoProgress = progress;
  260 + }
  261 + }
  262 +
  263 + @Override
  264 + public void onStartTrackingTouch(SeekBar seekBar) {
  265 +
  266 + }
  267 +
  268 + @Override
  269 + public void onStopTrackingTouch(SeekBar seekBar) {
  270 + cnPlayerView.seekTo(mVideoProgress);
  271 + setVideoProgress(mVideoProgress);
  272 + }
  273 +
  274 + @Override
  275 + public void onPlayState(boolean isPlay) {
  276 + if (isPlay) playerPlayPause.setImageResource(R.drawable.cnlive_video_pause);
  277 + else playerPlayPause.setImageResource(R.drawable.cnlive_video_play);
  278 + updateProgress(isPlay);
  279 + }
  280 +}
... ...
app/src/main/java/com/cnlive/demo/video/Util.java 0 → 100644
  1 +++ a/app/src/main/java/com/cnlive/demo/video/Util.java
  1 +package com.cnlive.demo.video;
  2 +
  3 +import java.util.Locale;
  4 +
  5 +/**
  6 + * Created by xiansong on 2016/7/4.
  7 + */
  8 +public class Util {
  9 +
  10 + public static String stringForTime(long second) {
  11 + int totalSeconds = (int) second;
  12 +
  13 + int seconds = totalSeconds % 60;
  14 + int minutes = (totalSeconds / 60) % 60;
  15 + int hours = totalSeconds / 3600;
  16 +
  17 + if (hours > 0) {
  18 + return String.format(Locale.getDefault(), "%d:%02d:%02d", hours, minutes, seconds);
  19 + } else {
  20 + return String.format(Locale.getDefault(), "%02d:%02d", minutes, seconds);
  21 + }
  22 + }
  23 +
  24 +
  25 +
  26 +}
... ...
app/src/main/java/com/cnlive/demo/video/barrage/BarrageBaseMessage.java 0 → 100644
  1 +++ a/app/src/main/java/com/cnlive/demo/video/barrage/BarrageBaseMessage.java
  1 +package com.cnlive.demo.video.barrage;
  2 +
  3 +import com.cnlive.libs.video.barrage.model.BarrageMessage;
  4 +
  5 +//普通 弹幕消息
  6 +public class BarrageBaseMessage extends ChatMessage implements BarrageMessage {
  7 +
  8 + String name = "名字";
  9 + String message = "弹幕消息弹幕消息弹幕消息弹幕消息弹幕消息弹幕消息弹幕消息弹幕消息弹幕消息弹幕消息";
  10 + String icon = "http://y3.cnliveimg.com:8080/image/itv/2016/0729/c48d1db2dc1641f19d90ef23e294d34a_139042_100.jpg";
  11 +
  12 + public BarrageBaseMessage() {
  13 + }
  14 +
  15 + public BarrageBaseMessage(String name, String message, String icon) {
  16 + this.name = name;
  17 + this.message = message;
  18 + this.icon = icon;
  19 + }
  20 +
  21 + @Override
  22 + public String getIcon() {
  23 + return icon;
  24 + }
  25 +
  26 + @Override
  27 + public String getName() {
  28 + return name;
  29 + }
  30 +
  31 + @Override
  32 + public String getMessage() {
  33 + return message;
  34 + }
  35 +
  36 + @Override
  37 + public boolean isSelf() {
  38 + return false;
  39 + }
  40 +
  41 +}
... ...
app/src/main/java/com/cnlive/demo/video/barrage/BarrageBaseView.java 0 → 100644
  1 +++ a/app/src/main/java/com/cnlive/demo/video/barrage/BarrageBaseView.java
  1 +package com.cnlive.demo.video.barrage;
  2 +
  3 +import android.content.Context;
  4 +import android.util.AttributeSet;
  5 +import android.view.View;
  6 +
  7 +import com.cnlive.demo.video.R;
  8 +import com.cnlive.libs.util.ui.emojicon.EmojiconTextView;
  9 +import com.cnlive.libs.video.barrage.MessageView;
  10 +import com.cnlive.libs.video.barrage.model.BarrageMessage;
  11 +
  12 +
  13 +/**
  14 + * Created by xiansong on 2016/5/19.
  15 + */
  16 +public class BarrageBaseView extends MessageView<BarrageMessage> {
  17 +
  18 + public EmojiconTextView chat_item_name;
  19 +
  20 + public EmojiconTextView chat_item_message;
  21 +
  22 + public View chat_item_bg;
  23 +
  24 + public BarrageBaseView(Context context) {
  25 + this(context, null);
  26 + }
  27 +
  28 + public BarrageBaseView(Context context, AttributeSet attrs) {
  29 + this(context, attrs, 0);
  30 + }
  31 +
  32 + public BarrageBaseView(Context context, AttributeSet attrs, int defStyleAttr) {
  33 + super(context, attrs, defStyleAttr);
  34 + chat_item_bg = findViewById(R.id.chat_item_bg);
  35 + chat_item_name = (EmojiconTextView) findViewById(R.id.chat_item_name);
  36 + chat_item_message = (EmojiconTextView) findViewById(R.id.chat_item_message);
  37 + }
  38 +
  39 + @Override
  40 + public int getLayoutResource() {
  41 + return R.layout.cnlive_view_chat_barrage;
  42 + }
  43 +
  44 + @Override
  45 + public void setData(BarrageMessage data) {
  46 + chat_item_bg.setBackgroundResource(data.isSelf() ? R.drawable.cnlive_chat_on : R.drawable.cnlive_chat_off);
  47 + chat_item_name.setText(data.getName() + ":");
  48 + chat_item_message.setText(data.getMessage());
  49 + }
  50 +}
... ...
app/src/main/java/com/cnlive/demo/video/barrage/BarrageGiftMessage.java 0 → 100644
  1 +++ a/app/src/main/java/com/cnlive/demo/video/barrage/BarrageGiftMessage.java
  1 +package com.cnlive.demo.video.barrage;
  2 +
  3 +import com.cnlive.demo.video.R;
  4 +import com.cnlive.libs.video.barrage.model.BarrageMessage;
  5 +
  6 +//自定义 弹幕消息
  7 +public class BarrageGiftMessage extends ChatMessage implements BarrageMessage {
  8 +
  9 + int gift_icon = R.drawable.cnlive_icon_chat_gift;
  10 + String name = "名字";
  11 + String message = "弹幕消息弹幕消息弹幕消息弹幕消息弹幕消息弹幕消息弹幕消息弹幕消息弹幕消息弹幕消息";
  12 + String icon = "http://y3.cnliveimg.com:8080/image/itv/2016/0729/c48d1db2dc1641f19d90ef23e294d34a_139042_100.jpg";
  13 +
  14 + public BarrageGiftMessage() {
  15 + }
  16 +
  17 + public BarrageGiftMessage(int gift_icon, String name, String message, String icon) {
  18 + this.gift_icon = gift_icon;
  19 + this.name = name;
  20 + this.message = message;
  21 + this.icon = icon;
  22 + }
  23 +
  24 + public int getGiftIcon() {
  25 + return gift_icon;
  26 + }
  27 +
  28 + @Override
  29 + public String getIcon() {
  30 + return icon;
  31 + }
  32 +
  33 + @Override
  34 + public String getName() {
  35 + return name;
  36 + }
  37 +
  38 + @Override
  39 + public String getMessage() {
  40 + return message;
  41 + }
  42 +
  43 + @Override
  44 + public boolean isSelf() {
  45 + return false;
  46 + }
  47 +
  48 +}
... ...
app/src/main/java/com/cnlive/demo/video/barrage/BarrageGiftView.java 0 → 100644
  1 +++ a/app/src/main/java/com/cnlive/demo/video/barrage/BarrageGiftView.java
  1 +package com.cnlive.demo.video.barrage;
  2 +
  3 +import android.content.Context;
  4 +import android.util.AttributeSet;
  5 +import android.widget.ImageView;
  6 +
  7 +import com.cnlive.demo.video.R;
  8 +import com.cnlive.libs.util.ui.emojicon.EmojiconTextView;
  9 +import com.cnlive.libs.video.barrage.MessageView;
  10 +
  11 +
  12 +//自定义 弹幕视图
  13 +public class BarrageGiftView extends MessageView<BarrageGiftMessage> {
  14 +
  15 + public EmojiconTextView chat_item_name;
  16 +
  17 + public EmojiconTextView chat_item_message;
  18 +
  19 + public ImageView chat_item_image;
  20 +
  21 + public ImageView chat_item_gift;
  22 +
  23 +
  24 + public BarrageGiftView(Context context) {
  25 + this(context, null);
  26 + }
  27 +
  28 + public BarrageGiftView(Context context, AttributeSet attrs) {
  29 + this(context, attrs, 0);
  30 + }
  31 +
  32 + public BarrageGiftView(Context context, AttributeSet attrs, int defStyleAttr) {
  33 + super(context, attrs, defStyleAttr);
  34 + chat_item_name = (EmojiconTextView) findViewById(R.id.chat_item_name);
  35 + chat_item_message = (EmojiconTextView) findViewById(R.id.chat_item_message);
  36 + chat_item_image = (ImageView) findViewById(R.id.chat_item_image);
  37 + chat_item_gift = (ImageView) findViewById(R.id.chat_item_gift);
  38 + }
  39 +
  40 + @Override
  41 + public int getLayoutResource() {
  42 + return R.layout.cnlive_view_chat_gift;
  43 + }
  44 +
  45 + @Override
  46 + public void setData(BarrageGiftMessage data) {
  47 + chat_item_name.setText(data.getName());
  48 + chat_item_message.setText(data.getMessage());
  49 + chat_item_gift.setImageResource(data.getGiftIcon());
  50 + }
  51 +}
... ...
app/src/main/java/com/cnlive/demo/video/barrage/ChatMessage.java 0 → 100644
  1 +++ a/app/src/main/java/com/cnlive/demo/video/barrage/ChatMessage.java
  1 +package com.cnlive.demo.video.barrage;
  2 +
  3 +/**
  4 + * Created by xiansong on 2016/8/5.
  5 + */
  6 +public class ChatMessage {
  7 + protected String type;
  8 +
  9 + public String getType() {
  10 + return type;
  11 + }
  12 +
  13 + public void setType(String type) {
  14 + this.type = type;
  15 + }
  16 +}
... ...
app/src/main/jniLibs/arm64-v8a/libksyplayer.so 0 → 100644
No preview for this file type
app/src/main/jniLibs/armeabi-v7a/libksyplayer.so 0 → 100644
No preview for this file type
app/src/main/jniLibs/x86/libksyplayer.so 0 → 100644
No preview for this file type
app/src/main/res/drawable-xxhdpi/cnlive_chat_off.9.png 0 → 100644

182 Bytes

app/src/main/res/drawable-xxhdpi/cnlive_chat_on.9.png 0 → 100644

378 Bytes

app/src/main/res/drawable-xxhdpi/cnlive_icon_chat_gift.png 0 → 100644

20.8 KB

app/src/main/res/drawable-xxhdpi/cnlive_video_pause.png 0 → 100644

3.15 KB

app/src/main/res/drawable-xxhdpi/cnlive_video_play.png 0 → 100644

6.41 KB

app/src/main/res/drawable/cnlive_chat_gift_bg.xml 0 → 100644
  1 +++ a/app/src/main/res/drawable/cnlive_chat_gift_bg.xml
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<shape xmlns:android="http://schemas.android.com/apk/res/android"
  3 + android:shape="rectangle"
  4 + android:useLevel="false">
  5 + <solid android:color="#66000000" />
  6 + <size android:height="24dp" />
  7 + <corners
  8 + android:bottomLeftRadius="0dp"
  9 + android:bottomRightRadius="8dp"
  10 + android:topLeftRadius="0dp"
  11 + android:topRightRadius="8dp" /> <!-- 设置四个角的半径 -->
  12 +
  13 +</shape>
0 14 \ No newline at end of file
... ...
app/src/main/res/drawable/cnlive_chat_icon_bg.xml 0 → 100644
  1 +++ a/app/src/main/res/drawable/cnlive_chat_icon_bg.xml
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +
  3 +<shape xmlns:android="http://schemas.android.com/apk/res/android">
  4 + <corners android:radius="80dp" />
  5 + <solid android:color="#ffffff" />
  6 + <stroke
  7 + android:width="2dp"
  8 + android:color="#ffd500" />
  9 + <size
  10 + android:width="80dp"
  11 + android:height="80dp" />
  12 +</shape>
0 13 \ No newline at end of file
... ...
app/src/main/res/drawable/cnlive_video_seekbar.xml 0 → 100644
  1 +++ a/app/src/main/res/drawable/cnlive_video_seekbar.xml
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
  3 +
  4 + <item android:id="@android:id/background">
  5 + <shape>
  6 + <corners android:radius="2dip" />
  7 + <solid android:color="#efefef" />
  8 + </shape>
  9 + </item>
  10 +
  11 + <item android:id="@android:id/secondaryProgress">
  12 + <scale android:scaleWidth="100%">
  13 + <shape>
  14 + <corners android:radius="2dip" />
  15 + <solid android:color="#50000000" />
  16 + </shape>
  17 + </scale>
  18 +
  19 + </item>
  20 +
  21 + <item android:id="@android:id/progress">
  22 + <clip>
  23 + <scale android:scaleWidth="100%">
  24 + <shape>
  25 + <corners android:radius="2dip" />
  26 + <solid android:color="#ff4e51" />
  27 + </shape>
  28 + </scale>
  29 + </clip>
  30 + </item>
  31 +
  32 +
  33 +</layer-list>
0 34 \ No newline at end of file
... ...
app/src/main/res/drawable/cnlive_video_seekbar_progress.xml 0 → 100644
  1 +++ a/app/src/main/res/drawable/cnlive_video_seekbar_progress.xml
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<shape xmlns:android="http://schemas.android.com/apk/res/android"
  3 + android:shape="rectangle">
  4 + <solid android:color="#ffffff" />
  5 + <corners android:radius="12dp" />
  6 + <stroke
  7 + android:width="4dp"
  8 + android:color="#2fffffff" />
  9 + <size
  10 + android:width="24dp"
  11 + android:height="24dp" />
  12 +</shape>
0 13 \ No newline at end of file
... ...
app/src/main/res/layout/activity_barrage.xml 0 → 100644
  1 +++ a/app/src/main/res/layout/activity_barrage.xml
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + android:layout_width="match_parent"
  4 + android:layout_height="match_parent">
  5 +
  6 + <com.cnlive.libs.video.barrage.BarrageLayout
  7 + android:id="@+id/barrage"
  8 + android:layout_width="match_parent"
  9 + android:layout_height="wrap_content"
  10 + android:background="#ff777757" />
  11 + <com.cnlive.libs.video.barrage.BarrageLayout
  12 + android:id="@+id/barrage_gift"
  13 + android:layout_width="match_parent"
  14 + android:layout_height="wrap_content"
  15 + android:background="#ff577777"
  16 + android:layout_below="@+id/barrage"/>
  17 +
  18 + <Button
  19 + android:id="@+id/addMessage"
  20 + android:layout_width="wrap_content"
  21 + android:layout_height="wrap_content"
  22 + android:layout_alignParentRight="true"
  23 + android:text="addMessage" />
  24 +
  25 + <Button
  26 + android:id="@+id/addGiftMessage"
  27 + android:layout_width="wrap_content"
  28 + android:layout_height="wrap_content"
  29 + android:layout_alignParentRight="true"
  30 + android:layout_below="@+id/addMessage"
  31 + android:text="addGiftMessage" />
  32 +
  33 +</RelativeLayout>
0 34 \ No newline at end of file
... ...
app/src/main/res/layout/activity_cnplayer.xml 0 → 100644
  1 +++ a/app/src/main/res/layout/activity_cnplayer.xml
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + android:layout_width="match_parent"
  4 + android:layout_height="match_parent"
  5 + android:orientation="vertical">
  6 +
  7 + <RelativeLayout
  8 + android:layout_width="match_parent"
  9 + android:layout_height="260dp"
  10 + android:background="@android:color/black">
  11 +
  12 + <com.cnlive.libs.video.player.CNMediaPlayerView
  13 + android:id="@+id/cnPlayerView"
  14 + android:layout_width="match_parent"
  15 + android:layout_height="match_parent"
  16 + android:layout_centerInParent="true" />
  17 + </RelativeLayout>
  18 +
  19 + <RelativeLayout
  20 + android:id="@+id/mediaControllerBottomLayout"
  21 + android:layout_width="match_parent"
  22 + android:layout_height="58dp"
  23 + android:layout_alignParentBottom="true"
  24 + android:background="#88000000">
  25 +
  26 + <ImageView
  27 + android:id="@+id/playerPlayPause"
  28 + android:layout_width="30dp"
  29 + android:layout_height="30dp"
  30 + android:src="@drawable/cnlive_video_pause"
  31 + android:layout_centerVertical="true"/>
  32 +
  33 + <SeekBar
  34 + android:id="@+id/videoProgressBar"
  35 + android:layout_width="match_parent"
  36 + android:layout_height="wrap_content"
  37 + android:layout_centerVertical="true"
  38 + android:layout_toRightOf="@+id/playerPlayPause"
  39 + android:maxHeight="4dp"
  40 + android:minHeight="4dp"
  41 + android:layout_toLeftOf="@+id/time"
  42 + android:progressDrawable="@drawable/cnlive_video_seekbar"
  43 + android:thumb="@drawable/cnlive_video_seekbar_progress"
  44 + android:layout_marginRight="8dp"
  45 + android:layout_marginLeft="8dp"
  46 + android:thumbOffset="0dip"/>
  47 +
  48 + <TextView
  49 + android:id="@+id/time"
  50 + android:layout_width="wrap_content"
  51 + android:layout_height="wrap_content"
  52 + android:layout_marginBottom="8dp"
  53 + android:text="00:00:00"
  54 + android:layout_marginRight="10dp"
  55 + android:textSize="16sp"
  56 + android:textColor="#ffffff"
  57 + android:layout_alignParentRight="true"
  58 + android:layout_centerVertical="true"/>
  59 +
  60 + </RelativeLayout>
  61 +
  62 +</RelativeLayout>
0 63 \ No newline at end of file
... ...
app/src/main/res/layout/activity_main.xml 0 → 100644
  1 +++ a/app/src/main/res/layout/activity_main.xml
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + xmlns:tools="http://schemas.android.com/tools"
  4 + android:layout_width="match_parent"
  5 + android:layout_height="match_parent"
  6 + android:paddingBottom="@dimen/activity_vertical_margin"
  7 + android:paddingLeft="@dimen/activity_horizontal_margin"
  8 + android:paddingRight="@dimen/activity_horizontal_margin"
  9 + android:paddingTop="@dimen/activity_vertical_margin"
  10 + tools:context="com.cnlive.demo.video.MainActivity">
  11 +
  12 + <Button
  13 + android:id="@+id/play"
  14 + android:layout_width="wrap_content"
  15 + android:layout_height="wrap_content"
  16 + android:text="播放普通视频" />
  17 +
  18 + <Button
  19 + android:id="@+id/playCnlive"
  20 + android:layout_width="wrap_content"
  21 + android:layout_height="wrap_content"
  22 + android:text="播放视讯云视频"
  23 + android:layout_below="@+id/play"/>
  24 +
  25 + <EditText
  26 + android:id="@+id/activedId"
  27 + android:layout_width="match_parent"
  28 + android:layout_height="50dp"
  29 + android:layout_toRightOf="@+id/playCnlive"
  30 + android:layout_alignBottom="@+id/playCnlive"/>
  31 +
  32 + <Button
  33 + android:id="@+id/barrageBtn"
  34 + android:layout_width="wrap_content"
  35 + android:layout_height="wrap_content"
  36 + android:text="弹幕"
  37 + android:layout_below="@+id/playCnlive"/>
  38 +</RelativeLayout>
... ...
app/src/main/res/layout/cnlive_view_chat_barrage.xml 0 → 100644
  1 +++ a/app/src/main/res/layout/cnlive_view_chat_barrage.xml
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + xmlns:tools="http://schemas.android.com/tools"
  4 + android:id="@+id/chat_item_bg"
  5 + android:layout_width="wrap_content"
  6 + android:layout_height="wrap_content"
  7 + android:layout_marginTop="8dp">
  8 +
  9 + <com.cnlive.libs.util.ui.emojicon.EmojiconTextView
  10 + android:id="@+id/chat_item_name"
  11 + android:layout_width="wrap_content"
  12 + android:layout_height="wrap_content"
  13 + android:layout_centerVertical="true"
  14 + android:ellipsize="end"
  15 + android:maxEms="6"
  16 + android:singleLine="true"
  17 + android:padding="4dp"
  18 + android:textColor="#FF0000"
  19 + android:textSize="15sp"
  20 + tools:text="Name:" />
  21 +
  22 + <com.cnlive.libs.util.ui.emojicon.EmojiconTextView
  23 + android:id="@+id/chat_item_message"
  24 + android:layout_width="wrap_content"
  25 + android:layout_height="wrap_content"
  26 + android:layout_centerVertical="true"
  27 + android:padding="4dp"
  28 + android:layout_toRightOf="@id/chat_item_name"
  29 + android:singleLine="true"
  30 + android:textColor="#ffffff"
  31 + android:textSize="15sp"
  32 + tools:text="Message" />
  33 +
  34 +
  35 +</RelativeLayout>
0 36 \ No newline at end of file
... ...
app/src/main/res/layout/cnlive_view_chat_gift.xml 0 → 100644
  1 +++ a/app/src/main/res/layout/cnlive_view_chat_gift.xml
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
  3 + xmlns:tools="http://schemas.android.com/tools"
  4 + android:id="@+id/chat_item_bg"
  5 + android:layout_width="wrap_content"
  6 + android:layout_height="wrap_content">
  7 +
  8 +
  9 + <RelativeLayout
  10 + android:id="@+id/msg_layout"
  11 + android:layout_width="wrap_content"
  12 + android:layout_height="wrap_content"
  13 + android:layout_alignBottom="@+id/chat_item_image"
  14 + android:layout_alignLeft="@+id/chat_item_image"
  15 + android:layout_alignTop="@+id/chat_item_image"
  16 + android:layout_marginBottom="2dp"
  17 + android:layout_marginLeft="21dp"
  18 + android:layout_marginTop="2dp"
  19 + android:background="@drawable/cnlive_chat_gift_bg"
  20 + android:paddingRight="8dp">
  21 +
  22 + <com.cnlive.libs.util.ui.emojicon.EmojiconTextView
  23 + android:id="@+id/chat_item_name"
  24 + android:layout_width="wrap_content"
  25 + android:layout_height="wrap_content"
  26 + android:layout_marginLeft="28dp"
  27 + android:layout_marginRight="48dp"
  28 + android:layout_marginTop="6dp"
  29 +
  30 + android:ellipsize="end"
  31 + android:maxEms="6"
  32 + android:singleLine="true"
  33 + android:textColor="#39f0dd"
  34 + android:textSize="12sp"
  35 + tools:text="Nmae" />
  36 +
  37 +
  38 + <com.cnlive.libs.util.ui.emojicon.EmojiconTextView
  39 + android:id="@+id/chat_item_message"
  40 + android:layout_width="wrap_content"
  41 + android:layout_height="wrap_content"
  42 + android:layout_alignParentBottom="true"
  43 + android:layout_marginBottom="6dp"
  44 + android:layout_marginLeft="28dp"
  45 + android:ellipsize="end"
  46 + android:singleLine="true"
  47 + android:textColor="#fbdb44"
  48 + android:textSize="12sp"
  49 + tools:text="Message" />
  50 +
  51 + </RelativeLayout>
  52 +
  53 +
  54 + <ImageView
  55 + android:id="@+id/chat_item_image"
  56 + android:layout_width="48dp"
  57 + android:layout_height="48dp"
  58 + android:layout_marginTop="8dp"
  59 + android:background="@drawable/cnlive_chat_icon_bg"
  60 + android:padding="2dp"/>
  61 +
  62 + <ImageView
  63 + android:id="@+id/chat_item_gift"
  64 + android:layout_width="36dp"
  65 + android:layout_height="36dp"
  66 + android:layout_alignRight="@+id/msg_layout"
  67 + android:layout_marginRight="8dp"
  68 + tools:src="@drawable/cnlive_icon_chat_gift" />
  69 +
  70 +
  71 +</RelativeLayout>
0 72 \ No newline at end of file
... ...
app/src/main/res/mipmap-hdpi/ic_launcher.png 0 → 100644

3.34 KB

app/src/main/res/mipmap-mdpi/ic_launcher.png 0 → 100644

2.15 KB

app/src/main/res/mipmap-xhdpi/ic_launcher.png 0 → 100644

4.73 KB

app/src/main/res/mipmap-xxhdpi/ic_launcher.png 0 → 100644

7.54 KB

app/src/main/res/mipmap-xxxhdpi/ic_launcher.png 0 → 100644

10.2 KB

app/src/main/res/values-w820dp/dimens.xml 0 → 100644
  1 +++ a/app/src/main/res/values-w820dp/dimens.xml
  1 +<resources>
  2 + <!-- Example customization of dimensions originally defined in res/values/dimens.xml
  3 + (such as screen margins) for screens with more than 820dp of available width. This
  4 + would include 7" and 10" devices in landscape (~960dp and ~1280dp respectively). -->
  5 + <dimen name="activity_horizontal_margin">64dp</dimen>
  6 +</resources>
... ...
app/src/main/res/values/colors.xml 0 → 100644
  1 +++ a/app/src/main/res/values/colors.xml
  1 +<?xml version="1.0" encoding="utf-8"?>
  2 +<resources>
  3 + <color name="colorPrimary">#3F51B5</color>
  4 + <color name="colorPrimaryDark">#303F9F</color>
  5 + <color name="colorAccent">#FF4081</color>
  6 +</resources>
... ...
app/src/main/res/values/dimens.xml 0 → 100644
  1 +++ a/app/src/main/res/values/dimens.xml
  1 +<resources>
  2 + <!-- Default screen margins, per the Android Design guidelines. -->
  3 + <dimen name="activity_horizontal_margin">16dp</dimen>
  4 + <dimen name="activity_vertical_margin">16dp</dimen>
  5 +</resources>
... ...
app/src/main/res/values/strings.xml 0 → 100644
  1 +++ a/app/src/main/res/values/strings.xml
  1 +<resources>
  2 + <string name="app_name">CNLiveVideoDemo</string>
  3 +</resources>
... ...
app/src/main/res/values/styles.xml 0 → 100644
  1 +++ a/app/src/main/res/values/styles.xml
  1 +<resources>
  2 +
  3 + <!-- Base application theme. -->
  4 + <style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
  5 + <!-- Customize your theme here. -->
  6 + <item name="colorPrimary">@color/colorPrimary</item>
  7 + <item name="colorPrimaryDark">@color/colorPrimaryDark</item>
  8 + <item name="colorAccent">@color/colorAccent</item>
  9 + </style>
  10 +
  11 +</resources>
... ...
app/src/test/java/com/cnlive/demo/video/ExampleUnitTest.java 0 → 100644
  1 +++ a/app/src/test/java/com/cnlive/demo/video/ExampleUnitTest.java
  1 +package com.cnlive.demo.video;
  2 +
  3 +import org.junit.Test;
  4 +
  5 +import static org.junit.Assert.*;
  6 +
  7 +/**
  8 + * To work on unit tests, switch the Test Artifact in the Build Variants view.
  9 + */
  10 +public class ExampleUnitTest {
  11 + @Test
  12 + public void addition_isCorrect() throws Exception {
  13 + assertEquals(4, 2 + 2);
  14 + }
  15 +}
0 16 \ No newline at end of file
... ...
build.gradle 0 → 100644
  1 +++ a/build.gradle
  1 +// Top-level build file where you can add configuration options common to all sub-projects/modules.
  2 +
  3 +buildscript {
  4 + repositories {
  5 + jcenter()
  6 + }
  7 + dependencies {
  8 + classpath 'com.android.tools.build:gradle:2.1.2'
  9 +
  10 + // NOTE: Do not place your application dependencies here; they belong
  11 + // in the individual module build.gradle files
  12 + }
  13 +}
  14 +
  15 +allprojects {
  16 + repositories {
  17 + jcenter()
  18 + }
  19 +}
  20 +
  21 +task clean(type: Delete) {
  22 + delete rootProject.buildDir
  23 +}
... ...
gradle.properties 0 → 100644
  1 +++ a/gradle.properties
  1 +# Project-wide Gradle settings.
  2 +
  3 +# IDE (e.g. Android Studio) users:
  4 +# Gradle settings configured through the IDE *will override*
  5 +# any settings specified in this file.
  6 +
  7 +# For more details on how to configure your build environment visit
  8 +# http://www.gradle.org/docs/current/userguide/build_environment.html
  9 +
  10 +# Specifies the JVM arguments used for the daemon process.
  11 +# The setting is particularly useful for tweaking memory settings.
  12 +# Default value: -Xmx10248m -XX:MaxPermSize=256m
  13 +# org.gradle.jvmargs=-Xmx2048m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
  14 +
  15 +# When configured, Gradle will run in incubating parallel mode.
  16 +# This option should only be used with decoupled projects. More details, visit
  17 +# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
  18 +# org.gradle.parallel=true
0 19 \ No newline at end of file
... ...
gradle/wrapper/gradle-wrapper.jar 0 → 100644
No preview for this file type
gradle/wrapper/gradle-wrapper.properties 0 → 100644
  1 +++ a/gradle/wrapper/gradle-wrapper.properties
  1 +#Mon Dec 28 10:00:20 PST 2015
  2 +distributionBase=GRADLE_USER_HOME
  3 +distributionPath=wrapper/dists
  4 +zipStoreBase=GRADLE_USER_HOME
  5 +zipStorePath=wrapper/dists
  6 +distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
... ...
gradlew 0 → 100644
  1 +++ a/gradlew
  1 +#!/usr/bin/env bash
  2 +
  3 +##############################################################################
  4 +##
  5 +## Gradle start up script for UN*X
  6 +##
  7 +##############################################################################
  8 +
  9 +# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
  10 +DEFAULT_JVM_OPTS=""
  11 +
  12 +APP_NAME="Gradle"
  13 +APP_BASE_NAME=`basename "$0"`
  14 +
  15 +# Use the maximum available, or set MAX_FD != -1 to use that value.
  16 +MAX_FD="maximum"
  17 +
  18 +warn ( ) {
  19 + echo "$*"
  20 +}
  21 +
  22 +die ( ) {
  23 + echo
  24 + echo "$*"
  25 + echo
  26 + exit 1
  27 +}
  28 +
  29 +# OS specific support (must be 'true' or 'false').
  30 +cygwin=false
  31 +msys=false
  32 +darwin=false
  33 +case "`uname`" in
  34 + CYGWIN* )
  35 + cygwin=true
  36 + ;;
  37 + Darwin* )
  38 + darwin=true
  39 + ;;
  40 + MINGW* )
  41 + msys=true
  42 + ;;
  43 +esac
  44 +
  45 +# Attempt to set APP_HOME
  46 +# Resolve links: $0 may be a link
  47 +PRG="$0"
  48 +# Need this for relative symlinks.
  49 +while [ -h "$PRG" ] ; do
  50 + ls=`ls -ld "$PRG"`
  51 + link=`expr "$ls" : '.*-> \(.*\)$'`
  52 + if expr "$link" : '/.*' > /dev/null; then
  53 + PRG="$link"
  54 + else
  55 + PRG=`dirname "$PRG"`"/$link"
  56 + fi
  57 +done
  58 +SAVED="`pwd`"
  59 +cd "`dirname \"$PRG\"`/" >/dev/null
  60 +APP_HOME="`pwd -P`"
  61 +cd "$SAVED" >/dev/null
  62 +
  63 +CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
  64 +
  65 +# Determine the Java command to use to start the JVM.
  66 +if [ -n "$JAVA_HOME" ] ; then
  67 + if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
  68 + # IBM's JDK on AIX uses strange locations for the executables
  69 + JAVACMD="$JAVA_HOME/jre/sh/java"
  70 + else
  71 + JAVACMD="$JAVA_HOME/bin/java"
  72 + fi
  73 + if [ ! -x "$JAVACMD" ] ; then
  74 + die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
  75 +
  76 +Please set the JAVA_HOME variable in your environment to match the
  77 +location of your Java installation."
  78 + fi
  79 +else
  80 + JAVACMD="java"
  81 + which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
  82 +
  83 +Please set the JAVA_HOME variable in your environment to match the
  84 +location of your Java installation."
  85 +fi
  86 +
  87 +# Increase the maximum file descriptors if we can.
  88 +if [ "$cygwin" = "false" -a "$darwin" = "false" ] ; then
  89 + MAX_FD_LIMIT=`ulimit -H -n`
  90 + if [ $? -eq 0 ] ; then
  91 + if [ "$MAX_FD" = "maximum" -o "$MAX_FD" = "max" ] ; then
  92 + MAX_FD="$MAX_FD_LIMIT"
  93 + fi
  94 + ulimit -n $MAX_FD
  95 + if [ $? -ne 0 ] ; then
  96 + warn "Could not set maximum file descriptor limit: $MAX_FD"
  97 + fi
  98 + else
  99 + warn "Could not query maximum file descriptor limit: $MAX_FD_LIMIT"
  100 + fi
  101 +fi
  102 +
  103 +# For Darwin, add options to specify how the application appears in the dock
  104 +if $darwin; then
  105 + GRADLE_OPTS="$GRADLE_OPTS \"-Xdock:name=$APP_NAME\" \"-Xdock:icon=$APP_HOME/media/gradle.icns\""
  106 +fi
  107 +
  108 +# For Cygwin, switch paths to Windows format before running java
  109 +if $cygwin ; then
  110 + APP_HOME=`cygpath --path --mixed "$APP_HOME"`
  111 + CLASSPATH=`cygpath --path --mixed "$CLASSPATH"`
  112 + JAVACMD=`cygpath --unix "$JAVACMD"`
  113 +
  114 + # We build the pattern for arguments to be converted via cygpath
  115 + ROOTDIRSRAW=`find -L / -maxdepth 1 -mindepth 1 -type d 2>/dev/null`
  116 + SEP=""
  117 + for dir in $ROOTDIRSRAW ; do
  118 + ROOTDIRS="$ROOTDIRS$SEP$dir"
  119 + SEP="|"
  120 + done
  121 + OURCYGPATTERN="(^($ROOTDIRS))"
  122 + # Add a user-defined pattern to the cygpath arguments
  123 + if [ "$GRADLE_CYGPATTERN" != "" ] ; then
  124 + OURCYGPATTERN="$OURCYGPATTERN|($GRADLE_CYGPATTERN)"
  125 + fi
  126 + # Now convert the arguments - kludge to limit ourselves to /bin/sh
  127 + i=0
  128 + for arg in "$@" ; do
  129 + CHECK=`echo "$arg"|egrep -c "$OURCYGPATTERN" -`
  130 + CHECK2=`echo "$arg"|egrep -c "^-"` ### Determine if an option
  131 +
  132 + if [ $CHECK -ne 0 ] && [ $CHECK2 -eq 0 ] ; then ### Added a condition
  133 + eval `echo args$i`=`cygpath --path --ignore --mixed "$arg"`
  134 + else
  135 + eval `echo args$i`="\"$arg\""
  136 + fi
  137 + i=$((i+1))
  138 + done
  139 + case $i in
  140 + (0) set -- ;;
  141 + (1) set -- "$args0" ;;
  142 + (2) set -- "$args0" "$args1" ;;
  143 + (3) set -- "$args0" "$args1" "$args2" ;;
  144 + (4) set -- "$args0" "$args1" "$args2" "$args3" ;;
  145 + (5) set -- "$args0" "$args1" "$args2" "$args3" "$args4" ;;
  146 + (6) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" ;;
  147 + (7) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" ;;
  148 + (8) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" ;;
  149 + (9) set -- "$args0" "$args1" "$args2" "$args3" "$args4" "$args5" "$args6" "$args7" "$args8" ;;
  150 + esac
  151 +fi
  152 +
  153 +# Split up the JVM_OPTS And GRADLE_OPTS values into an array, following the shell quoting and substitution rules
  154 +function splitJvmOpts() {
  155 + JVM_OPTS=("$@")
  156 +}
  157 +eval splitJvmOpts $DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS
  158 +JVM_OPTS[${#JVM_OPTS[*]}]="-Dorg.gradle.appname=$APP_BASE_NAME"
  159 +
  160 +exec "$JAVACMD" "${JVM_OPTS[@]}" -classpath "$CLASSPATH" org.gradle.wrapper.GradleWrapperMain "$@"
... ...
gradlew.bat 0 → 100644
  1 +++ a/gradlew.bat
  1 +@if "%DEBUG%" == "" @echo off
  2 +@rem ##########################################################################
  3 +@rem
  4 +@rem Gradle startup script for Windows
  5 +@rem
  6 +@rem ##########################################################################
  7 +
  8 +@rem Set local scope for the variables with windows NT shell
  9 +if "%OS%"=="Windows_NT" setlocal
  10 +
  11 +@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
  12 +set DEFAULT_JVM_OPTS=
  13 +
  14 +set DIRNAME=%~dp0
  15 +if "%DIRNAME%" == "" set DIRNAME=.
  16 +set APP_BASE_NAME=%~n0
  17 +set APP_HOME=%DIRNAME%
  18 +
  19 +@rem Find java.exe
  20 +if defined JAVA_HOME goto findJavaFromJavaHome
  21 +
  22 +set JAVA_EXE=java.exe
  23 +%JAVA_EXE% -version >NUL 2>&1
  24 +if "%ERRORLEVEL%" == "0" goto init
  25 +
  26 +echo.
  27 +echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
  28 +echo.
  29 +echo Please set the JAVA_HOME variable in your environment to match the
  30 +echo location of your Java installation.
  31 +
  32 +goto fail
  33 +
  34 +:findJavaFromJavaHome
  35 +set JAVA_HOME=%JAVA_HOME:"=%
  36 +set JAVA_EXE=%JAVA_HOME%/bin/java.exe
  37 +
  38 +if exist "%JAVA_EXE%" goto init
  39 +
  40 +echo.
  41 +echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
  42 +echo.
  43 +echo Please set the JAVA_HOME variable in your environment to match the
  44 +echo location of your Java installation.
  45 +
  46 +goto fail
  47 +
  48 +:init
  49 +@rem Get command-line arguments, handling Windowz variants
  50 +
  51 +if not "%OS%" == "Windows_NT" goto win9xME_args
  52 +if "%@eval[2+2]" == "4" goto 4NT_args
  53 +
  54 +:win9xME_args
  55 +@rem Slurp the command line arguments.
  56 +set CMD_LINE_ARGS=
  57 +set _SKIP=2
  58 +
  59 +:win9xME_args_slurp
  60 +if "x%~1" == "x" goto execute
  61 +
  62 +set CMD_LINE_ARGS=%*
  63 +goto execute
  64 +
  65 +:4NT_args
  66 +@rem Get arguments from the 4NT Shell from JP Software
  67 +set CMD_LINE_ARGS=%$
  68 +
  69 +:execute
  70 +@rem Setup the command line
  71 +
  72 +set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
  73 +
  74 +@rem Execute Gradle
  75 +"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
  76 +
  77 +:end
  78 +@rem End local scope for the variables with windows NT shell
  79 +if "%ERRORLEVEL%"=="0" goto mainEnd
  80 +
  81 +:fail
  82 +rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
  83 +rem the _cmd.exe /c_ return code!
  84 +if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
  85 +exit /b 1
  86 +
  87 +:mainEnd
  88 +if "%OS%"=="Windows_NT" endlocal
  89 +
  90 +:omega
... ...
settings.gradle 0 → 100644
  1 +++ a/settings.gradle
  1 +include ':app'
... ...