最新 / RSS
Kreisel / 無間巡回 / ガジェット(仮)

ChangeLog::hjk

最近 7 日分 / 今月の一覧

2018-01-12 Fri

mongodb を入れる [mongodb]

pacman -S mongodb mongodb-tools; systemctl start mongo.service

2018-01-11 Thu

viora (VIdeo - ORal Archive system) ブランチの創設 [git][project:viora]

[2017-09-23] project/slidesocket に続き…




in vaio...

git branch -a # 現在のブランチを確認。master と slidesocket

git checkout master # master に移動

# create branch
git branch viora master # master 直下に viora ブランチ創設
git checkout viora

cp /tmp/first.video.html catalog.html
cp /tmp/ffout .
cp /tmp/timestamp-x timestamp-hms.dat
cp /tmp/timestamp.json .
cp /tmp/timestamp05 timestamp-sec.dat
rm catalog.html~

git add .
git commit -a

# first push to git.server

git push origin viora

Counting objects: 10, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (9/9), done.
Writing objects: 100% (10/10), 4.84 KiB | 707.00 KiB/s, done.
Total 10 (delta 1), reused 0 (delta 0)
To ssh://***.**.80.18:22/home/huzioka/git/project.git

[new branch] viora -> viora




in arch...

git checkout master

git pull origin viora

git branch -a

master

  slidesocket
  remotes/origin/HEAD -> origin/master
  remotes/origin/master
  remotes/origin/slidesocket
  remotes/origin/viora


git checkout viora

Branch 'viora' set up to track remote branch 'viora' from 'origin'.
Switched to a new branch 'viora'


git branch

  master
  slidesocket

viora


ls

catalog.html ffout img policy timestamp-hms.dat timestamp-sec.dat timestamp.json

2018-01-10 Wed

整形 json から 一行 json へ [javascript]

var data = (JSON.stringify(rowdata));

[2018-01-09]

JSON.stringify() メソッドは JavaScript の値を JSON 文字列に変換します

https://developer.mozilla.org/ja/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify

JSON.parse <--> JSON.stringify
の関係
http://www.task-notes.com/entry/20160719/1468858991
あれ? 
http://blog.sushi.money/entry/20110828/1314189195



例)


var rowdata = [
    {
	"name": "scene 1",
	"start": "00:00:00",
	"end": "00:00:23"
    },
    {
	"name": "scene 2",
	"start": "00:00:23",
	"end": "00:00:47"
    }
]
var data = (JSON.stringify(rowdata));


は、すなわち


var data = '[{"name":"scene 1","start":"00:00:00","end":"00:00:23"},{"name":"scene 2","start":"00:00:23","end":"00:00:47"}]';


と同じ。

2018-01-09 Tue

json からボタン(button)生成 [javascript][video]

ほぼ手動の完成版?

<!--
<div>
    <button onclick="myfunc('00:01:27', '00:02:04')" type="button">Scene 4</button>
    <button onclick="myfunc('00:01:27', '00:02:04')" type="button">Scene 4</button>
</div>
-->

<video id="sample" src="01.mp4" controls></video>

<div id="channel"></div>
<script>
 // データjson読み込みとボタン生成
 //var data = '{"name":"scene 1","start":"00:00:00","end":"00:00:23"}';
 var data = '[{"name":"scene 1","start":"00:00:00","end":"00:00:23"},{"name":"scene 2","start":"00:00:23","end":"00:00:47"},{"name":"scene 3","start":"00:00:47","end":"00:01:27"},{"name":"scene 4","start":"00:01:27","end":"00:02:04"},{"name":"scene 5","start":"00:02:04","end":"00:02:25"},{"name":"scene 6","start":"00:02:25","end":"00:03:18"},{"name":"scene 7","start":"00:03:18","end":"00:03:22"}]';

 var obj = JSON.parse(data);
 var channel = document.getElementById('channel');
 for (var i=0; i<obj.length; i++) {
     var b = document.createElement('button');
     var val = 'myfunc(\'' + obj[i].start + '\',\'' + obj[i].end + '\')'; //myfunc('00:01:27', '00:02:04')
     b.setAttribute("onclick", val);
     b.setAttribute("type", "button");
     channel.appendChild(b);
     b.innerText = obj[i].name;
 };
<script>






<video id="sample" src="01.mp4" controls></video>

