Skip to content

Instantly share code, notes, and snippets.

View niusounds's full-sized avatar
🤘

Yuya Matsuo niusounds

🤘
View GitHub Profile
@niusounds
niusounds / Gear VRデモ用端末のセットアップ手順.md
Last active December 2, 2015 05:12
開発したGear VRアプリをOculus Storeを使わず独自に配布する場合、イベントで展示する場合などにすること。

Gear VRを使えるようにするための設定

  1. 電源を入れる。
  2. 適当に初期設定をする。アカウント作成などはしない。Googleアカウントも不要。
  3. Wi-Fiに接続する。
  4. 端末をGear VRに接続する。そしてすぐ外す。
  5. Gear VRセットアップを行う。適当に同意しつつ必要なアプリをインストールする。Oculusアカウントのセットアップまで来たら、終了して良い

Gear VR用アプリをビルドする

@niusounds
niusounds / GearVRVideoPlayer.cs
Created March 11, 2016 12:12
GearVRVideoPlayer.csを反転球のオブジェクトに付けて、動画のパスを指定する。
using UnityEngine;
using System;
using System.Collections;
using System.Runtime.InteropServices;
public class VideoPlayer: MonoBehaviour {
public string videoPath;
public bool autoPlay = true;
@niusounds
niusounds / BufferedData.java
Last active July 20, 2016 09:38
細切れの配列データを少しずつ書き込み、バッファがいっぱいになったときに通知を受けるクラス。
public class BufferedData {
public interface OnBufferFilledListener {
void onBufferFilled(float[] buffer);
}
private final float[][] buffers;
private int currentBufferIndex;
private int indexInCurrentBuffer;
private OnBufferFilledListener listener;
@niusounds
niusounds / angular-js-tree.js
Created December 16, 2016 09:02
Use jsTree as a component for Angular 1.
angular.module('jsTree', [])
.component('jsTree', {
template: '<div id="js-tree"></div>',
bindings: {
core: '<',
pluginsConf: '<',
plugins: '<',
onInit: '&',
onLoading: '&',
onLoaded: '&',
@niusounds
niusounds / MainActivity.java
Created December 26, 2016 05:04
Using Rajawali (and AndroidAnnotations) to play 360 video.
import android.app.Activity;
import android.media.MediaPlayer;
import org.androidannotations.annotations.AfterViews;
import org.androidannotations.annotations.Bean;
import org.androidannotations.annotations.EActivity;
import org.androidannotations.annotations.ViewById;
import org.rajawali3d.view.SurfaceView;
import java.io.IOException;
@niusounds
niusounds / MainActivity.java
Last active March 9, 2017 11:12
Minimum ExoPlayer video playing
import android.app.Activity;
import android.net.Uri;
import android.os.Bundle;
import android.os.Handler;
import android.support.annotation.Nullable;
import android.view.SurfaceView;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.DefaultLoadControl;
import com.google.android.exoplayer2.ExoPlayerFactory;
@niusounds
niusounds / GvrArmModel.java
Last active August 7, 2017 05:08
Google VR Arm model in Java. It requires JOML.
import org.joml.Quaternionf;
import org.joml.Vector3f;
/**
* Arm model from https://github.com/EpicGames/UnrealEngine/tree/release/Engine/Plugins/Runtime/GoogleVR/GoogleVRController/Source/GoogleVRController/Private/ArmModel
*/
public class GvrArmModel {
private static final Vector3f FORWARD = new Vector3f(0.0f, 0.0f, -1.0f);
private static final Vector3f UP = new Vector3f(0.0f, 1.0f, 0.0f);
@niusounds
niusounds / AudioInputStream.kt
Last active March 31, 2024 17:22
AudioInputStream and AudioOutputStream for Android. These wrap AudioRecord and AudioTrack.
import android.media.AudioFormat
import android.media.AudioRecord
import android.media.MediaRecorder
import java.io.IOException
import java.io.InputStream
class AudioInputStream(
audioSource: Int = MediaRecorder.AudioSource.DEFAULT,
sampleRate: Int = 44100,
channelConfig: Int = AudioFormat.CHANNEL_IN_MONO,
@niusounds
niusounds / RingBuffer.kt
Last active June 6, 2025 19:33
RingBuffer in Kotlin
class RingBuffer(val capacity: Int) {
private val storage = ByteArray(capacity)
/**
* Convenient version of [read].
* This method allocates new array every time. Do not use this in heavy loop.
*
* @param startPosition Start position. Can be over than capacity.
* @param size Result data size.
@niusounds
niusounds / 1 IPlayer.kt
Created December 6, 2017 07:06
Player interface abstracts MediaPlayer and ExoPlayer.
import android.content.Context
import android.graphics.SurfaceTexture
import android.net.Uri
import android.view.Surface
interface IPlayer {
/**
* コンテンツの全体時間を取得する。単位はミリ秒。
*/