> For the complete documentation index, see [llms.txt](https://catenoid-support.gitbook.io/kollus-dev-jp/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://catenoid-support.gitbook.io/kollus-dev-jp/kollus-vg-controller.md).

# Kollus VG Controller

\*Latest version 1.2.4

## 概要

Kollus VG Controllerは、Videogatewayから提供されるメディアの一部のコントロールを顧客のウェブサイト内で実装できるようにサポートするJavaScriptライブラリです。Kollus VG Controllerには次の特徴があります。

* Videogatewayで自動的に実行されるプレーヤータイプに関係なく、同じコードで制御できます。
* 簡単なインストールと使い方
* プレーヤーの検出や実行について心配する必要がありません。
* サードパーティのJavaScriptライブラリは必要ありません。

> メソッドとイベントリストの隣に表示されるV2、V3、V4 Playerなどは、該当のメソッドやイベントをサポートするプレーヤーを示します。
>
> * V2：通常、暗号化されたファイルはV2 Playerを介して再生されます。V2 Playerは、IEの場合はActiveX、ChromeまたはFirefoxの場合はNPAPIを使用するプレーヤーです。
> * V3：暗号化されたファイルがEdgeまたはChromeの45バージョン以上のウェブブラウザから呼び出される場合、ハイブリッドHTML5プレーヤーが実行されます。
> * **V4：暗号化されていないファイルの場合、HTML5プレーヤーが実行されます。**
> * 名前の横にプレーヤーが表示されない場合、それはすべてのプレーヤーが共通でその機能をサポートしていることを意味します。

### VgControllerClient

(顧客の html pageに挿入)

```html
...
<script src="/path/to/vg-controller-client.1.1.16.min.js"></script>
<script>
window.onload = function() {
    try {
        var controller = new VgControllerClient({
            target_window: document.getElementById('child').contentWindow
        });

        // ここからイベントリスナーを登録するか、ウェブページElementにメソッドをbindします。
    } catch(e) {
        // Videogateweay Controller Libraryは window.postMessage APIを使用しないため、
        // 該当機能を対応しないウェブブラウザには動作しません。
        // この部分に適切な fail-over コードを追加してください。
        console.error(e);
    }
};
</script>
<body>
    <iframe id="child" src="http://v.jp..."></iframe>
</body>
...
```

* **VgControllerClient** 生成の際にパラメータで転送するtarget\_windowには、Webページに添付しているKollus Videogateway iframeのHTMLElementにcontentWindow属性を入力します。
* このスクリプトは**window\.postMessage API** を使ってPlayerとの通信を行うため、該当機能に対応していないブラウザでは動作しません。
* Web Page内部に複数のiframeをembedしている場合、制御するiframe毎に**VgControllerClient** を生成する必要があります。
* 以前バージョンとの互換性を考慮して(v0.5以前) **new VgControllerClient()**&#x306E;代わりに**new Kollus.VideogatewayController()**&#x3092;使用しても正常に動作します。
* try-catch文のException code listは以下のようになります。

| code | message                                          | description                    |
| ---- | ------------------------------------------------ | ------------------------------ |
| -1   | \*                                               | PostMessage API exception code |
| -99  | player type is not defined                       | Player typeが定義されてありありません。      |
| -99  | player type must be one of v2, v3, v4 and flash. | Player typeが正常なデータではありません。     |
| -99  | this browser does not support postMessage        | PostMessage APIに対応しないブラウザです。   |
| -99  | listener is not callable.                        | ベントリスナーが関数形ではありません。            |

## CDN

Vg-Controller Client LibraryをCDNで提供します。最新バージョンのライブラリを使用するには以下のリンクを挿入してください。

```
https://file.kollus.com/vgcontroller/vg-controller-client.latest.min.js
```

以前バージョンのライブラリを使用するにはlatestの代わりにバージョン名を入力してください。

```
https://file.kollus.com/vgcontroller/vg-controller-client.1.1.4.min.js
```

"Integrity属性を使用することで、VG-Controller Client Libraryの悪意のあるスクリプト変調を防ぐことができます。スクリプトを呼び出す際に、適切なバージョンのIntegrity属性値を追加してください。"

```html
<script src="https://file.kollus.com/vgcontroller/vg-controller-client.1.2.3.min.js" 
integrity="sha256-esUCCL4RPYMS8AR+Sl3lNrFa5M+zgpt4Gb77qtz66OY=" crossorigin="anonymous">
</script>
```

バージョン毎 Integrity属性値は 属性の値が必要な場合担当者にお問い合わせください。

## VR Contents (Mobile Device)

iframe内で呼び出される360 VRコンテンツの場合、AndroidおよびiOSデバイスで再生時に問題が発生します。Androidの場合、Orientation値が正しく適用されず、左右の方向が逆になります。iOSの場合、iOS 13以降、DeviceMotion権限を取得する必要があり、Gyroscopeが正常に動作するようになりますが、この権限はiframe内で取得できないため、正常に動作しません（iOS 13以前のバージョンではSafari設定から 'Motion & Orientation Access'オプションを直接変更する必要があります）

これらの問題を解決するには、VG-Controller 1.1.10以降をインストールする必要があり、VG-ControllerクライアントからDeviceMotionイベントを自動的に登録して、VG-Controllerサーバーと通信します（外部のiframeイベントを定期的に内部に転送します）

OSの場合、Controller.set\_vr\_overlay()メソッドを実行する必要があります。詳細については、下記のリファレンスの「メソッドリスト」の「set\_vr\_overlayメソッド」をご参照ください。

> **Known Issue**\
> iOS 13.4 バージョンでは権限を取得しても DeviceMotionの rotationRate値が正常に発生しないエラーが報告されています。

## Intent Scheme Call Bug (iframe in Android)

プレイヤーページがiframe内でVGを呼び出すように構成されている場合、一部のモバイルAndroidデバイスでは専用プレイヤー（Kollus Player App）が正しく実行されないことがあります。 （Androidデバイス環境では、Intent Schemeを使用して呼び出すように設定されていますが、Chromeブラウザの場合、‐iframeを使用すると正常に動作しないエラーが報告されています。） このような場合、VG-Controller 1.1.15以降を使用すると正常に動作します。

> 別途具現するコードはないので, VG-Controllerが環境を分析して自動分析し処理します。

### イベントリスニング <a href="#vgcontroller-ibentorisuningu" id="vgcontroller-ibentorisuningu"></a>

Playerのイベントが発生した際に使用者が定義したcallback関数を実行するためのイベントリスナー(EventListener)を登録する方法となります。

```javascript
controller.on('event_name', function(param) {
    // イベントリスナー
});
```

単一イベントに複数のリスナーを登録することができます。この場合、イベントが発生すると登録されている全てのリスナーが実行されます。

```javascript
controller.on('event_name', function(param) {
    // 1番目のリスナー
});
controller.on('event_name', function(param) {
    // 2番目のリスナー
});

// イベント発生の際に1番目、2番目リスナーが全て実行
// 但し、JAVA Scriptイベントループとcallback関数の実行方式によって
// リスナーが順番通りに実行されない可能性があります。
```

イベントリスナーを登録する関数である「on」 はメソッドチェイニング(Method chaining)に対応しています。

```javascript
controller.on('event_name_1', function(param) {
    // 1番目のリスナー
}).on('event_name_2', function(param) {
    // 2番目のリスナー
});
```

一つ以上のリスナーを登録した場合、イベント発生時に登録されたすべてのリスナーが実行されます、ただし、javascriptイベントループとcallback関数が実行する方法によって実行の順番が変わる可能性があります。

### イベントリスト

<table data-header-hidden data-full-width="true"><thead><tr><th width="120"></th><th width="622"></th><th width="99"></th><th></th></tr></thead><tbody><tr><td>イベントリスト </td><td>内容</td><td>プレイヤー</td><td>コード</td></tr><tr><td><strong>loaded</strong></td><td>プレイヤーのロードが完了すると、イベントが発生します</td><td>v3, v4</td><td><br></td></tr><tr><td><strong>ready</strong></td><td>プレイヤーのロードが終わり、再生情報をサーバーから取得し、実際の再生準備が完了した時点です</td><td>v3, v4</td><td></td></tr><tr><td><strong>play</strong></td><td>再生開始時に発生します。 初期再生開始を除き、一時停止状態で再再生を開始する場合も発生します。</td><td>v3, v4</td><td></td></tr><tr><td><strong>progress</strong></td><td><p>再生時に毎秒発生します。 ただし、HTML5 Video Playerの構造上、progressイベントが正確に1秒ごとに発生しないことがあります。 (0.1から最大0.5秒ほど差が出ることがあります。)progressイベントで実行する場合、この点に注意してください。</p><p></p><p><strong>Parameters:</strong></p><ul><li><strong>percent</strong> INTTERの進行パーセンテージです。 値の範囲は 0 &#x3C;= percent &#x3C;= 100 です</li><li><strong>position</strong> NUMBER現在再生中の位置の値です。 秒単位です。（小数点5桁まで）</li><li><strong>duration</strong> NUMBER動画の全再生長です。 秒単位です。（小数点5桁まで）</li></ul></td><td>v3, v4</td><td><p><br><br></p><p><code>controller.on('progress', function(percent, position, duration) { // 因子の順番は上記の通りです。</code></p><p> <code>});</code></p><p><br><br></p></td></tr><tr><td><strong>pause</strong></td><td>一時停止時に発生ｓいます。</td><td>v3, v4</td><td><br></td></tr><tr><td><strong>done</strong></td><td>再生完了時に発生します。 再生完了は、durationの最後まですべて再生した場合を意味します。.</td><td>v3, v4</td><td></td></tr><tr><td><strong>muted</strong> </td><td><p>ミュート状態が変更された場合に呼び出されます。 (音消去時、音消去解除時の両方発生)<br></p><p><strong>Parameters:</strong></p><ul><li><strong>is_muted</strong> BOOLEAN trueはミュート、falsはミュート解除</li></ul></td><td>v3, v4</td><td><p></p><p><code>controller.on('muted', function(is_muted) { // is_mutedが trueの場合ミュート、falseの場合ミュート解除 });</code></p></td></tr><tr><td><strong>seeking</strong></td><td>再生時点変更時呼び出します。</td><td> v4</td><td></td></tr><tr><td><strong>seeked</strong></td><td> <strong>再生時点変 再生時点変更が終わった場合呼び出します。</strong></td><td> v4</td><td></td></tr><tr><td><p><br><br></p><p><strong>screenchange</strong></p></td><td><p>全体、一般画面の変更時に発生します。 IE10 以下のブラウザの場合、enable_fullscreen_button()が 有効化されている状態であれば、fullscreenボタンをクリックすると、実際にfullscreen/windowed切り替えが行われませんが、screenchangeイベントは正常に返されます。 screenパラメータは、windowed、fullscreenの2つの文字列のうちの1つを提供します。</p><p></p><p><strong>Parameters:</strong></p><ul><li><strong>screen</strong> STRING windowedは一般画面、fullscreenは全体画面です。</li></ul></td><td>v3, v4</td><td><p><br><br></p><p><code>controller.on('screenchange', function(screen) { // ... });</code></p><p></p></td></tr><tr><td><strong>volumechange</strong></td><td><p>音量変更時発生します。</p><p><strong>Parameters:</strong></p><ul><li><strong>volume</strong> INTEGER変更された音量です。範囲は 0 &#x3C;= volume &#x3C;= 100です。</li></ul></td><td>v3, v4</td><td><p></p><p><code>controller.on('volumechange', function(volume) { // volumeの 範囲は 0 &#x3C;= volume &#x3C;= 100 です。 });</code><br></p></td></tr><tr><td><strong>speedchange</strong>  </td><td><p>倍速変更時発生します。倍速最大値はPlayerの設定ｎいよって変わることもあります。</p><p></p><p><strong>Parameters:</strong></p><ul><li><strong>speed</strong> STRING変更された倍速です。範囲は 0.5 &#x3C;= speed &#x3C;= 4 です。</li><li>Javascript言語の特性上、2.0は2と表記されるため、Integer型の代わりにString型を使用して提供します。</li></ul></td><td>v3, v4</td><td><p></p><p><code>controller.on('speedchange', function(speed) { // speedの範囲は 0.5 &#x3C;= speed &#x3C;= 4です。 });</code></p><p></p></td></tr><tr><td><strong>playbackrateschange</strong></td><td><p>倍速単位を設定する倍速値グループ変更時発生します。</p><p></p><p><strong>Parameters:</strong></p><ul><li><strong>playback_rates</strong> STRING変更された倍速値グループの文字列です。</li><li>単一配列 倍速値メニューが一行に並びます ex) [1, 2, 3]</li><li>二重配列 : 倍速値メニューが複数の行並びます。 ex) [[0.5, 1, 1.5, 2], 2]</li></ul></td><td>v3, v4</td><td><p></p><p><code>controller.on('playbackrateschange', function(playback_rates) { // playback_rates는 配列文字。 //一行配列または二重配列でリターン });</code></p></td></tr><tr><td><strong>videosettingchange</strong> </td><td><p>ビデオ属性の変更時に発生します。 ビデオ属性変更機能は、V2 Playerにのみの機能です。 他のPlayerではイベントを発生させません。 各値の範囲はすべて-50&#x3C;=value&#x3C;=50の範囲を持ちます。 ユーザが別途指定していない場合、デフォルト値は0入 です。<br></p><p><strong>Parameters:</strong></p><ul><li><strong>videosetting</strong> OBJECTbrightness(밝기), contrast, saturationを propertyで持つ objectです。</li></ul></td><td>v3</td><td><p></p><p><code>controller.on('videosettingchange', function(videosetting) { // videosetting パラメーターは以下の形態// 表示される Object タイプです。</code></p><p> <code>// // { // "brightness": 0, // "contrast": 0, // "saturation": 0 // } });</code></p></td></tr><tr><td><strong>jumpstepchange</strong></td><td><p>ff, rw メソッドを通じて移動する時間値変更時発生ｓいます。</p><p><strong>Parameters:</strong></p><ul><li><strong>jumpstep</strong> INTEGER変更された移動する時間値です。秒単位です。</li></ul></td><td>v3, v4</td><td><code>controller.on('jumpstepchange', function(jumpstep) { // jumpstepは秒単位です。 });</code><br></td></tr><tr><td><strong>subtitlevisibilitychange</strong> </td><td><p>字幕の画面出力状態が変更されると発生します。</p><p></p><p><strong>Parameters:</strong></p><ul><li><strong>visible</strong> BOOLEAN字幕画面出力可否状態です。</li></ul></td><td>v3, v4</td><td></td></tr><tr><td><strong>hlsfragchange</strong> </td><td>hlsの fragが変更時に発生します。</td><td>v4</td><td><br><br></td></tr><tr><td><strong>html5_video_supported</strong> </td><td><p>Playerが内部でHTML5 Video再生機能を使用できると判断し、HTML5 Video Playerをロードする場合は trueを、専用プレイヤーを再生する必要があると判断した場合はfalseをリターンします。(<a href="http://caniuse.com/#feat=video">http://caniuse.com/#feat=video</a>参考)</p><p></p><p><strong>Parameters:</strong></p><ul><li><strong>html5_video_supported</strong> BOOLEANPlayerが HTML5 Playerでロードされる場合true,専用プレイヤーでロードされる場合falseがリターン</li></ul></td><td>v3, v4</td><td></td></tr><tr><td><strong>error</strong></td><td><p>Playerが再生エラーをリターンする場合発生します。</p><p></p><p><strong>Parameters:</strong></p><ul><li><strong>error_code</strong> INTEGERKollus Player エラーコードです。</li></ul></td><td>v3, v4</td><td><p><br><br></p><p><code>controller.on('error', function(error_code) { // ... });</code></p><p></p></td></tr><tr><td><strong>device_orientation_changed</strong></td><td><p>モバイルディバイスの場合横/縦回転時発生します。</p><p></p><p><strong>Parameters:</strong></p><ul><li><strong>orientation</strong> STRING縦 : Portrait, 横 : Landscape</li></ul></td><td> v4</td><td></td></tr><tr><td><strong>hls_manifest_loaded</strong></td><td><p>v4 player hls manifest がロード時発生します。</p><p> </p><p><strong>Parameters:</strong></p><ul><li><strong>data</strong> OBJECT hls manifest dataオブジェクトです。</li></ul></td><td>v4</td><td> </td></tr><tr><td><strong>dash_manifest_loaded</strong></td><td><p>v4 player dash manifest がロード時発生します。</p><p> </p><p><strong>Parameters:</strong></p><ul><li><strong>data</strong> OBJECT dash manifest dataオブジェクトです。</li></ul></td><td>v4</td><td> </td></tr><tr><td><strong>bitrate_data_loaded</strong></td><td><p> Hls/Dash manifestがロードされた後、Bitrateデータを昇順に整列した後、配列に入れて返します。</p><p> </p><p><strong>Parameters:</strong></p><ul><li><strong>bitrate_data</strong> ARRAY Hls/Dash bitrate data objectを含んだ配列オブジェクトです。</li></ul></td><td>v4</td><td><code>controller.on('bitrate_data_loaded', function(bitrate_data) { // bitrate_data는 Bitrate Data</code> objectを含んだ配列オブジェクトです <code>// // [ // { // width: &#x3C;int>, // height: &#x3C;int>, // bitrate: &#x3C;int> // } // ] });</code></td></tr></tbody></table>

### メソッド使用 <a href="#vgcontroller-mesoddo" id="vgcontroller-mesoddo"></a>

Videogateway Controller Libraryが対応するメソッドを呼び出す方法となります

```javascript
controller.play();
```

上記の記載だけで呼び出すことができますが、場合によってはパラメーターが必要なメソッドもあります。

```javascript
controller.set_volume(90);
```

## メソッドリスト

＊メソッドリストについては左側はメソッドリストを参考してください。

####


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://catenoid-support.gitbook.io/kollus-dev-jp/kollus-vg-controller.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