<div id="channel"></div>
<script>

 var rowdata = [
     {
         "name": "scene 1",
         "start": "00:00:00",
         "end": "00:00:23"
     },
     {
         "name": "scene 2",
         "start": "00:00:23",
         "end": "00:00:47"
     },
     {
         "name": "scene 3",
         "start": "00:00:47",
         "end": "00:01:27"
     }
 ]

 var data = (JSON.stringify(rowdata));

 var obj = JSON.parse(data);
 var channel = document.getElementById('channel');
 for (var i=0; i<obj.length; i++) {
     var b = document.createElement('button');
     var val = 'myfunc(\'' + obj[i].start + '\',\'' + obj[i].end + '\')'; //myfunc('00:01:27', '00:02:04')
     b.setAttribute("onclick", val);
     b.setAttribute("type", "button");
     channel.appendChild(b);
     b.innerText = obj[i].name;

</script>






<!DOCTYPE html>
<html>
    <head>
        <title>seek test</title>
    </head>
    <body>

        <video id="sample" src="01.mp4" controls></video>

        <div id="channel"></div>
        <script>

         // データjson読み込みとボタン生成
         //var data = '{"name":"scene 1","start":"00:00:00","end":"00:00:23"}';
         //var data = '[{"name":"scene 1","start":"00:00:00","end":"00:00:23"},{"name":"scene 2","start":"00:00:23","end":"00:00:47"},{"name":"scene 3","start":"00:00:47","end":"00:01:27"},{"name":"scene 4","start":"00:01:27","end":"00:02:04"},{"name":"scene 5","start":"00:02:04","end":"00:02:25"},{"name":"scene 6","start":"00:02:25","end":"00:03:18"},{"name":"scene 7","start":"00:03:18","end":"00:03:22"}]';

         var rowdata = [
             {
                 "name": "scene 1",
                 "start": "00:00:00",
                 "end": "00:00:23"
             },
             {
                 "name": "scene 2",
                 "start": "00:00:23",
                 "end": "00:00:47"
             },
             {
                 "name": "scene 3",
                 "start": "00:00:47",
                 "end": "00:01:27"
             },
             {
                 "name": "scene 4",
                 "start": "00:01:27",
                 "end": "00:02:04"
             },
             {
                 "name": "scene 5",
                 "start": "00:02:04",
                 "end": "00:02:25"
             },
             {
                 "name": "scene 6",
                 "start": "00:02:25",
                 "end": "00:03:18"
             },
             {
                 "name": "scene 7",
                 "start": "00:03:18",
                 "end": "00:03:22"
             }
         ]
         console.log(JSON.stringify(rowdata));

         var data = (JSON.stringify(rowdata));

         var obj = JSON.parse(data);
         var channel = document.getElementById('channel');
         for (var i=0; i<obj.length; i++) {
             var b = document.createElement('button');
             var val = 'myfunc(\'' + obj[i].start + '\',\'' + obj[i].end + '\')'; //myfunc('00:01:27', '00:02:04')
             b.setAttribute("onclick", val);
             b.setAttribute("type", "button");
             channel.appendChild(b);
             b.innerText = obj[i].name;
         };

         // イベント発火で指定のシーンへジャンプ
         let aaa = document.getElementById('sample');
         let src = aaa.getAttribute('src'); // 01.mp4

         let start;
         let end;

         function myfunc(start, end) {
             let target = src + '#t=' + start + ',' + end;
             aaa.setAttribute('src', target);
         };

        </script>
    </body>
</html>


Referrer (Inside): [2018-01-10-1]

2018-01-08 Mon

json ファイルからタグ自動生成 [javascript][video]

[2018-01-03], [2018-01-07] つづき


<!DOCTYPE html>
<html>
    <head>
        <title>seek test</title>
    </head>
    <body>

        <video id="sample" src="01.mp4" controls></video>

        <div id="channel"></div>

        <script>

         // データjson読み込みとボタン生成
         //var data = '{"name":"scene 1","start":"00:00:00","end":"00:00:23"}';
         var data = '[{"name":"scene 1","start":"00:00:00","end":"00:00:23"},{"name":"scene 2","start":"00:00:23","end":"00:00:47"}]';
         var obj = JSON.parse(data);
         var channel = document.getElementById('channel');
         for (var i=0; i<obj.length; i++) {
             var b = document.createElement('button');
             var val = 'myfunc(\'' + obj[i].start + '\',\'' + obj[i].end + '\')'; //myfunc('00:01:27', '00:02:04')
             b.setAttribute("onclick", val);
             b.setAttribute("type", "button");
             channel.appendChild(b);
             b.innerText = obj[i].name;
         };

         // イベント発火で指定のシーンへジャンプ
         let aaa = document.getElementById('sample');
         let src = aaa.getAttribute('src'); // 01.mp4

         let start;
         let end;

         function myfunc(start, end) {
             let target = src + '#t=' + start + ',' + end;
             aaa.setAttribute('src', target);
         };

        </script>
    </body>
</html>



JSON文字列をオブジェクトに変換する:
https://javascript.programmer-reference.com/js-json-parse/

2018-01-07 Sun

html5 <video> で再生開始・終了を指定 2. ~onclickの関数に引数導入~ [video][javascript]

1:27から2:04秒までを再生。

対比:[2018-01-03]





<!DOCTYPE html>
<html>
    <head>
        <title>seek test</title>
    </head>
    <body>

        <video id="sample" src="01.mp4" controls></video>

        <button onclick="myfunc('00:01:27', '00:02:04')" type="button">Set time 22</button>

        <script>
         let aaa = document.getElementById('sample');
         let src = aaa.getAttribute('src'); // 01.mp4

         let start;
         let end;

         function myfunc(start, end) {
             let target = src + '#t=' + start + ',' + end;
             aaa.setAttribute('src', target);
         };

        </script>
    </body>
</html>


Referrer (Inside): [2018-01-08-1]

2018-01-06 Sat