CoWatchingHandler

@PublicApi
interface CoWatchingHandler


โค้ดเรียกกลับที่มาจากแอปส่วนเสริมเพื่อจัดการการอัปเดตการดูร่วมกันจากระยะไกลและเพื่อค้นหาสถานะของสื่อในเครื่อง

สรุป

ฟังก์ชันสาธารณะ

Unit

ใช้การอัปเดตสถานะการดูร่วมกันจากผู้เข้าร่วมรายอื่นในการประชุม

Optional<QueriedCoWatchingState!>!

ดึงข้อมูลสถานะปัจจุบันของกิจกรรมการดูร่วมกันในพื้นที่

ฟังก์ชันสาธารณะ

onCoWatchingStateChanged

fun onCoWatchingStateChanged(state: CoWatchingState!): Unit

ใช้การอัปเดตสถานะการดูร่วมกันจากผู้เข้าร่วมรายอื่นในการประชุม

หมายเหตุ: ระบบจะไม่เรียกการดำเนินการนี้ตามการเปลี่ยนแปลงในเครื่อง

ตัวอย่างการติดตั้งใช้งาน

// Handle transition to new video.
if (!newState.mediaId().equals(this.videoPlayer.videoUrl)) {
  this.videoPlayer.loadVideo(newState.mediaId());
}

// Only adjust the local video playout if it is sufficiently diverged from the timestamp in the
// applied update.
if (newState
        .mediaPlayoutPosition()
        .minus(this.videoPlayer.videoTimestamp)
        .compareTo(Duration.ofMillis(500))
    > 0) {
  this.videoPlayer.seek(newState.mediaPlayoutPosition());
}

// Update pause state if necessary.
if (newState.playbackState().equals(PLAY) && this.videoPlayer.isPaused) {
  this.videoPlayer.unpause();
} else if (newState.playbackState().equals(PAUSE) && !this.videoPlayer.isPaused) {
  this.videoPlayer.pause();
}
พารามิเตอร์
state: CoWatchingState!

CoWatchingState ใหม่ที่จะนำไปใช้กับโปรแกรมเล่น

onStateQuery

fun onStateQuery(): Optional<QueriedCoWatchingState!>!

ดึงข้อมูลสถานะปัจจุบันของกิจกรรมการดูร่วมกันในพื้นที่

เราจะเรียกฟังก์ชันนี้ว่าเป็นประจำ ดังนั้นควรเขียนให้มีประสิทธิภาพ (เช่น <100 มิลลิวินาที)

ตัวอย่างการติดตั้งใช้งาน

QueriedCoWatchingState myCurrentPlaybackState = QueriedCoWatchingState
    .of(/* mediaPlayoutPosition= *{/} this.videoPlayer.videoTimestamp);
return Optional.of(myCurrentPlaybackState);
การคืนสินค้า
Optional<QueriedCoWatchingState!>!

Optional จาก QueriedCoWatchingState ซึ่งอธิบายสถานะการดูร่วมกันปัจจุบัน Optional ว่างเปล่าแสดงว่าไม่มีกิจกรรมการดูร่วมกันที่ดำเนินอยู่