curl을 사용할 때 -F를 사용해 boundary를 사용한 예제이다. 



curl -XPOST "http://up.google.com/up/" -F "key1=value1" -F "key2=value2" -v

*   Trying ...

* Connected to up.google.com (1.1.1.1) port 80 (#0)

> POST /up/ HTTP/1.1

> Host: up.google.com

> User-Agent: curl/7.43.0

> Accept: */*

> Content-Length: 465

> Expect: 100-continue

> Content-Type: multipart/form-data; boundary=------------------------fa94669c2a0ffcbe

>

< HTTP/1.1 100 Continue

< HTTP/1.1 200 OK

< Server: openresty

< Date: Fri, 09 Jun 2017 12:25:23 GMT

< Content-Type: application/json

< Transfer-Encoding: chunked

< Connection: keep-alive

<

* Connection #0 to host up.google left intact






이를 apache http를 사용해서 boundary 를 적용한 예제이다. 


import org.apache.http.HttpEntity;

import org.apache.http.client.methods.CloseableHttpResponse;

import org.apache.http.client.methods.HttpPost;

import org.apache.http.entity.mime.HttpMultipartMode;

import org.apache.http.entity.mime.MultipartEntityBuilder;

import org.apache.http.entity.mime.content.StringBody;

import org.apache.http.impl.client.CloseableHttpClient;

import org.apache.http.util.EntityUtils;

import org.junit.Test;




@Test

public void test() throws Exception {


HttpPost httpPost = new HttpPost("http://up.google.com/up/");


String BOUNDARY = "----------fa94669c2a0ffcbe";

httpPost.setHeader("Content-Type", "multipart/form-data;boundary=" + BOUNDARY);


MultipartEntityBuilder builder = MultipartEntityBuilder.create();

builder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);

builder.setBoundary(BOUNDARY);

builder.addPart("text_1", new StringBody("304"));

builder.addPart("text_2", new StringBody(toHex("사랑합니다💕 ")));

httpPost.setEntity(builder.build());


CloseableHttpClientFactory httpClientFactory = new CloseableHttpClientFactory();

CloseableHttpClient httpClient = httpClientFactory.getObject();

CloseableHttpResponse response = httpClient.execute(httpPost);

System.out.println("response : " + response);


if (response.getStatusLine().getStatusCode() == 200 || response.getStatusLine().getStatusCode() == 201) {

HttpEntity entity = response.getEntity();

String responseString = EntityUtils.toString(entity, "UTF-8");

System.out.println("result : " + responseString);

} else {

System.out.println("error");

}


}


public String toHex(String arg) {

return String.format("%040x", new BigInteger(1, arg.getBytes()));

}



로그는 다음과 같이 나타난다.


21:49:43.806 [main] DEBUG o.a.h.c.protocol.RequestAddCookies - CookieSpec selected: default

21:49:43.814 [main] DEBUG o.a.h.c.protocol.RequestAuthCache - Auth cache not set in the context

21:49:43.816 [main] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection request: [route: {}->http://up.google.com:80][total kept alive: 0; route allocated: 0 of 5; total allocated: 0 of 30]

21:49:43.824 [main] DEBUG o.a.h.i.c.PoolingHttpClientConnectionManager - Connection leased: [id: 0][route: {}->http://up.google.com:80][total kept alive: 0; route allocated: 1 of 5; total allocated: 1 of 30]

21:49:43.825 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Opening connection {}->http://up.google.com:80

21:49:44.234 [main] DEBUG o.a.h.i.c.DefaultHttpClientConnectionOperator - Connecting to up.google.com/1.1.1.1:80

21:49:44.247 [main] DEBUG o.a.h.i.c.DefaultHttpClientConnectionOperator - Connection established 1.1.1.2:59752<->1.1.1.1:80

21:49:44.248 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Executing request POST /up/ HTTP/1.1

21:49:44.248 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Target auth state: UNCHALLENGED

21:49:44.249 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Proxy auth state: UNCHALLENGED

21:49:44.250 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> POST /up/ HTTP/1.1

21:49:44.250 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Content-Type: multipart/form-data;boundary=----------HV2ymHFg03ehbqgZCaKO6jyH

21:49:44.250 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Content-Length: 447

21:49:44.250 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Host: up.google.com

21:49:44.250 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> Connection: Keep-Alive

21:49:44.250 [main] DEBUG org.apache.http.headers - http-outgoing-0 >> User-Agent: Apache-HttpClient/4.4.1 (Java/1.8.0_101)

21:49:44.251 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "POST /up/ HTTP/1.1[\r][\n]"

21:49:44.251 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Content-Type: multipart/form-data;boundary=----------HV2ymHFg03ehbqgZCaKO6jyH[\r][\n]"

21:49:44.251 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Content-Length: 447[\r][\n]"

21:49:44.251 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Host: up.google.com[\r][\n]"

21:49:44.251 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Connection: Keep-Alive[\r][\n]"

21:49:44.251 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "User-Agent: Apache-HttpClient/4.4.1 (Java/1.8.0_101)[\r][\n]"

21:49:44.251 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "[\r][\n]"

21:49:44.251 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "------------HV2ymHFg03ehbqgZCaKO6jyH[\r][\n]"

21:49:44.251 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Content-Disposition: form-data; name="text_1"[\r][\n]"

21:49:44.251 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "[\r][\n]"

21:49:44.251 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "304"

21:49:44.251 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "[\r][\n]"

21:49:44.251 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "------------HV2ymHFg03ehbqgZCaKO6jyH[\r][\n]"

21:49:44.252 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "Content-Disposition: form-data; name="text_2"[\r][\n]"

21:49:44.252 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "[\r][\n]"

21:49:44.252 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "ec82aceb9e91ec9db420eb8498ecb998eb8a9420ed9598eba3a8ec9e85eb8b88eb8ba42ef09f929520ebb09beb8a9420eab283eb8f8420eca28beca780eba78c20ed919ced9884ed9598eb8a9420eab283eb8f8420eca491ec9a94ed959c20eab1b020ec9584ec8b9ceca3a03ff09f988a"

21:49:44.252 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "[\r][\n]"

21:49:44.252 [main] DEBUG org.apache.http.wire - http-outgoing-0 >> "------------HV2ymHFg03ehbqgZCaKO6jyH--[\r][\n]"

21:49:45.401 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "HTTP/1.1 200 OK[\r][\n]"

21:49:45.401 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Server: openresty[\r][\n]"

21:49:45.401 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Date: Fri, 09 Jun 2017 12:49:45 GMT[\r][\n]"

21:49:45.401 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Content-Type: application/json[\r][\n]"

21:49:45.401 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Transfer-Encoding: chunked[\r][\n]"

21:49:45.401 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "Connection: keep-alive[\r][\n]"

21:49:45.401 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "[\r][\n]"

21:49:45.401 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "338[\r][\n]"

21:49:45.401 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "{.......}}[\r][\n]"

21:49:45.401 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "0[\r][\n]"

21:49:45.401 [main] DEBUG org.apache.http.wire - http-outgoing-0 << "[\r][\n]"

21:49:45.404 [main] DEBUG org.apache.http.headers - http-outgoing-0 << HTTP/1.1 200 OK

21:49:45.405 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Server: openresty

21:49:45.405 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Date: Fri, 09 Jun 2017 12:49:45 GMT

21:49:45.405 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Content-Type: application/json

21:49:45.405 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Transfer-Encoding: chunked

21:49:45.405 [main] DEBUG org.apache.http.headers - http-outgoing-0 << Connection: keep-alive

21:49:45.410 [main] DEBUG o.a.h.impl.execchain.MainClientExec - Connection can be kept alive indefinitely



Posted by '김용환'
,

일래스틱서치에서는 인덱스 이름을 변경할 수 있는 방법이 거의 없지만..


유일하게 스냅샷을 복구할 때 인덱스 이름을 유일하게 변경할 수 있다.




$ curl -XPOST "http://localhost:9200/_snapshot/es/snapshot_1/_restore" -d'

{

"indices": "my_index",

"ignore_unavailable": "true",

"rename_replacement": "your_index"

}'



Posted by '김용환'
,


먼저 저장소 경로를 등록한다. vi conf/elasticsearch.yml에서 다음을 추가한다. 


path.repo: ["/tmp/mnt"] 



파일 시스템 저장소를 등록한다.


curl -XPUT 'http://localhost:9200/_snapshot/es-backup' -d '{

"type": "fs",

"settings": {

"location": "/tmp/mnt/es-backup",

"compress": true

}

}'



만약 conf/elasticsearch.yml 파일에서 path.repo를 등록하지 않으면 다음 에러가 발생한다. 


{"error":{"root_cause":[{"type":"repository_exception","reason":"[es-backup] location [/tmp/es-backup] doesn't match any of the locations specified by path.repo because this setting is empty"}],"type":"repository_exception","reason":"[es-backup] failed to create repository","caused_by":{"type":"repository_exception","reason":"[es-backup] location [/tmp/es-backup] doesn't match any of the locations specified by path.repo because this setting is empty"}},"status":500}





snapshot 저장하기


$ curl -XPUT 'http://localhost:9200/_snapshot/es-backup/snapshot_1?wait_for_completion=true' -d '{

> "indices": "index_1,index_2",

> "ignore_unavailable": "true",

> "include_global_state": false

> }'

{"snapshot":{"snapshot":"snapshot_1","uuid":"gD2dYNYzQjevg3S6PbV0Fg","version_id":5030199,"version":"5.3.1","indices":[],"state":"SUCCESS","start_time":"2017-06-08T02:41:58.489Z","start_time_in_millis":1496889718489,"end_time":"2017-06-08T02:41:58.496Z","end_time_in_millis":1496889718496,"duration_in_millis":7,"failures":[],"shards":{"total":0,"failed":0,"successful":0}}}[/usr/local/elasticsearch-5.3.1/bin]





스냅샷 정보를 얻어오려면 다음 커맨드를 사용한다. 


curl -XGET 'http://localhost:9200/_snapshot/es-backup/snapshot_1'

{"snapshots":[{"snapshot":"snapshot_1","uuid":"gD2dYNYzQjevg3S6PbV0Fg","version_id":5030199,"version":"5.3.1","indices":[],"state":"SUCCESS","start_time":"2017-06-08T02:41:58.489Z","start_time_in_millis":1496889718489,"end_time":"2017-06-08T02:41:58.496Z","end_time_in_millis":1496889718496,"duration_in_millis":7,"failures":[],"shards":{"total":0,"failed":0,"successful":0}}]}





curl -XGET 'http://localhost:9200/_snapshot/es-backup/snapshot_1,snapshot_2'





curl -XGET 'http://localhost:9200/_snapshot/es-backup/_all'

'{"snapshots":[{"snapshot":"snapshot_1","uuid":"gD2dYNYzQjevg3S6PbV0Fg","version_id":5030199,"version":"5.3.1","indices":[],"state":"SUCCESS","start_time":"2017-06-08T02:41:58.489Z","start_time_in_millis":1496889718489,"end_time":"2017-06-08T02:41:58.496Z","end_time_in_millis":1496889718496,"duration_in_millis":7,"failures":[],"shards":{"total":0,"failed":0,"successful":0}}]}




스냅샷 삭제하는 방법은 다음과 같다. 


curl -XDELETE 'http://localhost:9200/_snapshot/es-backup/snapshot_1'



Posted by '김용환'
,




맥북에서 크롬캐스트2(TV)로 동기화하기


간단한 앱으로는 airflow 라는 앱이 있다. 개발이 중단된 것 같다. 음성 조절은 안드로이드폰에서 되는 단점이 있다.

1080p는 좀 버벅거린다.

http://airflowapp.com/



크롬 웹 스토어에 크롬 캐스트 앱이 있는데, 1080p 비디오가 버벅거리지 않고 소리 조절도 편하게 된다.

광고가 나온다는 단점이 있고 유료화에 대한 이슈가 있다.

https://chrome.google.com/webstore/search/videostream%20for%20google%20chromecast?utm_source=chrome-ntp-icon







Posted by '김용환'
,


spark streaming job을 개발할 때,


streaming이 잘 동작하는데. 문제 없는지 확인하고 싶을 때  


다음 URL을 잘 이용해 본다. spark ui를 



https://docs.cloud.databricks.com/docs/latest/databricks_guide/07%20Spark%20Streaming/02%20Debugging%20Spark%20Streaming%20Application.html




'scala' 카테고리의 다른 글

[sbt] sbt 버전 확인하기  (0) 2017.06.26
[play2] json-객체 연동 코드 예제  (0) 2017.06.26
[spark] parquet 사용 예제  (0) 2017.05.26
[spark] zipWithIndex, for-yield 예제  (0) 2017.05.25
[spark] join 예제  (0) 2017.05.23
Posted by '김용환'
,



cat API의 기본 엔드 포인트는 /_cat이다. 매개 변수가 없이 호출하면 cat API에 사용할 수 있는 모든 엔드 포인트를 표시한다.



curl -XGET 'localhost:9200/_cat'

=^.^=

/_cat/allocation

/_cat/shards

/_cat/shards/{index}

/_cat/master

/_cat/nodes

/_cat/tasks

/_cat/indices

/_cat/indices/{index}

/_cat/segments

/_cat/segments/{index}

/_cat/count

/_cat/count/{index}

/_cat/recovery

/_cat/recovery/{index}

/_cat/health

/_cat/pending_tasks

/_cat/aliases

/_cat/aliases/{alias}

/_cat/thread_pool

/_cat/thread_pool/{thread_pools}

/_cat/plugins

/_cat/fielddata

/_cat/fielddata/{fields}

/_cat/nodeattrs

/_cat/repositories

/_cat/snapshots/{repository}

/_cat/templates





각각의 cap api 요약을 한다면 다음과 같다.

  • 클러스터에서 현재 실행 중인 작업
  • 세그먼트 통계
  • 세그먼트 통계(특정 인덱스로 제한)
  • 샤드 할당 - 관련 정보
  • 필드 데이터 캐시 크기
  • 개별 필드의 필드 데이터 캐시 크기
  • 복구 정보
  • 복구 정보(특정 인덱스로 제한)
  • 클러스터에 등록된 스냅샷 저장소 정보
  • 사용자 정의 노드의 속성 정보
  • 색인 통계
  • 색인 통계(특정 색인으로 제한)
  • 특정 저장소에 속한 모든 스냅샷에 대한 정보
  • 각 노드에 설치된 플러그인
  • 특정 별명의 인덱스 앨리어스와 인덱스
  • 마스터 정보(선출된 마스터 표시 포함)
  • 마스터 노드 정보
  • 클러스터 상태
  • 실행 대기 중인 작업
  • 클러스터당 노드별 쓰레드 풀 정보
  • 클러스터당 노드별 단일 또는 다중 스레드 풀에 대한 스레드 풀 정보
  • 전체 클러스터 또는 개별 인덱스의 다큐먼트 개수
  • 모든 샤드 관련 정보(특정 인덱스로 제한)


클러스터 상태 정보를 보려면 다음을 호출한다.

$ curl -XGET 'localhost:9200/_cat/health'
1496739863 18:04:23 elasticsearch yellow 1 1 60 60 0 0 41 0 - 59.4%



컬럼 내용을 보이게 하려면 v를 추가한다. 

$ curl -XGET 'localhost:9200/_cat/health?v'
epoch      timestamp cluster       status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1496740013 18:06:53  elasticsearch yellow          1         1     60  60    0    0       41             0                  -                 59.4%


help 커맨드를 사용하면 헤더 내용을 알 수 있다.


$ curl -XGET 'localhost:9200/_cat/health?help'

epoch                 | t,time                                   | seconds since 1970-01-01 00:00:00

timestamp             | ts,hms,hhmmss                            | time in HH:MM:SS

cluster               | cl                                       | cluster name

status                | st                                       | health status

node.total            | nt,nodeTotal                             | total number of nodes

node.data             | nd,nodeData                              | number of nodes that can store data

shards                | t,sh,shards.total,shardsTotal            | total number of shards

pri                   | p,shards.primary,shardsPrimary           | number of primary shards

relo                  | r,shards.relocating,shardsRelocating     | number of relocating nodes

init                  | i,shards.initializing,shardsInitializing | number of initializing nodes

unassign              | u,shards.unassigned,shardsUnassigned     | number of unassigned shards

pending_tasks         | pt,pendingTasks                          | number of pending tasks

max_task_wait_time    | mtwt,maxTaskWaitTime                     | wait time of longest task pending

active_shards_percent | asp,activeShardsPercent                  | active number of shards in percent





특정 헤더만 보고 싶다면 다음을 실행한다.


$ curl -XGET 'localhost:9200/_cat/health?h=cluster,status'

elasticsearch yellow



용량을 알아서 보여주지만, bytes=b로 하면 바이트로, bytes=mb는 메가 바이트로 표현할 수 있다.


$ curl -XGET 'localhost:9200/_cat/indices'

yellow open books               SO4qsDCoSIK2y0Hb3OcBpQ 5 1     2 0  7.4kb  7.4kb


$ curl -XGET 'localhost:9200/_cat/indices?bytes=b'

yellow open books               SO4qsDCoSIK2y0Hb3OcBpQ 5 1     2 0      7646      7646




 /_cat/master REST 엔드 포인트를 호출하면 노드에 대한 정보와 현재 노드 중 하나를 마스터로 선출할 수 있다.


$ curl -XGET 'localhost:9200/_cat/master?v'

id                     host      ip        node

5OEGj_avT8un0nOak28qQg 127.0.0.1 127.0.0.1 5OEGj_a



응답에서 알 수 있듯이 현재 어떤 노드가 마스터로 선출되었는지에 대한 정보를 얻었다. 노드의 식별자, IP 주소, 이름을 볼 수 있다.




node 정보를 확인할 수 있다.


참고로 노드 이름, 노드의 역할(노드가 마스터(m), 데이터(a), ingest(i) 또는 클라이언트(-) 노드인지 여부), 노드의 부하(load_1m, load_5m ,load_15m), 가동 시간(uptime)을 선택하려면 다음과 같이 진행할 수 있다.


(참고: https://www.elastic.co/guide/en/elasticsearch/reference/current/cat-nodes.html)


$ curl -XGET 'localhost:9200/_cat/nodes?v&h=name,node.role,load,uptime'






Posted by '김용환'
,

pretty 사용시 기본은 예쁘게 json을 볼 수 있다.


[/usr/local/elasticsearch-5.3.1/bin] curl 'localhost:9200/_cluster/health?pretty'

{

  "cluster_name" : "elasticsearch",

  "status" : "yellow",

  "timed_out" : false,

  "number_of_nodes" : 1,

  "number_of_data_nodes" : 1,

  "active_primary_shards" : 60,

  "active_shards" : 60,

  "relocating_shards" : 0,

  "initializing_shards" : 0,

  "unassigned_shards" : 41,

  "delayed_unassigned_shards" : 0,

  "number_of_pending_tasks" : 0,

  "number_of_in_flight_fetch" : 0,

  "task_max_waiting_in_queue_millis" : 0,

  "active_shards_percent_as_number" : 59.4059405940594

}





format=yaml 매개 변수를 사용하면 yaml 형태로 정보를 얻을 수 있다.



[/usr/local/elasticsearch-5.3.1/bin] curl 'localhost:9200/_cluster/health?pretty&format=yaml'

---

cluster_name: "elasticsearch"

status: "yellow"

timed_out: false

number_of_nodes: 1

number_of_data_nodes: 1

active_primary_shards: 60

active_shards: 60

relocating_shards: 0

initializing_shards: 0

unassigned_shards: 41

delayed_unassigned_shards: 0

number_of_pending_tasks: 0

number_of_in_flight_fetch: 0

task_max_waiting_in_queue_millis: 0

active_shards_percent_as_number: 59.4059405940594

Posted by '김용환'
,



이모티콘을 mysql에 저장할 때 자바 애플리케이션에서 다음 방식을 사용했다. 




* A 서버 

 mysql connector java : 5.1.21 환경


update set names utfmd4를 사용하지 않고 이모티콘을 잘 저장했다. 

(테이블은 utf8, 컬럼은 utfmd4이었다)



* B 서버


mysql connector java : 5.1.35 환경


update set names utfmd4를 사용해야 이모티콘을 잘 저장했다  

(테이블은 utf8, 컬럼은 utfmd4이었다)

 

  public boolean updateDNS(final DNS dns) {

return transactionTemplate.execute(new TransactionParamBuilder().add(masterJdbcTemplate).build(), new TransactionCallback<Integer>() {

@Override

public Integer doInTransaction() {

masterJdbcTemplate.update("SET NAMES utf8mb4");

String sql = "UPDATE dns SET lang=?, type=?, content=?, status=? WHERE id=?";

return masterJdbcTemplate.update(sql, dns.lang, dns.type, dns.content, 1, dns.id);

}

}) > 0;

}

 

 



아마도..다음 이슈때문은 아닌지... 예상만 한다. 


https://dev.mysql.com/doc/relnotes/connector-j/5.1/en/news-5-1-33.html


The 4-byte UTF8 (utfbmb4) character encoding could not be used with Connector/J when the server collation was set to anything other than the default value (utf8mb4_general_ci). This fix makes Connector/J detect and set the proper character mapping for any utfmb4 collation. (Bug #19479242, Bug #73663)




Posted by '김용환'
,



html 컴포넌트에서 필드를 안보이게 하려면 다음과 같이 설정할 수 있다. 


style="display:none;"




Posted by '김용환'
,



다음에 접속해서 player를 하나 생성한다. 

https://dashboard.jwplayer.com/#/players/list


참고 : http://moonlight-ramble.tistory.com/399




먼저 어떤 형태로 서비스할 고른다.

https://dashboard.jwplayer.com/#/players/downloads


js를 내부에서 읽도록 하려려면 EMBEDDING SELF-HOSTED PLAYERS 부분을 참조한다. 관련 소스를 다운받을 수 있다. 



api key는 다음을 참조한다. 

https://support.jwplayer.com/customer/portal/articles/2339133-accessing-your-api-key-secret




css 설정을 진행한다.


.jw-icon-rewind {

 display: none !important;

}

외부 jwplayer 코드 대신 인하우스(inhouse)용으로 진행하려면 jwplayer 코드를 모두 애플리케이션에 복사해서 사용할 수 있다..



jwplayer를 사용할 수 있게 하고 간단한 설정을 진행할 수 있게 한다. 

<script type="text/javascript">


var player = jwplayer();

if (document.cookie.indexOf("jwplayerAutoStart") == -1) {

  document.cookie = "jwplayerAutoStart=1";

  player.on('ready', function() {

    player.play();

  });

}

</script>



화면에 하나의 jwplayer만 사용하려면 아래와 같이 간단히 사용한다.




<div id="legacyPlayer" align="center"></div>

<script type="text/javascript">

   jwplayer("legacyPlayer").setup({

       width:370,

       height:250,

       file: "${Guide.objectUrl}",

   });

</script>

만약 테이블에서 jwplayer를 사용하려면 다음처럼 사용한다.


(freemarker 이용 코드)


<div id="legacyPlayer${item.id}" align="center"></div>

<script type="text/javascript">

   jwplayer("legacyPlayer${item.id}").setup({

       width:370,

       height:250,

       file: "${item.objectUrl}",

   });

</script>


Posted by '김용환'
,