Giter Site home page Giter Site logo

puzzletak_audioplayer's Introduction

Audio Playback Library with Visualizer

Description

The AudioPlayer module is designed to handle audio playback functionality in your application. It provides methods for starting and controlling audio playback, as well as handling various events related to audio playback.

Demo new

image_demo

Overview

This library is a versatile audio playback solution that allows you to seamlessly handle both offline and online audio content. It comes equipped with a built-in visualizer for real-time audio waveform display and an equalizer for fine-tuning audio output to meet your specific needs. Features Offline Audio Playback

Local Audio File Support: Easily play audio files stored on your device, making it perfect for music and sound effect playback in your applications.

Usage

  1. Initialization: Initialize the AudioPlayer and set the audio file path using the StartMusic method.

    Public Sub StartMusic(call As Object, path As String)
        ' Initialize the AudioPlayer
        Private AudioPlayer As PuzzleTak_AudioPlayer
        Private callBack As Object
        callBack = call
        AudioPlayer.initialize("AudioPlayer")
        AudioPlayer.PathFile = path
        Log("StartMusic")
        
        ' Notify the caller about the audio byte data
        CallSub2(callBack, "onGetByteMusic", AudioPlayer.Byte)
        
        ' Check if an audio session is available
        If AudioPlayer.AudioSessionId <> -1 Then
            Log(AudioPlayer.AudioSessionId)
            
            ' Notify the caller about the audio session ID
            If IsPaused(callBack) == False Then CallSub2(callBack, "onGetAudioSession", AudioPlayer.AudioSessionId)
        End If
    End Sub
  2. Event Handlers: The module includes various event handlers to monitor the audio playback status:

    • AudioPlayer_onBufferingUpdate(buffer As Int): Handles buffering updates.
    • AudioPlayer_onCompletion(): Handles audio playback completion.
    • AudioPlayer_onError(): Handles audio playback errors.
    • AudioPlayer_onInfo(p0 As Int, p1 As Int): Handles audio playback information updates.
    • AudioPlayer_onPrepared(): Handles audio player preparation.
    • AudioPlayer_onSeekComplete(): Handles seek operations completion.

    Customize these event handlers as needed for your application.

Handling Audio Data and Audio Session

The AudioPlayer module provides two important callback methods for handling audio data and audio session information.

onGetByteMusic(bytes() As Byte)

  • Description: This callback is triggered to provide the raw audio bytes to the SymmetricWaveVisualizer component for visualization or processing. It takes an array of bytes as a parameter, which represents the audio data.
  • Parameters:
    • bytes() As Byte: An array of bytes containing audio data.
  • Usage Example:
    Private Sub onGetByteMusic(bytes() As Byte)
        SymmetricWaveVisualizer.RawAudioBytes = bytes
    End Sub
Private Sub onGetAudioSession(sessionId As Int)
    SymmetricWaveVisualizer.AudioSessionId = sessionId
End Sub


## Example
Here's an example of how to use the `StartMusic` method to start audio playback:

```vbnet
Sub StartAudioPlayback()
	Dim sm As StoryMusic
	sm.Initialize(Me,"sm","dadadada","https://site.com/cover.png","https://site.com/file.mp3")
	Activity.AddView(sm.AsView,0,0,Activity.Width,Activity.Height)
	sm.initState
End Sub

puzzletak_audioplayer's People

Contributors

puzzletakx avatar

Stargazers

Bahman Teymouri Nezhad avatar jist avatar  avatar  avatar Ada avatar Mohamad Nematizadeh avatar Fateme Emadi avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.