Skip to content

Instantly share code, notes, and snippets.

View iamcxa's full-sized avatar
🎯
Focusing

Kent Chen iamcxa

🎯
Focusing
View GitHub Profile
@iamcxa
iamcxa / 0_reuse_code.js
Created December 25, 2015 07:26
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@iamcxa
iamcxa / MainActivity.java
Created November 9, 2016 17:43
RTSP player with screen capture sample
import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.SurfaceTexture;
import android.media.MediaPlayer;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.Surface;
import android.view.TextureView;
@iamcxa
iamcxa / activity_main.xml
Created November 9, 2016 17:45
RTSP player with screen capture
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@iamcxa
iamcxa / activity_main.xml
Created November 9, 2016 17:46
RTSP Player using VideoView
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/LinearLayout1"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<EditText
android:id="@+id/editText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
@iamcxa
iamcxa / MainActivity.java
Last active November 9, 2016 17:47
RTSP Player using VideoView
package rtsp.example.com.rtspsample;
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.EditText;
import android.widget.VideoView;
public class MainActivity extends Activity implements OnClickListener {
@iamcxa
iamcxa / storeImage.java
Created November 9, 2016 17:49
How to store a bitmap into file
private void storeImage(Bitmap image) {
File pictureFile = getOutputMediaFile();
if (pictureFile == null) {
Log.d(TAG,
"Error creating media file, check storage permissions: ");// e.getMessage());
return;
}
try {
FileOutputStream fos = new FileOutputStream(pictureFile);
image.compress(Bitmap.CompressFormat.PNG, 90, fos);
@iamcxa
iamcxa / getExternalStorageDirectory.java
Created November 9, 2016 17:50
How to get your SDcard path by using Environment
Environment.getExternalStorageDirectory()
+ "/Android/data/"
+ getApplicationContext().getPackageName()
+ "/Files"
/** Create a File for saving an image or video */
private File getOutputMediaFile(){
// To be safe, you should check that the SDCard is mounted
// using Environment.getExternalStorageState() before doing this.
// p.s: MODIFY THE PATH YOU WANT YOUR IMAGE TO STORE HERE
// 嗨嗨如果你想改儲存路徑記得改這邊
// for example, you can just using this way to save image into the root of sdcard
// File mediaStorageDir = new File(Environment.getExternalStorageDirectory().toString());
File mediaStorageDir = new File(Environment.getExternalStorageDirectory()
+ "/Android/data/"
//rootProject.file(): 取得根目錄中的檔案
def ksFile = rootProject.file('keystore.properties')
def props = new Properties();
if (ksFile.canRead()) {
props.load(new FileInputStream(ksFile))
if (props != null) {
android.signingConfigs.sign.storeFile file(props['KEYSTORE_FILE'])
android.signingConfigs.sign.storePassword props['KEYSTORE_PASSWORD']
android.signingConfigs.sign.keyAlias props['KEYSTORE_ALIAS']
android.signingConfigs.sign.keyPassword props['KEYSTORE_ALIAS_PASSWORD']
@iamcxa
iamcxa / control.js
Created November 9, 2016 18:48
Let stream video rotation and zoom in/out
/* predefine zoom and rotate */
var zoomScale = 1;
var rotate = 0;
var videocontrols = (function () {
console.log("VIDCONTROL START");
var css =
'#video-container{background:#eee;width:480px;height:360px;overflow:hidden;position:relative;}' +
'#ideo-container span{font-size:20px;color:#666;display:block;padding:2em;}' +
'video{width:480px;height:360px;position:absolute;top:0;left:0;}' +
'change button{width:50px;border:none;background:#333;color:wheat;}';