-
Notifications
You must be signed in to change notification settings - Fork 22.7k
Add example demonstrating navigator.presentation
usage to property documentation
#39053
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Preview URLs (comment last updated: 2025-04-09 17:31:17) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks but I don't think this is a useful demo. I would prefer an actual usage example that invokes at least one method on the presentation object.
@Josh-Cena I'll try to improve the example. |
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
IMO this is still not a useful example because it doesn't pertain to |
Thanks for your feedback! From what I understand, |
The |
The |
I explored a little bit more and I understand the attributes of the
The const presentationRequest = new PresentationRequest(["presentation.html"]);
const presentationRequest2 = new PresentationRequest(["presentation2.html"]);
navigator.presentation.defaultRequest = presentationRequest;
document.getElementById("startPresentation").addEventListener("click", () => {
presentationRequest2.start().then(session => {
console.log("Presentation started with session:", session);
}).catch(error => {
console.error("Error starting presentation:", error);
});
}); The For the purpose of the if ("presentation" in navigator) {
const presentationRequest = new PresentationRequest(["https://example.com/presentation.html"]);
// Use the default presentation if available, otherwise manually create one
navigator.presentation.defaultRequest = presentationRequest;
} else {
console.error("Presentation API is not available in this browser.");
} This will launch a presentation by using the browser's cast menu. Let me know what you think! (I tested all the code I'm presenting on chrome and edge). |
Description
This pull request adds an example to demonstrate the usage of the
navigator.presentation
property in the documentation. The example checks if the browser supports the Presentation API, retrieves thenavigator.presentation
object, and logs it to the console. If the API is unavailable, an error message is displayed.Motivation
Additional details
Related issues and pull requests