<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multitheftauto.com/wiki/PL/GetSoundBufferLength?action=history&amp;feed=atom</id>
	<title>PL/GetSoundBufferLength - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multitheftauto.com/wiki/PL/GetSoundBufferLength?action=history&amp;feed=atom"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=PL/GetSoundBufferLength&amp;action=history"/>
	<updated>2026-04-12T22:51:23Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=PL/GetSoundBufferLength&amp;diff=74163&amp;oldid=prev</id>
		<title>Tracer: Created page with &quot;__NOTOC__  {{Client function}} {{New feature/item|3.0157|1.5.6|16216|Ta funkcja pobiera długość bufora odtwarzania określonego dźwięku. Działa tylko ze strumieniami.}}  ==Składnia== &lt;syntaxhighlight lang=&quot;c++&quot;&gt; float getSoundBufferLength ( element dzwiek ) &lt;/syntaxhighlight&gt;   {{OOP||sound:getBufferLength|bufferLength}}  ===Wymagane argumenty===  *'''dzwiek:''' element dźwięku, którego długość bufora chcesz uzyskać.  ===Zwraca=== *...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=PL/GetSoundBufferLength&amp;diff=74163&amp;oldid=prev"/>
		<updated>2022-02-24T20:36:42Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;__NOTOC__  {{Client function}} {{New feature/item|3.0157|1.5.6|16216|Ta funkcja pobiera długość bufora odtwarzania określonego &lt;a href=&quot;/wiki/Sound&quot; class=&quot;mw-redirect&quot; title=&quot;Sound&quot;&gt;dźwięku&lt;/a&gt;. Działa tylko ze strumieniami.}}  ==Składnia== &amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt; float getSoundBufferLength ( element dzwiek ) &amp;lt;/syntaxhighlight&amp;gt;   {{OOP||&lt;a href=&quot;/wiki/Sound&quot; class=&quot;mw-redirect&quot; title=&quot;Sound&quot;&gt;sound&lt;/a&gt;:getBufferLength|bufferLength}}  ===Wymagane argumenty===  *&amp;#039;&amp;#039;&amp;#039;dzwiek:&amp;#039;&amp;#039;&amp;#039; element &lt;a href=&quot;/wiki/Sound&quot; class=&quot;mw-redirect&quot; title=&quot;Sound&quot;&gt;dźwięku&lt;/a&gt;, którego długość bufora chcesz uzyskać.  ===Zwraca=== *...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;__NOTOC__ &lt;br /&gt;
{{Client function}}&lt;br /&gt;
{{New feature/item|3.0157|1.5.6|16216|Ta funkcja pobiera długość bufora odtwarzania określonego [[sound|dźwięku]]. Działa tylko ze strumieniami.}}&lt;br /&gt;
&lt;br /&gt;
==Składnia==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;c++&amp;quot;&amp;gt;&lt;br /&gt;
float getSoundBufferLength ( element dzwiek )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
{{OOP||[[sound]]:getBufferLength|bufferLength}}&lt;br /&gt;
&lt;br /&gt;
===Wymagane argumenty=== &lt;br /&gt;
*'''dzwiek:''' element [[sound|dźwięku]], którego długość bufora chcesz uzyskać.&lt;br /&gt;
&lt;br /&gt;
===Zwraca===&lt;br /&gt;
* Wartość typu [[float]] wskazująca długość odtwarzania bufora [[sound|dźwięku]] w sekundach.&lt;br /&gt;
* ''false'' jeśli dźwięk nie jest strumieniem.&lt;br /&gt;
* ''nil'' jeśli dźwięk jest nieprawidłowy.&lt;br /&gt;
&lt;br /&gt;
==Przykład== &lt;br /&gt;
Ten przykład rysuje prosty odtwarzacz, który pokazuje długość pobranej części utworu.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local screenSize = Vector2(guiGetScreenSize())&lt;br /&gt;
local BOX_SIZE = Vector2(300, 100)&lt;br /&gt;
local LINE_SIZE = Vector2(BOX_SIZE.x, 10)&lt;br /&gt;
local BOX_POSITION = screenSize / 2 - BOX_SIZE / 2&lt;br /&gt;
local TITLE_POSITION = BOX_POSITION + Vector2(8, 8)&lt;br /&gt;
local ARTIST_POSITION = BOX_POSITION + Vector2(8, 32)&lt;br /&gt;
&lt;br /&gt;
local sound&lt;br /&gt;
&lt;br /&gt;
addCommandHandler(&amp;quot;playsound&amp;quot;, function ()&lt;br /&gt;
    if isElement(sound) then&lt;br /&gt;
        destroyElement(sound)&lt;br /&gt;
    end&lt;br /&gt;
    sound = playSound(&amp;quot;https://example.com/song.mp3&amp;quot;)&lt;br /&gt;
end)&lt;br /&gt;
&lt;br /&gt;
addCommandHandler(&amp;quot;stopsound&amp;quot;, function ()&lt;br /&gt;
    if isElement(sound) then&lt;br /&gt;
        destroyElement(sound)&lt;br /&gt;
    end&lt;br /&gt;
end)&lt;br /&gt;
&lt;br /&gt;
addEventHandler(&amp;quot;onClientRender&amp;quot;, root, function ()&lt;br /&gt;
    if isElement(sound) then&lt;br /&gt;
        local soundLength = getSoundLength(sound)&lt;br /&gt;
        local soundPosition = getSoundPosition(sound)&lt;br /&gt;
        local soundBufferLength = getSoundBufferLength(sound)&lt;br /&gt;
&lt;br /&gt;
        local meta = getSoundMetaTags(sound)&lt;br /&gt;
&lt;br /&gt;
        dxDrawRectangle(BOX_POSITION, BOX_SIZE, tocolor(20, 20, 20, 255), false, false)&lt;br /&gt;
&lt;br /&gt;
        if meta.title then&lt;br /&gt;
            dxDrawText(meta.title, TITLE_POSITION, 0, 0, tocolor(255, 255, 255, 255), 1.5, 1.5, &amp;quot;clear&amp;quot;)&lt;br /&gt;
        end&lt;br /&gt;
        if meta.artist then&lt;br /&gt;
            dxDrawText(meta.artist, ARTIST_POSITION, 0, 0, tocolor(255, 255, 255, 255), 1.0, 1.0, &amp;quot;clear&amp;quot;)&lt;br /&gt;
        end&lt;br /&gt;
&lt;br /&gt;
        dxDrawText((&amp;quot;%d:%02d&amp;quot;):format(soundPosition / 60, soundPosition % 60), BOX_POSITION + Vector2(8, BOX_SIZE.y - 32), BOX_POSITION + BOX_SIZE - Vector2(8, 0), tocolor(255, 255, 255, 255), 1.0, 1.0, &amp;quot;clear&amp;quot;, &amp;quot;left&amp;quot;, &amp;quot;top&amp;quot;)&lt;br /&gt;
        dxDrawText((&amp;quot;%d:%02d&amp;quot;):format(soundLength / 60, soundLength % 60), BOX_POSITION + Vector2(8, BOX_SIZE.y - 32), BOX_POSITION + BOX_SIZE - Vector2(8, 0), tocolor(255, 255, 255, 255), 1.0, 1.0, &amp;quot;clear&amp;quot;, &amp;quot;right&amp;quot;, &amp;quot;top&amp;quot;)&lt;br /&gt;
        &lt;br /&gt;
        -- draw seek bar&lt;br /&gt;
        local linePosition = Vector2(BOX_POSITION.x, BOX_POSITION.y + BOX_SIZE.y - LINE_SIZE.y)&lt;br /&gt;
        dxDrawRectangle(linePosition, LINE_SIZE, tocolor(255, 255, 255, 128), false, false)&lt;br /&gt;
&lt;br /&gt;
        -- draw buffer length&lt;br /&gt;
        if soundBufferLength then&lt;br /&gt;
            dxDrawRectangle(linePosition, Vector2(LINE_SIZE.x * (soundBufferLength / soundLength), LINE_SIZE.y), tocolor(255, 255, 255, 96), false, false)&lt;br /&gt;
        end&lt;br /&gt;
        -- draw current position&lt;br /&gt;
        dxDrawRectangle(linePosition, Vector2(LINE_SIZE.x * (soundPosition / soundLength), LINE_SIZE.y), tocolor(255, 255, 255, 255), false, false)&lt;br /&gt;
    end&lt;br /&gt;
end)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Zobacz także==&lt;br /&gt;
{{Client_audio_functions}}&lt;br /&gt;
&lt;br /&gt;
[[AR:getSoundBufferLength]]&lt;br /&gt;
[[en:getSoundBufferLength]]&lt;br /&gt;
[[PT-BR:getSoundBufferLength]]&lt;/div&gt;</summary>
		<author><name>Tracer</name></author>
	</entry>
</feed>