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()

概要

プロパティ

プロパティ

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.

方法

GetConnectedWires

パラメータ

pin: string

戻り値

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

イベント

Ended


Looped