Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Music and Web Builds #98

Open
HVukman opened this issue Jan 3, 2024 · 2 comments
Open

Music and Web Builds #98

HVukman opened this issue Jan 3, 2024 · 2 comments

Comments

@HVukman
Copy link

HVukman commented Jan 3, 2024

I tried to recreate the music example from the website, but the music is not playing. There is no error or a crash.
System: WSL with Ubuntu

proc main =
  # Initialization
  # --------------------------------------------------------------------------------------
  initWindow(screenWidth, screenHeight, "raylib [audio] example - music playing (streaming)")
  defer: closeWindow() # Close window and OpenGL context

  initAudioDevice() # Initialize audio device
  defer: closeAudioDevice() # Close audio device (music streaming is automatically stopped)

  let music = loadMusicStream("resources/country.mp3")
  
  # 1 second delay (device sampleRate*channels)
 
  var pause = false # Music playing paused
  when defined(emscripten):
    emscriptenSetMainLoop(updateDrawFrame, 0, 1)
  else:
    setTargetFPS(60) # Set our game to run at 60 frames-per-second
  # --------------------------------------------------------------------------------------
  # Main game loop
  while not windowShouldClose(): # Detect window close button or ESC key
    # Update
    # ------------------------------------------------------------------------------------
    updateMusicStream(music) # Update music buffer with new stream data

    # Restart music playing (stop and play)
    if isKeyPressed(Space):
        stopMusicStream(music)
        playMusicStream(music)

    # Pause/Resume music playing
    if isKeyPressed(P):
      pause = not pause
      if pause: pauseMusicStream(music)
      else: resumeMusicStream(music)

    # Get normalized time played for current music stream
    timePlayed = getMusicTimePlayed(music)/getMusicTimeLength(music)
    if timePlayed > 1: timePlayed = 1 # Make sure time played is no longer than music
    # ------------------------------------------------------------------------------------
    # Draw
    # ------------------------------------------------------------------------------------
    updateDrawFrame()
    # ------------------------------------------------------------------------------------
  

main()

music_example.zip

@planetis-m
Copy link
Owner

I have limited time to work on naylib, so please verify that your problem is caused by naylib and not something else. You can ask for help in discord first and then report the issue here. I can see that you forgot to include the minshell.html and the resources folder in your zipped file.

@planetis-m
Copy link
Owner

image

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants