#! /usr/bin/env ruby # -*- mode: ruby; coding: utf-8 -*- # Last updated: <2021/08/16 08:44:58 +0900> # sfml-audio-fiddle example 2. with soundbuffer. begin require 'sfml/audio' rescue => e require 'fiddle/import' require 'fiddle/types' module WinAPI extend Fiddle::Importer dlload 'kernel32.dll' include Fiddle::Win32Types extern 'int SetDllDirectory(LPCSTR)' end my_dll_dir_path = File.expand_path("..", __FILE__) WinAPI.SetDllDirectory(my_dll_dir_path) require 'sfml/audio' end buffer = SFML::SoundBuffer.new 'loop_bgm.ogg' sound = SFML::Sound.new buffer sound.play sleep buffer.get_duration + 1