Skip to main content

GetWithOptions

info
  • This method is only available on ServerScripts

Gets a VideoRequest from a specified URL.

Parameters

Parameter NameParameter TypeParameter Description
urlstringThe URL to pull media from. This should be a valid URI
onDonefunction(VideoRequest)A callback for when the media information is pulled
optionsStreamDownloadOptions(Optional) Provides options for downloading media
note

Use the Get(string, function(VideoRequest)) overload for using default options

The example below downloads media and sets a VideoPlayer to that media

JavaScript

let Events = instance.GetHandler("Events")
let Network = instance.GetHandler("Network")

Events.Subscribe(ScriptEvent.OnUserNetworkEvent, function(userid, eventName, eventArgs) {
if (eventName == "getVideo") {
Streaming.Get(eventArgs[1], function(videoRequest){
// VideoRequests will return null/undefined if no media is found at the specified URL
if (videoRequest === undefined || videoRequest === null) return
Network.SendToAllClients("loadVideo", [videoRequest])
}
}
})

Lua

local Events = instance.GetHandler("Events")
local Network = instance.GetHandler("Network")

Events.Subscribe(ScriptEvent.OnUserNetworkEvent, function(userid, eventName, eventArgs)
if eventName == "getVideo" then
Streaming.Get(eventArgs[1], function(videoRequest)
-- VideoRequests will return nil if no media is found at the specified URL
if videoRequest == nil then return end
Network.SendToAllClients("loadVideo", {videoRequest})
end)
end
end)