Giter Site home page Giter Site logo

1c7 / asaudiowaveformview Goto Github PK

View Code? Open in Web Editor NEW

This project forked from andrewmika/asaudiowaveformview

0.0 2.0 0.0 4.24 MB

a SIMPLE Audio Waveform View in Swift for iOS and it will adjust to fit the frame automatically

License: MIT License

Ruby 9.37% Swift 90.63%

asaudiowaveformview's Introduction

ASAudioWaveformView

Version License Platform

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

zoom

Requirements

swift 5.0+

Installation

ASAudioWaveformView is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'ASAudioWaveformView'

Usage

there are two ways to create waveform view, waveform will adjust to fit the frame automatically

  1. init with frame. completion is Optional

    let wave = ASAudioWaveformView.create(frame: CGRect(x: 0, y: 40, width: 200, height: 100)) { (config) in
        let url = Bundle.main.url(forResource: "test", withExtension: "mp3")
        config.audioURL(url).maxSamplesCount(500).fillColor(.systemTeal)
    } completion: { (empty) in
        print("-->draw Complete ,empty: \(empty)")
    }
  2. if you use Autolayout or set the frame later. completion is Optional

    let wave = ASAudioWaveformView()
    wave.createWaveform { (config) in
            let url = Bundle.main.url(forResource: "test", withExtension: "mp3")
            config.audioURL(url).positionType(.top).fillColor(.green)
    } completion: { (empty) in
        print("-->draw Complete ,empty: \(empty)")
    }

config waveform

    /// config waveform postion, the default is center
    public func positionType(_ type: ASAudioWaveformView.PositionType) -> ASAudioWaveformConfig

    /// config waveform content style, the default is polyline
    public func contentType(_ type: ASAudioWaveformView.ContentType) -> ASAudioWaveformConfig

    /// config waveform fill color, the default is yellow
    public func fillColor(_ color: UIColor) -> ASAudioWaveformConfig

    /// config waveform audio source
    public func audioURL(_ URL: URL?) -> ASAudioWaveformConfig

    /// config max samples count, the default is 1000
    public func maxSamplesCount(_ count: Int) -> ASAudioWaveformConfig
  1. position type center, content type polyLine

    center

  2. position type top, content type polyLine

    top

  3. position type bottom, content type polyLine

    bottom

  4. position type center, content type singleLine

    single

reload with different audio URL

waveform will adjust to fit the frame automatically

/// Refresh waveform by audio url
public func refreshWaveform(with audioURL: URL?)

Author

Andrew Shen, [email protected]

License

ASAudioWaveformView is available under the MIT license. See the LICENSE file for more info.

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.