AudioPlayer

แสดงที่เลิกใช้งานแล้ว

*เนื้อหานี้จะพร้อมใช้งานในภาษาที่คุณเลือกในเร็วๆ นี้

AudioPlayer is used to play audio assets. It provides a single Output pin which can be connected to other pins via Wires.

ตัวอย่างโค้ด

Outputting Audio to Device

local audioPlayer : AudioPlayer = Instance.new("AudioPlayer")
audioPlayer.Parent = workspace
audioPlayer.AssetId = "rbxassetid://9112854440"
local deviceOutput = Instance.new("AudioDeviceOutput")
deviceOutput.Parent = workspace
local wire = Instance.new("Wire")
wire.Parent = workspace
wire.SourceInstance = audioPlayer
wire.TargetInstance = deviceOutput
audioPlayer:Play()

สรุป

คุณสมบัติ

  • อ่านพร้อมๆ กัน

    The asset to be loaded into the AudioPlayer.

  • อ่านพร้อมๆ กัน

    Controls whether AssetId loads automatically once assigned.

  • อ่านพร้อมๆ กัน

    Denotes whether this AudioPlayer is currently playing.

  • อ่านอย่างเดียว
    ไม่ซ้ำ
    อ่านพร้อมๆ กัน

    Denotes whether this AudioPlayer is loaded, buffered, and ready to play.

  • อ่านพร้อมๆ กัน

    A range, in seconds, denoting a desired loop start and loop end within the PlaybackRegion of this AudioPlayer.

  • อ่านพร้อมๆ กัน

    Controls whether this AudioPlayer loops.

  • อ่านพร้อมๆ กัน

    Range in seconds denoting a desired start time (minimum) and stop time (maximum) within the TimeLength.

  • อ่านพร้อมๆ กัน

    Controls how quickly the asset will be played, which controls its pitch.

  • อ่านอย่างเดียว
    ไม่ซ้ำ
    อ่านพร้อมๆ กัน

    Denotes the length of the loaded asset.

  • อ่านพร้อมๆ กัน

    Tracks the current position of the playhead within the asset.

  • อ่านพร้อมๆ กัน

    Controls how loudly the asset will be played.

วิธีการ

คุณสมบัติ

AssetId

อ่านพร้อมๆ กัน

The asset to be loaded into the AudioPlayer. If AutoLoad is true, the asset loads immediately once this property is assigned. When loading is complete, IsReady becomes true.

AutoLoad

อ่านพร้อมๆ กัน

Controls whether AssetId loads automatically once assigned. If false, the asset will load upon the first attempt to play.

IsPlaying

อ่านพร้อมๆ กัน
การรักษาความปลอดภัยของ Roblox

Denotes whether this AudioPlayer is currently playing. This property is read-only, but replicates. To play and stop an AudioPlayer at runtime, use the Play() and Stop() methods.

IsReady

อ่านอย่างเดียว
ไม่ซ้ำ
อ่านพร้อมๆ กัน

Denotes whether this AudioPlayer is loaded, buffered, and ready to play. Although uncommon, AudioPlayers may have their assets unloaded at runtime if there is extreme memory pressure, in which case IsReady will become false.

LoopRegion

อ่านพร้อมๆ กัน

A range, in seconds, denoting a desired loop start and loop end within the PlaybackRegion of this AudioPlayer.

If the LoopRegion minimum is greater than the PlaybackRegion minimum, the loop starts from the LoopRegion minimum.

If the LoopRegion minimum is less than the PlaybackRegion minimum, the loop starts from the PlaybackRegion minimum.

If the LoopRegion maximum is greater than the PlaybackRegion maximum, the loop ends at the PlaybackRegion maximum.

If the LoopRegion maximum is less than the PlaybackRegion maximum, the loop ends at exactly the LoopRegion maximum.

If the LoopRegion minimum equals the LoopRegion maximum, the AudioPlayer uses the PlaybackRegion property instead.

Looping

อ่านพร้อมๆ กัน

Controls whether this AudioPlayer loops when exceeding the end of its TimeLength, LoopRegion, or PlaybackRegion.

PlaybackRegion

อ่านพร้อมๆ กัน

Range in seconds denoting a desired start time (minimum) and stop time (maximum) within the TimeLength.

If the PlaybackRegion minimum is greater than 0, the sound begins playing from the PlaybackRegion minimum time.

If the PlaybackRegion minimum is less than 0, the sound begins playing from 0.

If the PlaybackRegion maximum is greater than the TimeLength, the sound stops at TimeLength.

If the PlaybackRegion maximum is less than the TimeLength, the sound stops at exactly the PlaybackRegion maximum.

If the PlaybackRegion minimum equals the PlaybackRegion maximum, the sound plays in its entirety.

PlaybackSpeed

อ่านพร้อมๆ กัน

Multiplier controlling how quickly the asset will be played, directly controlling its perceived pitch. Ranges from 0 to 20.

TimeLength

อ่านอย่างเดียว
ไม่ซ้ำ
อ่านพร้อมๆ กัน

Denotes the length of the loaded AssetId in seconds.

TimePosition

อ่านพร้อมๆ กัน

Tracks and controls the current position of the playhead within the AssetId, in seconds.

Volume

อ่านพร้อมๆ กัน

Volume level which is multiplied onto the output audio stream, controlling how loudly the asset will be played. Ranges from 0 to 3.

วิธีการ

GetConnectedWires

Instances

Returns an array of Wires that are connected to the specified pin. AudioPlayer has one "Output" pin.

พารามิเตอร์

pin: string

ส่งค่ากลับ

Instances

Play

void

Plays the AudioPlayer from wherever its TimePosition is. Replicates from server to client.


ส่งค่ากลับ

void

Stop

void

Stops the AudioPlayer wherever its TimePosition is. Replicates from server to client.


ส่งค่ากลับ

void

GetWaveformAsync

ผลตอบแทน

พารามิเตอร์

timeRange: NumberRange
samples: number

ส่งค่ากลับ

อีเวนต์

Ended

Fires after the AudioPlayer has completed playback and stopped. Note this event will not fire for audio with Looped set to true since it continues playing upon reaching its end. This event will also not fire when the audio is stopped before playback has completed; for this, use AudioPlayer:GetPropertyChangedSignal() on the IsPlaying property.

This event is often used to destroy an AudioPlayer when it has completed playback.


Looped

Event that fires after the AudioPlayer loops. This happens when the audio reaches the end of its content (or the end of the LoopRegion if it is active) and Looping is true.

This event does not fire if the audio is looped manually by changing its TimePosition.


WiringChanged

พารามิเตอร์

connected: bool
pin: string
wire: Wire
instance: Instance