Mình xin hướng dẫn tạo TVC chạy ở đầu video bằng JW Player ạ

doanthuvan

New member
## Cách khiến TVC chạy ở đầu video với người chơi JW

1. ** Thêm khóa API JW Player vào trang web của bạn. **

Để làm điều này, hãy truy cập trang web của người chơi JW và tạo một tài khoản.Khi bạn có tài khoản, bạn sẽ được cung cấp khóa API.Sao chép khóa này và dán nó vào tệp `jwplayer.config.js` trên trang web của bạn.

2. ** Thêm chức năng `jwplayer.on đã ()` vào trang web của bạn. **

Hàm này sẽ được gọi khi trình phát JW được tải.Trong chức năng này, bạn có thể thêm mã để hiển thị TVC ở đầu video.

`` `
jwplayer.onready (function () {
// Nhận phần tử video.
var video = document.getEuityById ('video');

// Nhận phần tử TVC.
var tvc = document.getEuityById ('TVC');

// Thêm TVC vào đầu video.
Video.AppendChild (TVC);
});
`` `

3. ** Đặt thuộc tính `autostart` của TVC thành` true`. **

Điều này sẽ khiến TVC bắt đầu phát tự động khi video bắt đầu phát.

`` `
TVC.setAttribution ('autostart', 'true');
`` `

4. ** Đặt thuộc tính `vị trí` của TVC thành` top`. **

Điều này sẽ khiến TVC được hiển thị ở đầu video.

`` `
TVC.setAttribution ('vị trí', 'top');
`` `

5. ** Đặt các thuộc tính `width` và` height` của tvc thành các giá trị giống như video. **

Điều này sẽ đảm bảo rằng TVC có cùng kích thước với video.

`` `
TVC.setAttribution ('Width', Video.getAttribution ('Width'));
TVC.setAttribution ('chiều cao', video.getAttribution ('chiều cao'));
`` `

Dưới đây là một ví dụ về cách bạn có thể sử dụng các bước này để thực hiện TVC chạy ở đầu video với JW Player:

`` `
<! DOCTYPE HTML>
<Html>
<Đầu>
<Title> Cách làm TVC chạy ở đầu video với JW Player </Title>
<script src = "https://cdn.jwplayer.com/player/v6/jwplayer.js"> </script>
</head>
<Body>
<video id = "video" src = "https://www.example.com/video.mp4"> </video>
<div id = "tvc">
<img src = "https://www.example.com/tvc.jpg">
</div>

<Script>
jwplayer.onready (function () {
// Nhận phần tử video.
var video = document.getEuityById ('video');

// Nhận phần tử TVC.
var tvc = document.getEuityById ('TVC');

// Thêm TVC vào đầu video.
Video.AppendChild (TVC);

// Đặt thuộc tính Autostart của TVC thành true.
TVC.setAttribution ('autostart', 'true');

// Đặt thuộc tính vị trí của TVC thành đầu.
TVC.setAttribution ('vị trí', 'top');

// Đặt thuộc tính chiều rộng và chiều cao của TVC thành các giá trị giống như video.
TVC.setAttribution ('Width', Video.getAttribution ('Width'));
TVC.setAttribution ('chiều cao', video.getAttribution ('chiều cao'));
});
</script>
</Body>
</html>
`` `

## hashtags

* #JWPlayer
* #TVC
* #băng hình
* #Streaming
* #Quảng cáo
=======================================
## How to make TVC run at the top of the video with JW Player

1. **Add the JW Player API key to your website.**

To do this, go to the JW Player website and create an account. Once you have an account, you will be given an API key. Copy this key and paste it into the `jwplayer.config.js` file on your website.

2. **Add the `jwplayer.onReady()` function to your website.**

This function will be called when the JW Player is loaded. In this function, you can add the code to display the TVC at the top of the video.

```
jwplayer.onReady(function() {
// Get the video element.
var video = document.getElementById('video');

// Get the TVC element.
var tvc = document.getElementById('tvc');

// Add the TVC to the top of the video.
video.appendChild(tvc);
});
```

3. **Set the `autostart` property of the TVC to `true`.**

This will cause the TVC to start playing automatically when the video starts playing.

```
tvc.setAttribute('autostart', 'true');
```

4. **Set the `position` property of the TVC to `top`.**

This will cause the TVC to be displayed at the top of the video.

```
tvc.setAttribute('position', 'top');
```

5. **Set the `width` and `height` properties of the TVC to the same values as the video.**

This will ensure that the TVC is the same size as the video.

```
tvc.setAttribute('width', video.getAttribute('width'));
tvc.setAttribute('height', video.getAttribute('height'));
```

Here is an example of how you could use these steps to make a TVC run at the top of a video with JW Player:

```
<!DOCTYPE html>
<html>
<head>
<title>How to make TVC run at the top of the video with JW Player</title>
<script src="https://cdn.jwplayer.com/player/v6/jwplayer.js"></script>
</head>
<body>
<video id="video" src="https://www.example.com/video.mp4"></video>
<div id="tvc">
<img src="https://www.example.com/tvc.jpg">
</div>

<script>
jwplayer.onReady(function() {
// Get the video element.
var video = document.getElementById('video');

// Get the TVC element.
var tvc = document.getElementById('tvc');

// Add the TVC to the top of the video.
video.appendChild(tvc);

// Set the autostart property of the TVC to true.
tvc.setAttribute('autostart', 'true');

// Set the position property of the TVC to top.
tvc.setAttribute('position', 'top');

// Set the width and height properties of the TVC to the same values as the video.
tvc.setAttribute('width', video.getAttribute('width'));
tvc.setAttribute('height', video.getAttribute('height'));
});
</script>
</body>
</html>
```

## Hashtags

* #JWPlayer
* #TVC
* #Video
* #Streaming
* #Advertising
 
Join ToolsKiemTrieuDoGroup
Back
Top
AdBlock Detected

We get it, advertisements are annoying!

Sure, ad-blocking software does a great job at blocking ads, but it also blocks useful features of our website. For the best site experience please disable your AdBlocker.

I've Disabled AdBlock