Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

PLAY

Open a content projector/player to display various media types including videos, images, documents, and presentations.

Syntax

' Basic playback
PLAY file_or_url

' With options
PLAY file_or_url WITH OPTIONS options_string

Parameters

ParameterTypeRequiredDescription
file_or_urlStringYesPath to file or URL to display
options_stringStringNoComma-separated playback options

Supported Options

OptionDescription
autoplayStart playback automatically
loopLoop content continuously
fullscreenOpen in fullscreen mode
mutedStart with audio muted
controlsShow playback controls
nocontrolsHide playback controls

Supported Content Types

Video

ExtensionFormat
.mp4MPEG-4 Video
.webmWebM Video
.oggOgg Video
.movQuickTime
.aviAVI Video
.mkvMatroska
.m4vM4V Video

Audio

ExtensionFormat
.mp3MP3 Audio
.wavWAV Audio
.flacFLAC Audio
.aacAAC Audio
.m4aM4A Audio
.oggOgg Audio

Images

ExtensionFormat
.jpg .jpegJPEG Image
.pngPNG Image
.gifGIF (animated)
.webpWebP Image
.svgSVG Vector
.bmpBitmap

Documents

ExtensionFormat
.pdfPDF Document
.docx .docWord Document
.pptx .pptPowerPoint
.xlsx .xlsExcel Spreadsheet
.odtOpenDocument Text
.odpOpenDocument Presentation

Code

ExtensionLanguage
.rsRust
.pyPython
.js .tsJavaScript/TypeScript
.javaJava
.goGo
.rbRuby
.mdMarkdown
.htmlHTML

Examples

Play a Video

' Play a video file
PLAY "training-video.mp4"

' Play with autoplay and loop
PLAY "background.mp4" WITH OPTIONS "autoplay,loop,muted"

' Play from URL
PLAY "https://example.com/videos/demo.mp4"

Display an Image

' Show an image
PLAY "product-photo.jpg"

' Show image fullscreen
PLAY "banner.png" WITH OPTIONS "fullscreen"

Show a Presentation

' Display PowerPoint presentation
PLAY "quarterly-report.pptx"

' Fullscreen presentation mode
PLAY "sales-deck.pptx" WITH OPTIONS "fullscreen"

Display a Document

' Show PDF document
PLAY "contract.pdf"

' Show Word document
PLAY "proposal.docx"

Interactive Training Module

TALK "Welcome to the training module!"
TALK "Let's start with an introduction video."

PLAY "intro-video.mp4" WITH OPTIONS "controls"

HEAR ready AS TEXT "Type 'continue' when you're ready to proceed:"

IF LOWER(ready) = "continue" THEN
    TALK "Great! Now let's review the key concepts."
    PLAY "concepts-slides.pptx"
    
    HEAR understood AS TEXT "Did you understand the concepts? (yes/no)"
    
    IF LOWER(understood) = "yes" THEN
        TALK "Excellent! Here's your certificate."
        PLAY "certificate.pdf"
    ELSE
        TALK "Let's review the material again."
        PLAY "concepts-detailed.mp4"
    END IF
END IF

Product Showcase

' Show product images in sequence
products = FIND "products", "featured=true"

FOR EACH product IN products
    TALK "Now showing: " + product.name
    PLAY product.image_path
    WAIT 3000  ' Wait 3 seconds between images
NEXT

Code Review

' Display code for review
TALK "Let's review the implementation:"
PLAY "src/main.rs"

HEAR feedback AS TEXT "Any comments on this code?"
INSERT "code_reviews", file_path, feedback, NOW()

Audio Playback

' Play audio message
TALK "Here's a voice message from your team:"
PLAY "team-message.mp3" WITH OPTIONS "controls"

' Play background music
PLAY "ambient.mp3" WITH OPTIONS "autoplay,loop,muted"

Dynamic Content Display

' Display content based on file type
HEAR file_name AS TEXT "Enter the file name to display:"

file_ext = LOWER(RIGHT(file_name, 4))

IF file_ext = ".mp4" OR file_ext = "webm" THEN
    PLAY file_name WITH OPTIONS "controls,autoplay"
ELSE IF file_ext = ".pdf" THEN
    PLAY file_name
ELSE IF file_ext = ".jpg" OR file_ext = ".png" THEN
    PLAY file_name WITH OPTIONS "fullscreen"
ELSE
    TALK "Unsupported file type"
END IF

Embedded Video from URL

' Play YouTube video (via embed URL)
PLAY "https://www.youtube.com/embed/dQw4w9WgXcQ"

' Play Vimeo video
PLAY "https://player.vimeo.com/video/123456789"

Onboarding Flow

' Multi-step onboarding with media
TALK "Welcome to our platform! Let's get you started."

' Step 1: Welcome video
TALK "First, watch this quick introduction:"
PLAY "onboarding/welcome.mp4" WITH OPTIONS "controls"

HEAR step1_done AS TEXT "Press Enter when done..."

' Step 2: Feature overview
TALK "Here's an overview of our key features:"
PLAY "onboarding/features.pptx"

HEAR step2_done AS TEXT "Press Enter when done..."

' Step 3: Quick start guide
TALK "Finally, here's your quick start guide:"
PLAY "onboarding/quickstart.pdf"

TALK "You're all set! 🎉"

Error Handling

' Check if file exists before playing
file_path = "presentation.pptx"

IF FILE_EXISTS(file_path) THEN
    PLAY file_path
ELSE
    TALK "Sorry, the file could not be found."
    TALK "Please check the file path and try again."
END IF

Player Behavior

Web Interface

When used in the web interface, PLAY opens a modal overlay with:

  • Appropriate player for the content type
  • Close button to dismiss
  • Optional playback controls
  • Fullscreen toggle

WhatsApp/Messaging Channels

On messaging channels, PLAY sends the file directly:

  • Videos/images: Sent as media messages
  • Documents: Sent as file attachments
  • URLs: Sent as links with preview

Desktop Application

In the desktop app, PLAY uses the native media player or viewer appropriate for the content type.

File Locations

Files can be referenced from:

LocationExample
Bot’s .gbdrivedocuments/report.pdf
User’s folderusers/john@email.com/uploads/photo.jpg
Absolute URLhttps://cdn.example.com/video.mp4
Relative path./assets/logo.png

Limitations

  • Maximum file size depends on channel (WhatsApp: 16MB for media, 100MB for documents)
  • Some formats may require conversion for web playback
  • Streaming large files requires adequate bandwidth
  • Protected/DRM content is not supported

See Also

  • SEND FILE - Send files as attachments
  • TALK - Display text messages
  • UPLOAD - Upload files to storage
  • DOWNLOAD - Download files from URLs

Implementation

The PLAY keyword is implemented in src/basic/keywords/play.rs with content type detection and appropriate player selection for each media format.