{"id":15371519,"url":"https://github.com/nathanwalker/nativescript-ezaudio","last_synced_at":"2025-04-15T14:05:19.278Z","repository":{"id":57308508,"uuid":"50714433","full_name":"NathanWalker/nativescript-ezaudio","owner":"NathanWalker","description":"A NativeScript plugin for EZAudio: the simple, intuitive audio framework for iOS.","archived":false,"fork":false,"pushed_at":"2016-12-15T07:12:13.000Z","size":13728,"stargazers_count":9,"open_issues_count":1,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-15T14:05:00.164Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NathanWalker.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-01-30T07:28:28.000Z","updated_at":"2023-08-27T11:34:56.000Z","dependencies_parsed_at":"2022-09-10T03:43:34.341Z","dependency_job_id":null,"html_url":"https://github.com/NathanWalker/nativescript-ezaudio","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NathanWalker%2Fnativescript-ezaudio","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NathanWalker%2Fnativescript-ezaudio/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NathanWalker%2Fnativescript-ezaudio/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NathanWalker%2Fnativescript-ezaudio/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NathanWalker","download_url":"https://codeload.github.com/NathanWalker/nativescript-ezaudio/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249085439,"owners_count":21210267,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-01T13:47:21.888Z","updated_at":"2025-04-15T14:05:19.258Z","avatar_url":"https://github.com/NathanWalker.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"![alt text](http://i.imgur.com/ll5q68r.png \"EZAudioLogo\")\n\nA NativeScript plugin for the simple, intuitive audio framework for iOS.\n[EZAudio](https://github.com/syedhali/EZAudio)\n\n* [Install](#install)\n* [Usage](#usage)\n* [Screenshots](#screenshots)\n* [TNSEZAudioPlayer](#tnsezaudioplayer)\n* [TNSEZRecorder](#tnsezrecorder)\n* [UI Components](#ui-components)\n* [Why the `TNS` prefixed name?](#why-the-tns-prefixed-name)\n* [Try it/Contributing](https://github.com/NathanWalker/nativescript-ezaudio/blob/master/docs/CONTRIBUTING.md)\n\n# Install\n\n```\nnpm install nativescript-ezaudio --save\n```\n\n# Usage\n\n**IMPORTANT:** *Make sure you include `xmlns:ez=\"nativescript-ezaudio\"` on the Page element*\n\n```\n// main-page.xml\n\u003cPage xmlns=\"http://schemas.nativescript.org/tns.xsd\" \n  xmlns:ez=\"nativescript-ezaudio\"\n  loaded=\"pageLoaded\"\u003e\n  \u003cAbsoluteLayout width=\"100%\" height=\"100%\"\u003e\n    \u003cez:AudioPlot \n      class=\"audioPlot\" \n      plotColor=\"{{audioPlotColor}}\" \n      plotType=\"{{audioPlotType}}\" \n      fill=\"{{audioPlotFill}}\" \n      mirror=\"{{audioPlotMirror}}\" \n      bufferData=\"{{audioPlotBufferData}}\" /\u003e\n    \u003cButton text=\"{{btnTxt}}\" tap=\"{{toggleCurrentTrack}}\" /\u003e\n  \u003c/AbsoluteLayout\u003e\n\u003c/Page\u003e\n\n// app.css\n.audioPlot {\n  width:100%;\n  height:100%;\n  background-color: #000;\n  top:0;\n  left:0;\n}\nbutton {\n  font-size: 22;\n  horizontal-align: center;\n  margin:20px 0;\n  color:#FFF803;\n  top:20;\n  left:0;\n  width:100%;\n}\n\n// main-page.ts\nimport {AudioDemo} from \"./main-view-model\";\n\nfunction pageLoaded(args) {\n  var page = args.object;\n  page.bindingContext = new AudioDemo(page);\n}\nexports.pageLoaded = pageLoaded;\n\n// main-view-model.ts\nimport {Observable} from 'data/observable';\nimport {TNSEZAudioPlayer} from 'nativescript-ezaudio';\n\nexport class AudioDemo extends Observable {\n  public btnTxt: string = 'Play Track';\n  \n  // AudioPlot\n  public audioPlotColor: string = '#FFF803';\n  public audioPlotType: string = 'buffer';\n  public audioPlotFill: boolean = true;\n  public audioPlotMirror: boolean = true;\n  public audioPlotBufferData: any;\n  \n  // internal\n  private _player: any;\n  private _currentTrackIndex: number = 0;\n  private _tracks: Array\u003cstring\u003e = [\n    `any-mp3-you-like.mp3`,\n  ];\n\n  constructor(page: any) {\n    super();\n    this._player = new TNSEZAudioPlayer(true);\n    this._player.delegate().audioEvents.on('audioBuffer', (eventData) =\u003e {\n      this.set('audioPlotBufferData', {\n        buffer: eventData.data.buffer,\n        bufferSize: eventData.data.bufferSize\n      });\n    });\n  }\n\n  public toggleCurrentTrack() {\n    this._player.togglePlay(this._tracks[this._currentTrackIndex]);\n    this.toggleBtn();  \n  }\n  \n  private toggleBtn() {\n    this.set(`btnTxt`, `${this._player.isPlaying() ? 'Stop' : 'Play'} Track`);\n  }\n}\n```\n\n## Screenshots\n\nSample 1 |  Sample 2\n-------- | ---------\n![Sample1](screenshots/1.png) | ![Sample2](screenshots/2.png)\n\nSample 3 | Sample 4\n-------- | -------\n![Sample3](screenshots/3.png) | ![Sample4](screenshots/4.png)\n\n## TNSEZAudioPlayer\n\nAudioPlayer based on [EZAudioPlayer](https://github.com/syedhali/EZAudio#EZAudioPlayer).\n\nCreating:\n```\n// Option 1: simple\nthis._player = new TNSEZAudioPlayer();\n\n// Option 2: advanced\n// passing true to constructor will let the player know it should emit events\nthis._player = new TNSEZAudioPlayer(true);\n\n// it allows you to listen to events like so:\nthis._player.delegate().audioEvents.on('audioBuffer', (eventData) =\u003e {\n  this.set('audioPlotBufferData', {\n    buffer: eventData.data.buffer,\n    bufferSize: eventData.data.bufferSize\n  });\n});\n\n```\n\n#### Methods\n\nEvent |  Description\n-------- | ---------\n`togglePlay(fileName?: string, reloadTrack?: boolean)`: `void` | Allows toggle play/pause on a track as well as reloading the current track or reloading in a new track. First time will always load the track and play. `fileName` represents the path to the file in your resources. `reloadTrack` can be used to reload current track or load a new track.\n`pause()`: `void` | Pause track\n`isPlaying()`: `boolean` | Determine whether player is playing a track\n`duration()`: `number` | Length in seconds\n`formattedDuration()`: `string` | Formatted duration in '00:00'\n`totalFrames`: `number` | Total number of frames in the loaded track\n`formattedCurrentTime`: `string` | Formatted current time in '00:00'\n`setCurrentTime(time: number)`: `void` | Set the current time via a frame number\n`seekToFrame(frame: number)`: `void` | Seek playhead to a given frame number\n`volume()`: `number` | Get the current volume\n`setVolume(volume: number)`: `void` | Set the volume. Must be between 0 - 1.\n`pan()`: `number` | Get current pan settings\n`setPan(pan: number)`: `void` | Set pan left/right. Must be between -1 (left) and 1 (right). 0 is default (center). \n`device()`: `any` | Get current output device\n\n#### Events\n\nEvent |  Description\n-------- | ---------\n`audioBuffer` | When audio file is playing, get the `buffer` and `bufferSize` to set an `AudioPlot`'s `bufferData`\n`position` | Current frame number\n`reachedEnd` | When the end of the file is reached\n`changeAudioFile` | When the audio file is changed or set\n`changeOutput` | When the output device is changed\n`changePan` | When the pan is changed\n`changeVolume` | When the volume is changed\n`changePlayState` | When the player state changes, ie. play/pause\n`seeked` | When the audio file has been seeked to a certain frame number\n\n## TNSEZRecorder\n\nRecorder based on [EZRecorder](https://github.com/syedhali/EZAudio#ezrecorder).\n\nCreating:\n```\nthis._recorder = new TNSEZRecorder();\n\n// it allows you to listen to events like so:\nthis._recorder.delegate().audioEvents.on('audioBuffer', (eventData) =\u003e {\n  this.set('audioPlotBufferData', {\n    buffer: eventData.data.buffer,\n    bufferSize: eventData.data.bufferSize\n  });\n});\n\n```\n\n#### Methods\n\nEvent |  Description\n-------- | ---------\n`record(filePath: string)`: `void` | Record a `.m4a` file. Pass in an absoulte filePath.\n`stop()`: `void` | Stop recording\n`isRecording()`: `boolean` | Determine whether recorder is recording\n`deviceInputs()`: `Array\u003cany\u003e` | Collection of input devices\n`setDevice(device:any)`: `void` | Set the input device\n\n#### Events\n\nEvent |  Description\n-------- | ---------\n`audioBuffer` | While recording, get the `buffer` and `bufferSize` to set an `AudioPlot`'s `bufferData`\n`recordTime` | Current recording time\n\n## UI Components\n\n### AudioPlot\n\nDisplays an audio waveform and provides attributes to modify it's display.\n\nExample:\n```\n\u003cez:AudioPlot plotColor=\"#fff\" plotType=\"buffer\" fill=\"true\" mirror=\"true\" bufferData=\"{{audioPlotBufferData}}\" /\u003e\n```\n\n#### Attributes\n\nProperty |  Value\n-------- | ---------\n`plotColor`: `string` | Color of waveform. Any rgb hex value, ie. #fff\n`plotType`: `string` | `buffer` or `rolling`\n`fill`: `boolean` | Makes waveform solid with color. When `false`, it appears more like lines.\n`mirror`: `boolean` | Whether to mirror the waveform top/bottom.\n`bufferData`: `Object` | An Object representing the audio file's `buffer` and `bufferSize`. See [example implementation](https://github.com/NathanWalker/nativescript-ezaudio/blob/master/demo/app/player/player-view-model.ts#L54-L59)\n\n### Contributors\n\n* [NathanaelA](https://github.com/NathanaelA)\n\n## Why the TNS prefixed name?\n\n`TNS` stands for **T**elerik **N**ative**S**cript\n\niOS uses classes prefixed with `NS` (stemming from the [NeXTSTEP](https://en.wikipedia.org/wiki/NeXTSTEP) days of old):\nhttps://developer.apple.com/library/mac/documentation/Cocoa/Reference/Foundation/Classes/NSString_Class/\n\nTo avoid confusion with iOS native classes, `TNS` is used instead.\n\n## License\n\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnathanwalker%2Fnativescript-ezaudio","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnathanwalker%2Fnativescript-ezaudio","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnathanwalker%2Fnativescript-ezaudio/lists"}