Engine-Klasse
CaptureService
*Dieser Inhalt wurde mit KI (Beta) übersetzt und kann Fehler enthalten. Um diese Seite auf Englisch zu sehen, klicke hier.
Zusammenfassung
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 |
Events
CaptureBegan(captureType: Enum.CaptureType):RBXScriptSignal |
CaptureEnded(captureType: Enum.CaptureType):RBXScriptSignal |
CaptureSaved(captureInfo: Dictionary):RBXScriptSignal |
UserCaptureSaved(captureContentId: ContentId):RBXScriptSignal |
API-Referenz
Methoden
CaptureScreenshot
Parameter
Rückgaben
()
Code-Beispiele
Screenshot erfassen
local CaptureService = game:GetService("CaptureService")
-- Referenz zu einem ImageLabel, das das Skript enthält, das diesen Code enthält
local imageLabel = script.Parent
local function onCaptureReady(contentId)
imageLabel.Image = contentId
end
CaptureService:CaptureScreenshot(onCaptureReady)CheckUploadCaptureStatusAsync
PromptCaptureGalleryPermissionAsync
CaptureService:PromptCaptureGalleryPermissionAsync(captureGalleryPermission:Enum.CaptureGalleryPermission):boolean
Parameter
Rückgaben
Code-Beispiele
Erlaubnis zur Aufnahme-Galerie anfordern
local CaptureService = game:GetService("CaptureService")
local function isGalleryAccessGranted()
local accepted = CaptureService:PromptCaptureGalleryPermissionAsync(Enum.CaptureGalleryPermission.ReadAndUpload)
return accepted
endPromptSaveCapturesToGallery
Rückgaben
()
Code-Beispiele
Freigabeaufforderung zur Aufnahme
local CaptureService = game:GetService("CaptureService")
local function onShareAccepted()
print("Die Freigabe der Aufnahme wurde akzeptiert!")
end
local function onShareDenied()
print("Die Freigabe der Aufnahme wurde abgelehnt!")
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
Rückgaben
Code-Beispiele
Lese Aufnahmen aus der Galerie und durchlaufe die Seiten
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
-- Wahrscheinlich ein Berechtigungsfehler, siehe CaptureService:PromptCaptureGalleryPermissionAsync()
warn("Fehler beim Abrufen der anfänglichen Aufnahmen: " .. result.Name)
return
end
-- Durch die aktuelle Seite iterieren
local currentPage = capturesPages:GetCurrentPage()
for _, capture in currentPage do
table.insert(allCaptures, capture)
end
-- Zum nächsten Seite vorankommen, bis fertig
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(
Parameter
| Standardwert: "nil" |
Rückgaben
Code-Beispiele
Videoaufnahme asynchron starten
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("Die Videoaufnahme konnte aus folgendem Grund nicht abgeschlossen werden:", result)
else
-- Fordern Sie den Benutzer auf, die Videoaufnahme in seiner Galerie zu speichern
CaptureService:PromptSaveCapturesToGallery({ videoCapture }, function()
print("Aufnahme gespeichert")
end)
end
end
tool.Activated:Connect(function()
local videoRecordingAllowedResult: Enum.VideoCaptureStartedResult = CaptureService:StartVideoCaptureAsync(onCaptureReady, {})
if videoRecordingAllowedResult ~= Enum.VideoCaptureStartedResult.Success then
print("Die Videoaufnahme konnte aus folgendem Grund nicht gestartet werden:", videoRecordingAllowedResult)
end
end)StopVideoCapture
CaptureService:StopVideoCapture():()
Rückgaben
()
TakeScreenshotCaptureAsync
Parameter
| Standardwert: "nil" |
Rückgaben
()
Code-Beispiele
Screenshotaufnahme asynchron machen
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 konnte aus folgendem Grund nicht abgeschlossen werden:", result)
else
-- Fordern Sie den Benutzer auf, die Screenshotaufnahme in seiner Galerie zu speichern
CaptureService:PromptSaveCapturesToGallery({ screenshotCapture }, function(results)
for capture, result in pairs(results) do
if result then
print("Aufnahme gespeichert")
end
end
end)
end
end
parent.Activated:Connect(function()
CaptureService:TakeScreenshotCaptureAsync(onCaptureReady, { UICaptureMode = Enum.UICaptureMode.All })
end)UploadCaptureAsync
Parameter
Rückgaben
Code-Beispiele
Aufnahme in das Assetsystem hochladen
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
-- Fehler behandeln
return nil
end
return assetId
end)
if not success then
-- Fehler behandeln
return nil
end
return result
endEvents
CaptureBegan
Parameter
CaptureEnded
Parameter
CaptureSaved
UserCaptureSaved
Parameter
captureContentId:ContentId |