Engine Class
CaptureService
*เนื้อหานี้แปลโดยใช้ AI (เวอร์ชัน Beta) และอาจมีข้อผิดพลาด หากต้องการดูหน้านี้เป็นภาษาอังกฤษ ให้คลิกที่นี่
สรุป
วิธีการ
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 |
เหตุการณ์
CaptureBegan(captureType: Enum.CaptureType):RBXScriptSignal |
CaptureEnded(captureType: Enum.CaptureType):RBXScriptSignal |
CaptureSaved(captureInfo: Dictionary):RBXScriptSignal |
UserCaptureSaved(captureContentId: ContentId):RBXScriptSignal |
เอกสารอ้างอิงเกี่ยวกับ API
วิธีการ
CaptureScreenshot
CheckUploadCaptureStatusAsync
PromptCaptureGalleryPermissionAsync
CaptureService:PromptCaptureGalleryPermissionAsync(captureGalleryPermission:Enum.CaptureGalleryPermission):boolean
พารามิเตอร์
ส่งค่ากลับ
ตัวอย่างโค้ด
ขออนุญาตเข้าถึงแกลลอรีการจับภาพ
local CaptureService = game:GetService("CaptureService")
local function isGalleryAccessGranted()
local accepted = CaptureService:PromptCaptureGalleryPermissionAsync(Enum.CaptureGalleryPermission.ReadAndUpload)
return accepted
endPromptSaveCapturesToGallery
ReadCapturesFromGalleryAsync
ส่งค่ากลับ
ตัวอย่างโค้ด
อ่านการบันทึกจากแกลเลอรีและวนซ้ำผ่านหน้า
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
-- เป็นไปได้ว่าเกิดข้อผิดพลาดด้านสิทธิ์, ดูที่ CaptureService:PromptCaptureGalleryPermissionAsync()
warn("ไม่สามารถดึงข้อมูลการจับภาพเริ่มต้นได้: " .. result.Name)
return
end
-- ทำซ้ำผ่านหน้าปัจจุบัน
local currentPage = capturesPages:GetCurrentPage()
for _, capture in currentPage do
table.insert(allCaptures, capture)
end
-- ขยับไปยังหน้าถัดไปจนเสร็จสิ้น
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(
พารามิเตอร์
| ค่าเริ่มต้น: "nil" |
ส่งค่ากลับ
StopVideoCapture
CaptureService:StopVideoCapture():()
ส่งค่ากลับ
()
TakeScreenshotCaptureAsync
พารามิเตอร์
| ค่าเริ่มต้น: "nil" |
ส่งค่ากลับ
()
UploadCaptureAsync
พารามิเตอร์
ส่งค่ากลับ
ตัวอย่างโค้ด
อัปโหลดการจับภาพไปยังระบบสินทรัพย์
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
-- จัดการความล้มเหลว
return nil
end
return assetId
end)
if not success then
-- จัดการข้อผิดพลาด
return nil
end
return result
endเหตุการณ์
CaptureBegan
พารามิเตอร์
CaptureEnded
พารามิเตอร์
CaptureSaved
UserCaptureSaved
พารามิเตอร์
captureContentId:ContentId |