Skip to content

Commit 2a686db

Browse files
authored
Adds sample code for starting a 2nd presentation. (#453)
1 parent b439c16 commit 2a686db

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

index.html

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -885,6 +885,32 @@ <h3>
885885
document.appendChild(spanElt);
886886
};
887887
&lt;/script&gt;
888+
</pre>
889+
</section>
890+
<section>
891+
<h3>
892+
Creating a second presentation from the same controlling page
893+
</h3>
894+
<pre class="example">
895+
&lt;!-- controller.html --&gt;
896+
&lt;!-- The same controlling page can create and manage multiple presentations,
897+
by calling start() multiple times. --&gt;
898+
&lt;button id="secondPresentBtn" style="display: none;"&gt;Present Again&lt;/button&gt;
899+
&lt;script&gt;
900+
var secondPresentBtn = document.getElementById("secondPresentBtn");
901+
var secondPresUrl = "https://example.com/second-presentation.html";
902+
var secondRequest = new PresentationRequest(secondPresUrl);
903+
// For simplicity, the logic to handle screen availability for secondRequest
904+
// and update the status of secondPresentBtn is omitted.
905+
secondPresentBtn.onclick = function () {
906+
// Start new presentation, likely on a different screen than the original
907+
// request.
908+
secondRequest.start().then(setSecondConnection);
909+
};
910+
function setSecondConnection(newConnection) {
911+
// Logic to handle messages to/from second-presentation.html.
912+
};
913+
&lt;/script&gt;
888914
</pre>
889915
</section>
890916
</section>

0 commit comments

Comments
 (0)