업무관련/넥사크로
넥사크로 WebBrowser 동영상 제어 관련 코드
레임보우
2023. 3. 31. 14:48
html 간단한 웹 페이지 코드
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
<!DOCTYPE html>
<html>
<script>
var video;
window.onload = function(){
var player = videojs("vid1", {
sources : [
{ src : "http://192.168.0.132/LCDMSLv2/MOV/TESTMOV.mp4", type : "video/mp4"}
],
poster : "http://192.168.0.132/LCDMSLv2/title_1.png",
controls : true,
playsinline : true,
muted : false,
preload : "metadata",
controlBar : {
playToggle : true,
pictureInPictureToggle : true,
remainingTimeDisplay : true,
progressControl : false
}
});
video = videojs("vid1");
}
// PLAY TOGGLE x=1 ON, x=0 OFF
function fnSetPlay(x) {
if (x == 1) {
video.play();
}
else {
video.pause();
}
}
// 영상이 정지중인지 확인 1=정지 0=재생중
function fnGetIsPaused() {
return video.paused();
}
// 현재 시간 추출
function fnGetPlayTime() {
//alert(jsPlayer.currentTime());
return video.currentTime();
}
// 재생시간 변경
function fnSetCurrentTime(x) {
video.currentTime(x);
}
// 총 시간 추출
function fnGetDuration() {
//alert(jsPlayer.duration());
return video.duration();
}
// PIP TOGGLE x=1 ON, x=0 OFF
function fnPictureInPicture(x) {
if (x == 1) {
if (document.pictureInPictureEnabled) {
video.requestPictureInPicture();
}
}
else {
if (document.pictureInPictureElement) {
document.exitPictureInPicture();
}
}
}
</script>
<head>
<link href="https://cdnjs.cloudflare.com/ajax/libs/video.js/7.8.1/video-js.min.css" rel="stylesheet">
<script src="https://cdnjs.cloudflare.com/ajax/libs/video.js/7.8.1/video.min.js"></script>
</head>
<body oncontextmenu='return false' onselectstart='return false' ondragstart='return false'>
<video id="vid1" width="640" height="264" class="video-js vjs-default-skin" webkit-playsinline></video>
</body>
</html>
|
cs |
위 html을 만들고 메서드도 만들어놓고 넥사크로에서 사용할수 있다.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
// 폼 로드 완료시 초기화
this.form_onload = function(obj:nexacro.Form,e:nexacro.LoadEventInfo)
{
this.div00.form.webPlayer.set_url("Player.html");
}
// 웹브라우져가 성공적으로 완료된 후
this.div00_webPlayer_onloadcompleted = function(obj:nexacro.WebBrowser,e:nexacro.WebLoadCompEventInfo)
{
// 웹 열기가 성공해야 아래 프로퍼티를 가져올수 있음
var _doc = this.div00.form.webPlayer.getProperty("window");
// 아래와 같이 getProperty를 이용하여 직접 접근 가능하지만 되도록이면 html에 function를 사용 권장
var dom = _doc.callMethod("videojs", "vid1");
var str;
str = dom.getProperty("currentTime"); // 현재 재생시간
str = dom.getProperty("duration"); // 총 재생시간
// 아래와 같이 html에 정의된 메소드를 이용 권장
str = _doc.callMethod("fnGetDuration"); // 전체 ms 가져오기
str = _doc.callMethod("fnGetIsPaused"); // 현재 동영상이 정지중인지 bool 전달
str = _doc.callMethod("fnGetPlayTime"); // 재생중인 시간 가져오기 이때 number 타입으로 가져옴
_doc.callMethod("fnSetCurrentTime","600"); // 10분으로 이동
_doc.callMethod("fnSetPlay","1"); // 재생하기
_doc.callMethod("fnSetPlay","0"); // 정지하기
_doc.callMethod("fnPictureInPicture","1"); // PIP기능 ON
_doc.callMethod("fnPictureInPicture","0"); // PIP기능 OFF
if(_doc)
{
_doc.destroy();
_doc = null;
}
if(doc)
{
doc.destroy();
doc = null;
}
}
|
cs |
웹브라우저에서 비슷하게나마 사용할수 있게 참고