Engine-klasse
CaptureService
*Deze inhoud is vertaald met behulp van AI (bèta) en kan fouten bevatten. Klik hier om deze pagina in het Engels te bekijken.
Samenvatting
Methoden
CaptureScreenshot(onCaptureReady: function):() |
CheckUploadCaptureStatusAsync(token: string):Tuple |
PromptCaptureGalleryPermissionAsync(captureGalleryPermission: Enum.CaptureGalleryPermission):boolean |
PromptSaveCapturesToGallery(captures: {any},resultCallback: function):() |
PromptShareCapture(captureContent: Content,launchData: string,onAcceptedCallback: function,onDeniedCallback: function):() |
ReadCapturesFromGalleryAsync(captureTypeFilters: {any},readFromAllEligibleExperiences: boolean):Tuple |
StartUploadCaptureAsync(capture: Capture):Tuple |
StartVideoCaptureAsync(onCaptureReady: function,captureParams: Dictionary):Enum.VideoCaptureStartedResult |
StopVideoCapture():() |
TakeScreenshotCaptureAsync(onCaptureReady: function,captureParams: Dictionary):() |
UploadCaptureAsync(capture: Capture):Tuple |
Evenementen
CaptureBegan(captureType: Enum.CaptureType):RBXScriptSignal |
CaptureEnded(captureType: Enum.CaptureType):RBXScriptSignal |
CaptureSaved(captureInfo: Dictionary):RBXScriptSignal |
UserCaptureSaved(captureContentId: ContentId):RBXScriptSignal |
API-referentie
Methoden
CaptureScreenshot
Parameters
Teruggaves
()
Codevoorbeelden
Screenshot Vastleggen
local CaptureService = game:GetService("CaptureService")
-- Referentie naar een ImageLabel ouder van het script dat deze code bevat
local imageLabel = script.Parent
local function onCaptureReady(contentId)
imageLabel.Image = contentId
end
CaptureService:CaptureScreenshot(onCaptureReady)CheckUploadCaptureStatusAsync
PromptCaptureGalleryPermissionAsync
CaptureService:PromptCaptureGalleryPermissionAsync(captureGalleryPermission:Enum.CaptureGalleryPermission):boolean
Parameters
Teruggaves
Codevoorbeelden
Vraag toestemming voor de capture gallery
local CaptureService = game:GetService("CaptureService")
local function isGalleryAccessGranted()
local accepted = CaptureService:PromptCaptureGalleryPermissionAsync(Enum.CaptureGalleryPermission.ReadAndUpload)
return accepted
endPromptSaveCapturesToGallery
Teruggaves
()
Codevoorbeelden
Prompt Delen Vastleggen
local CaptureService = game:GetService("CaptureService")
local function onShareAccepted()
print("Vastleg delen werd geaccepteerd!")
end
local function onShareDenied()
print("Vastleg delen werd geweigerd!")
end
local onCaptureReady = function(result, videoCapture)
if videoCapture then
local captureContent = Content.fromObject(videoCapture)
CaptureService:PromptShareCapture(captureContent, "launchData" , onShareAccepted, onShareDenied)
end
end
CaptureService:StartVideoCaptureAsync(onCaptureReady, {})ReadCapturesFromGalleryAsync
Teruggaves
Codevoorbeelden
Lees captures uit de galerij en doorloop pagina's
local CaptureService = game:GetService("CaptureService")
local function readCapturesFromGallery()
local allCaptures = {}
local capturesPages
local success, result = pcall(function()
local readResult, pages = CaptureService:ReadCapturesFromGalleryAsync({}, false)
if readResult == Enum.ReadCapturesFromGalleryResult.Success then
capturesPages = pages
end
return readResult
end)
if not success or result ~= Enum.ReadCapturesFromGalleryResult.Success then
-- Waarschijnlijk een machtigingsfout, zie CaptureService:PromptCaptureGalleryPermissionAsync()
warn("Kon de initiële captures niet ophalen: " .. result.Name)
return
end
-- Doorloop de huidige pagina
local currentPage = capturesPages:GetCurrentPage()
for _, capture in currentPage do
table.insert(allCaptures, capture)
end
-- Ga door naar de volgende pagina totdat deze is voltooid
while not capturesPages.IsFinished do
local advanceToNextPageSuccess, _ = pcall(function()
capturesPages:AdvanceToNextPageAsync()
end)
if not advanceToNextPageSuccess then
return
end
currentPage = capturesPages:GetCurrentPage()
for _, capture in currentPage do
table.insert(allCaptures, capture)
end
end
return allCaptures
endStartUploadCaptureAsync
StartVideoCaptureAsync
CaptureService:StartVideoCaptureAsync(
Parameters
| Standaardwaarde: nil |
Teruggaves
Codevoorbeelden
Start Video-opname Async
local CaptureService = game:GetService("CaptureService")
local tool = Instance.new("Tool")
tool.Parent = workspace
local onCaptureReady = function(result, videoCapture)
if result ~= Enum.VideoCaptureResult.Success and result ~= Enum.VideoCaptureResult.TimeLimitReached or not videoCapture then
print("Video-opname is om de volgende reden niet voltooid:", result)
else
-- Vraag de gebruiker om de video-opname op te slaan in hun galerij
CaptureService:PromptSaveCapturesToGallery({ videoCapture }, function()
print("Opname opgeslagen")
end)
end
end
tool.Activated:Connect(function()
local videoRecordingAllowedResult: Enum.VideoCaptureStartedResult = CaptureService:StartVideoCaptureAsync(onCaptureReady, {})
if videoRecordingAllowedResult ~= Enum.VideoCaptureStartedResult.Success then
print("Video-opname is om de volgende reden niet gestart:", videoRecordingAllowedResult)
end
end)StopVideoCapture
CaptureService:StopVideoCapture():()
Teruggaves
()
TakeScreenshotCaptureAsync
Parameters
| Standaardwaarde: nil |
Teruggaves
()
Codevoorbeelden
Neem Screenshot Vast Async
local CaptureService = game:GetService("CaptureService")
local parent = Instance.new("Tool")
parent.Parent = workspace
local onCaptureReady = function(result, screenshotCapture)
if result ~= Enum.ScreenshotCaptureResult.Success or not screenshotCapture then
print("Screenshot is om de volgende reden niet voltooid:", result)
else
-- Vraag de gebruiker om de screenshot vastlegging op te slaan in hun galerij
CaptureService:PromptSaveCapturesToGallery({ screenshotCapture }, function(results)
for capture, result in pairs(results) do
if result then
print("Vastlegging opgeslagen")
end
end
end)
end
end
parent.Activated:Connect(function()
CaptureService:TakeScreenshotCaptureAsync(onCaptureReady, { UICaptureMode = Enum.UICaptureMode.All })
end)UploadCaptureAsync
Parameters
Teruggaves
Codevoorbeelden
Upload opname naar het assetsysteem
local CaptureService = game:GetService("CaptureService")
local function uploadCapture(capture: Capture)
local success, result = pcall(function()
local uploadCaptureResult, assetId = CaptureService:UploadCaptureAsync(capture)
if uploadCaptureResult ~= Enum.UploadCaptureResult.Success then
-- Foutafhandeling
return nil
end
return assetId
end)
if not success then
-- Foutafhandeling
return nil
end
return result
endEvenementen
CaptureBegan
Parameters
CaptureEnded
Parameters
CaptureSaved
UserCaptureSaved
Parameters
captureContentId:ContentId |