DocumentPictureInPicture

Limited availability

This feature is not Baseline because it does not work in some of the most widely-used browsers.

Experimental: This is an experimental technology
Check the Browser compatibility table carefully before using this in production.

Secure context: This feature is available only in secure contexts (HTTPS), in some or all supporting browsers.

Giao diện DocumentPictureInPicture của Document Picture-in-Picture API là điểm khởi đầu để tạo và xử lý các cửa sổ picture-in-picture tài liệu.

Nó được truy cập thông qua thuộc tính Window.documentPictureInPicture.

EventTarget DocumentPictureInPicture

Thuộc tính phiên bản

Kế thừa các thuộc tính từ lớp cha, EventTarget.

window Read only Experimental

Trả về phiên bản Window đại diện cho ngữ cảnh duyệt web bên trong cửa sổ Picture-in-Picture.

Phương thức phiên bản

Kế thừa các phương thức từ lớp cha, EventTarget.

requestWindow() Experimental

Mở cửa sổ Picture-in-Picture cho ngữ cảnh duyệt web chính hiện tại. Trả về Promise hoàn thành với phiên bản Window đại diện cho ngữ cảnh duyệt web bên trong cửa sổ Picture-in-Picture.

Sự kiện

Kế thừa các sự kiện từ lớp cha, EventTarget.

enter Experimental

Được kích hoạt khi cửa sổ Picture-in-Picture được mở thành công.

Ví dụ

js
const videoPlayer = document.getElementById("player");

// …

// Open a Picture-in-Picture window.
const pipWindow = await window.documentPictureInPicture.requestWindow({
  width: videoPlayer.clientWidth,
  height: videoPlayer.clientHeight,
});

// …

Xem Document Picture-in-Picture API Example để xem bản demo hoạt động đầy đủ (xem thêm mã nguồn).

Thông số kỹ thuật

Specification
Document Picture-in-Picture Specification
# documentpictureinpicture

Tương thích trình duyệt

Xem thêm