Origin Scripting Language
  • Basics
    • Syntax
    • Types
    • The Execution Loop
    • Defining Variables
      • Clone Objects (=)
      • References To Objects/Variables (@=)
    • Assignment Operators
    • Local Scoping
    • Typed Variables
  • Operators
    • Mathematical Usage
      • Addition Operator (+)
      • Subtraction Operator (-)
      • Divide Operator (/)
      • Multiply Operator (*)
      • To The Power Of (^)
      • Modulo Operator (%)
    • Text Usage
    • String Concatenation Operator (+)
    • Array Operations
    • Comparative Operators
    • Logical Operators
    • Bitwise operators
    • Pipe Operator (|>)
    • Nullish Coalescing Operator (??)
  • Program Flow
    • If Statements
      • if truthy (
      • ) else if truthy (
      • ) else (
      • )
    • Switch Case
    • Iteration
    • While And Until
    • Dynamic OSL Execution
  • Arrays And Objects
    • Making Arrays Or Objects
    • Modifying An Array
    • Clone Objects And References
    • Object Operations
    • Object Property Shorthand
  • Environment
    • The Window System
    • Mouse Cursor
    • Camera
    • Sound System
    • Input Simulation
    • Running Other Languages
    • Notifications
    • Send Data Between Windows
    • Interfacing With Rightclick
    • Permissions
    • Files
      • What is a file? (in ofsf)
      • Creating Directories
      • open("file_path")
      • fileGet(int)
      • listFiles()
  • Storage
    • Save DB
    • Local DB
  • Custom Syntax
    • Commands
    • Methods
    • Functions
    • Inline
    • Lambda
    • Spread Operator
    • Typed Parameters
    • Classes
    • Promises
  • External
    • Make An Iframe App
  • Commands
    • Debugging
      • log "hello world"
      • warn "you should change this"
      • error "something went wrong"
      • void expression
    • Rendering
      • Basics
        • Color Commands
        • Color Picker
        • Modifiers
      • Draw Cursor
        • goto x y
        • set_x x
        • set_y y
        • change_x x
        • change_y y
        • change x y
        • loc a b c d
      • Elements
        • Canvas
        • Rectangle
        • Triangle
        • Icon
        • Text
        • Image
        • Video
        • Input
        • Pen
        • Hitbox
        • Bar
        • Slider
      • ICN (Icon System)
        • Drawing Commands
        • Dynamic Icons
      • Clipping And Scrolling (frames)
      • 3D Rendering
  • Functions
    • Math
      • Math()
      • random(low,high)
      • min(num1,num2)
      • max(num1,num2)
      • lcm(num1,num2)
      • gcd(num1,num2)
      • sum(num1,..)
      • average(num1,..)
      • dist(x1,y1,x2,y2)
      • degtorad(angle)
      • radtodeg(angle)
      • noise(x, y, z)
      • octaveNoise(x, y, z, octaves, persistence)
    • Types
      • typeof(value)
      • symbol(name)
    • Encoding
      • encodeURIComponent(string)
      • decodeURIComponent(string)
      • btoa/atob(string)
    • function()
    • formatFileSize(bytes)
    • getGamepads()
    • import(path)
    • ouidNew()
    • parseFilePath(path)
  • Global Variables
    • Overview
    • System Information
    • User Information
    • Date and Time
    • Input State
    • Display and UI
    • Network
    • File System
  • Methods
    • Strings
      • .padStart(val,num)
      • .padEnd(val,num
      • .startsWith(val)
      • .endsWith(val)
      • .wrapText(characters)
      • .trimText(characters)
      • .split(characters)
      • .count(val)
      • .replace(old,new)
      • .replaceFirst(old,new)
      • .oslTokenise()
      • .strip()
      • .toOrdArray()
      • .match(pattern)
      • Encoding
        • .encodeBin()
        • .decodeBin()
        • .encodeHex()
        • .decodeHex()
        • .encodeUTF16()
        • .decodeUTF16()
        • .encrypt(password)
        • .decrypt(password)
        • .ord()
        • .chr()
      • Hashing
        • .hashMD5()
        • .hashSHA1()
        • .hashSHA256()
        • .hashSHA512()
      • Case
        • .toLower()
        • .toUpper()
        • .toMixed()
        • .toTitle()
    • Keyboard
      • .isKeyDown()
      • .onKeyDown()
    • Utilities
      • .len
      • .not
      • .ask()
      • .reverse()
      • .first()
      • .last()
      • .append(val)
      • .prepend(val)
      • .insert(location,val)
      • .delete(location)
      • .concat(val)
      • .trim(idx1,idx2)
      • .left(num)
      • .right(num)
      • .contains(val)
      • .index(val)
    • Maths
      • .abs()
      • .invabs()
      • .log()
      • .ln()
      • .isPrime()
      • .sqrt()
      • .sign()
      • .chance()
      • .clamp(low,high)
      • .toBase(base)
      • Rounding
        • .round(places)
        • .ceiling()
        • .floor()
      • Trigonometry
        • .sin
        • .cos
        • .tan
        • .asin()
        • .acos()
        • .atan()
        • .radSin()
        • .radCos()
    • Iframes
      • .iframeNew()
      • .iframeGoto()
      • .iframeResize()
      • .iframeRedirect()
      • .iframeShow()
      • .iframeHide()
      • .iframeClose()
    • JSON
      • Arrays
        • .pop()
        • .shift()
        • .randomOf()
        • .sort(direction)
        • .sortBy(key,direction)
        • .swap(idx1,idx2)
        • .fill(value)
        • .join(characters)
        • .map(callback)
        • .filter(callback)
        • .some(callback)
        • .every(callback)
      • Objects
        • .getKeys(keys)
        • .getValues()
      • .JsonStringify()
      • .JsonParse()
      • .JsonFormat()
      • .JsonClean()
    • Types
      • .getType()
      • .isType(type)
      • .toNum()
      • .toBool()
      • .toStr()
    • Functions
      • .bind(context)
    • Networking
      • .httpGet()
      • .http(method,data,headers)
      • .getAsync()
      • .roturConnect()
      • .roturSend(msg,target)
      • Websockets
        • .newWebsocket()
        • .wsSend(msg)
        • .wsClose()
        • .wsOpen()
        • .wsHasnew()
        • .wsGetnext()
        • .wsGetcount()
    • Timestamp
      • .timestamp("convert-date")
      • .timestamp("component")
Powered by GitBook
On this page
  • Creating a Video Element
  • Manipulating a Video Element
  • "Pause" and "Play"
  • "Seek"
  • "Volume" and "Speed"
  • "Clear"
  • Video Info

Was this helpful?

Edit on GitHub
  1. Commands
  2. Rendering
  3. Elements

Video

PreviousImageNextInput

Last updated 18 days ago

Was this helpful?

Creating a Video Element

By using the video , videos can be displayed an OSL program. To initialize a video, simply render it using the following syntax:

// video url width height
// "height" argument is optional
url = "https://raw.githubusercontent.com/Mistium/Origin-OS/main/Resources/gifs/badapplefull.mp4"
video url 300 400

OSL handles all the fetching and loading of videos internally the first time a URL is used. However, videos take a while to load; you may notice that when running the example script above, the screen will be black for several frames while the video initializes. To work around this, we can initialize the video before it's displayed by using the "load" argument.

// video "load" url id
url = "https://raw.githubusercontent.com/Mistium/Origin-OS/main/Resources/gifs/badapplefull.mp4"
video "load" url "my_video"

Manipulating a Video Element

To manipulate a video's state, we first need to identify the video's ID. All videos created in OSL have a video ID. Typically, this ID is just the same as the URL you used to initialize the video. However, when pre-loading a video using the "load" argument, a custom ID can be chosen for the video.

"Pause" and "Play"

You may notice that when loading a video, it doesn't begin playing right away. That's because when initialized, a video begins paused; to unpause it, the "play" command must be called. Inversely, the "pause" command can return the video to a non-playing state.

video "videoID_here" "play"

video "videoID_here" "pause"

"Seek"

To seek (or jump to a specific part of) a video, the aptly named "seek" argument is used. By specifying a time in seconds, we can start the video at that point. Note that if the video was paused before calling "seek," this command resumes playback—the video can be paused after using "seek" to mitigate this.

// Starts the video at 10 seconds
video "videoID_here" "seek" 10

"Volume" and "Speed"

By using the "volume" and "speed" commands, we can tinker with those values as well. By default, volume is set to 100 and playback speed is set to 1.

// Slows the video to half speed, then to x2 speed.
video "videoID_here" "speed" .5
video "videoID_here" "speed" 2

// Mutes the video.
video "videoID_here" "volume" 0

"Clear"

To clear a video from memory, the "clear" argument can be used.

url = "https://raw.githubusercontent.com/Mistium/Origin-OS/main/Resources/gifs/badapplefull.mp4"
video "load" url "my_video"

// Removes the video from memory.
video url "clear"

Video Info

Method
Type
Description

.videoInfo("loaded")

Boolean

Returns whether a video has been fully initialized or not.

.videoInfo("playing")

Boolean

Returns if a video is actively playing content; in other words, checks if the video is paused or not.

.videoInfo("width")

Number

Return the video's width in pixels.

.videoInfo("height")

Number

Return the video's height in pixels.

.videoInfo("current_time")

Number

Return the current time of the video in seconds.

.videoInfo("duration")

Number

Return the runtime of the video in seconds.

.videoInfo("volume")

Number

Returns the volume of the video; defaults to 100, but can be set using the "volume" argument above.

By using the .videoInfo() after the video ID, information about the respective video can be accessed. The method takes one argument, which specifies which data to return.

command
method