OAVp5.phone()#
functionoav-p5OAVp5.phone()
Shows the 📱 card: a QR code that sends a phone to the remote page, whose MIDI tab then plays this sketch. Returns the room name.
The same as the 📱 button in the panel. The card shows a QR code, the room and the link underneath; opening the link on a phone gives that phone an on-screen controller whose MIDI tab plays your sketch over the relay, as one more input (OAVp5.last.source is 'phone'). Calling it again hides the card. The first call connects to the relay and loads a small QR-code library from jsDelivr.
Before you call it
A network connection, to the relay (wss://remote.cheyuwu.com/relay unless you set another) and, for the picture of the QR code, to jsDelivr. Without the library the card shows the link as text.
Returns
String The name of the room the phone joins: the room option, or the link room, or a name made up for this browser (p5-…) and kept in it.
Examples
function setup() {
createCanvas(400, 300);
}
function mousePressed() {
const room = OAVp5.phone(); // the QR code card opens
console.log('phones join room', room);
}
function notePressed(note) {
background(random(255), random(255), random(255)); // a phone key changes the colour
}
function draw() {
fill(255);
text('click the canvas, scan the QR code, open the MIDI tab', 20, 30);
}To be confirmed
A phone playing a sketch through the relay was not tried for this page: the headless check cannot reach the relay, so the example is not run. The behaviour is as the code and the project's README describe it.
Related
roomThe name of the room phones join to play this page: by default one made up per browser.relayThe address of the relay that phones andlinkrooms talk through: a WebSocket URL.remoteThe address of the remote page that the 📱 QR code opens on a phone.OAVp5.panel.open()Opens the 🎹 panel (open()), closes it (close()) or flips it (toggle()).