// Check if there's a next episode
try {
const nextEpisode = await ctx.playback.getNextEpisode()
if (nextEpisode) {
console.log(`Next episode: ${nextEpisode.name}`)
} else {
console.log("No next episode available")
}
} catch (error) {
console.error("Error getting next episode:", error)
}
// Play next episode when current is almost done
ctx.playback.registerEventListener((event) => {
if (event.status && event.status.completionPercentage > 95) {
try {
ctx.playback.playNextEpisode()
} catch(e) {}
}
})
// Good practice: Play scanned files for proper tracking
const localFile = getScannedFile() // Get a file that's in the library
ctx.playback.playUsingMediaPlayer(localFile.path)
// Bad practice: Playing unscanned files won't track properly
ctx.playback.playUsingMediaPlayer("/random/video.mp4") // Will cause tracking errors