From bf6747624fbae36814ac753281d67c8ac0ba520e Mon Sep 17 00:00:00 2001 From: Faizan Hasan Date: Sat, 4 Mar 2017 03:19:15 +0500 Subject: [PATCH 1/8] NPM fixes --- .npmignore | 9 +++++++++ package.json | 1 + 2 files changed, 10 insertions(+) create mode 100644 .npmignore diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..65ece33 --- /dev/null +++ b/.npmignore @@ -0,0 +1,9 @@ +# Node generated files +node_modules +npm-debug.log +# OS generated files +Thumbs.db +.DS_Store +# Ignored files +*.ts +!*.d.ts diff --git a/package.json b/package.json index 401046a..4e88343 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "typings": "./dist/index.d.ts", "scripts": { "prepublish": "tsc -p ./", + "release": "npm run prepublish && npm publish", "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { From 683c3fab64087fc1e692fffaeeb6d77abdeaf07e Mon Sep 17 00:00:00 2001 From: Faizan Hasan Date: Sat, 4 Mar 2017 03:25:50 +0500 Subject: [PATCH 2/8] Removed ignoring .ts files Demo Contains .ts files --- .npmignore | 1 - 1 file changed, 1 deletion(-) diff --git a/.npmignore b/.npmignore index 65ece33..f9b1e51 100644 --- a/.npmignore +++ b/.npmignore @@ -5,5 +5,4 @@ npm-debug.log Thumbs.db .DS_Store # Ignored files -*.ts !*.d.ts From 9cbc21dc1bd89b9f6829e92713973fa597eb3f68 Mon Sep 17 00:00:00 2001 From: Faizan Hasan Date: Fri, 10 Mar 2017 04:30:16 +0500 Subject: [PATCH 3/8] Updating package.json Update new version (2.2.0) of Ionic. Updated all the dependencies --- package.json | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/package.json b/package.json index 9a637e0..508eedb 100644 --- a/package.json +++ b/package.json @@ -10,18 +10,18 @@ "test": "echo \"Error: no test specified\" && exit 1" }, "dependencies": { - "@angular/common": "2.2.1", - "@angular/compiler": "2.2.1", - "@angular/compiler-cli": "2.2.1", - "@angular/core": "2.2.1", - "@angular/forms": "2.2.1", - "@angular/http": "2.2.1", - "@angular/platform-browser": "2.2.1", - "@angular/platform-browser-dynamic": "2.2.1", - "@angular/platform-server": "2.2.1", - "ionic-angular": "2.1.0", - "rxjs": "5.0.0-beta.12", - "zone.js": "0.6.26" + "@angular/common": "2.4.8", + "@angular/compiler": "2.4.8", + "@angular/compiler-cli": "2.4.8", + "@angular/core": "2.4.8", + "@angular/forms": "2.4.8", + "@angular/http": "2.4.8", + "@angular/platform-browser": "2.4.8", + "@angular/platform-browser-dynamic": "2.4.8", + "@angular/platform-server": "2.4.8", + "ionic-angular": "2.2.0", + "rxjs": "5.0.1", + "zone.js": "0.7.2" }, "devDependencies": { "typescript": "2.0.9" From b65a1b40a3ffaa89fa54e554e70418412638ca4e Mon Sep 17 00:00:00 2001 From: Faizan Hasan Date: Fri, 10 Mar 2017 04:34:55 +0500 Subject: [PATCH 4/8] Commenting AudioContext from ionic-audio-web-track.ts AOT failed to build because it cannot find the reference of AudioContext ``` Failed on type {"filePath":"/Users/faizanhasan/app/v2/node_modules/ionic-audio/dist/ion ic-audio-web-track.ts","name":"WebAudioTrack","members":[]} with error Error: Error encountered resolving symbol values statically. Could not resolve type AudioContext (position 26:105 in the original .ts file), resolving symbol WebAudioTrack in /Users/faizanhasan/app/v2/node_modules/ionic-audio/dist/ionic-audio-web- track.ts build prod failed: Error encountered resolving symbol values statically. Could not resolve type AudioContext (position 26:105 in the original .ts file), resolving symbol WebAudioTrack in /Users/faizanhasan/app/v2/node_modules/ionic-audio/dist/ionic-audio-web- track.ts ionic-app-script task: "build" Error: Error encountered resolving symbol values statically. Could not resolve type AudioContext (position 26:105 in the original .ts file), resolving symbol WebAudioTrack in /Users/faizanhasan/app/v2/node_modules/ionic-audio/dist/ionic-audio-web- track.ts Error: Error encountered resolving symbol values statically. Could not resolve type AudioContext (position 26:105 in the original .ts file), resolving symbol WebAudioTrack in /Users/faizanhasan/app/v2/node_modules/ionic-audio/dist/ionic-audio-web- track.ts ``` --- dist/ionic-audio-web-track.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/dist/ionic-audio-web-track.ts b/dist/ionic-audio-web-track.ts index 4e90feb..65bf560 100644 --- a/dist/ionic-audio-web-track.ts +++ b/dist/ionic-audio-web-track.ts @@ -23,8 +23,9 @@ export class WebAudioTrack implements IAudioTrack { private _id: number; private _isLoading: boolean; private _hasLoaded: boolean; - constructor(public src: string, @Optional() public preload: string = 'none', @Optional() private ctx: AudioContext = undefined) { + constructor(public src: string, @Optional() public preload: string = 'none') { // audio context not needed for now + // @Optional() private ctx: AudioContext = undefined // this.ctx = this.ctx || new AudioContext(); this.createAudio(); From ae40518de3e0d2ff7391a260f716908b279c7aa9 Mon Sep 17 00:00:00 2001 From: Faizan Hasan Date: Fri, 10 Mar 2017 04:37:05 +0500 Subject: [PATCH 5/8] Adding Readme and License file --- LICENSE.md | 0 README.md | 0 2 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 LICENSE.md create mode 100644 README.md diff --git a/LICENSE.md b/LICENSE.md new file mode 100644 index 0000000..e69de29 diff --git a/README.md b/README.md new file mode 100644 index 0000000..e69de29 From 70791616c529f85805dfafa7a072f0dd92560ccb Mon Sep 17 00:00:00 2001 From: Faizan Hasan Date: Fri, 10 Mar 2017 04:40:32 +0500 Subject: [PATCH 6/8] Adding Content to README.md and LICENSE.md --- LICENSE.md | 21 +++++++++ README.md | 135 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 156 insertions(+) diff --git a/LICENSE.md b/LICENSE.md index e69de29..d9e33b3 100644 --- a/LICENSE.md +++ b/LICENSE.md @@ -0,0 +1,21 @@ +The MIT License + +Copyright (c) 2015-2017 Ariel Faur. [https://github.com/arielfaur](https://github.com/arielfaur), ariel.faur@gmail.com + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in +all copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +THE SOFTWARE. \ No newline at end of file diff --git a/README.md b/README.md index e69de29..4ff6a5e 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,135 @@ +# Ionic Audio for Ionic 2 + +An audio player plugin for Ionic that works out of the box in the browser and device using an underlying audio provider depending on the environment. When running inside the browser the plugin will default to a Web Audio provider, whereas on a device it will switch to Cordova Media if cordova-plugin-media is available, otherwise falls back to web audio. + +## API Docs + +[API](http://arielfaur.github.io/ionic-audio/2.0/docs/modules/ionic-audio.html) + +## Demo + +[Demo](http://arielfaur.github.io/ionic-audio-example/) + +## Installation + +Make sure you have Ionic and Angular installed. + +``` +npm install --save ionic-audio +``` + +**For Ionic 2 version 2.0.0 to 2.1.0:** +``` +npm install --save ionic-audio@2.3.4 +``` + + +```typescript +import { IonicAudioModule } from 'ionic-audio'; + +@NgModule({ + imports: [ + IonicAudioModule.forRoot() + ] +}) +export class AppModule {} +``` + +## Usage + +**Import and inject `AudioProvider` where needed (optional):** + +```typescript +import {Component, Provider} from '@angular/core'; +import { AudioProvider } from 'ionic-audio'; + +@Component({ + templateUrl: 'build/pages/page1/page1.html' +}) +export class Page1 { + myTracks: any[]; + allTracks: any[]; + + constructor(private _audioProvider: AudioProvider) { + // plugin won't preload data by default, unless preload property is defined within json object - defaults to 'none' + this.myTracks = [{ + src: 'https://archive.org/download/JM2013-10-05.flac16/V0/jm2013-10-05-t12-MP3-V0.mp3', + artist: 'John Mayer', + title: 'Why Georgia', + art: 'img/johnmayer.jpg', + preload: 'metadata' // tell the plugin to preload metadata such as duration for this track, set to 'none' to turn off + }, + { + src: 'https://archive.org/download/JM2013-10-05.flac16/V0/jm2013-10-05-t30-MP3-V0.mp3', + artist: 'John Mayer', + title: 'Who Says', + art: 'img/johnmayer.jpg', + preload: 'metadata' // tell the plugin to preload metadata such as duration for this track, set to 'none' to turn off + }]; + } + + ngAfterContentInit() { + // get all tracks managed by AudioProvider so we can control playback via the API + this.allTracks = this._audioProvider.tracks; + } + + playSelectedTrack() { + // use AudioProvider to control selected track + this._audioProvider.play(this.selectedTrack); + } + + pauseSelectedTrack() { + // use AudioProvider to control selected track + this._audioProvider.pause(this.selectedTrack); + } + + onTrackFinished(track: any) { + console.log('Track finished', track) + } +} +``` + +**Add components to views:** + +```html + + + + + + + +
+

{{audio.title}}{{audio.artist}}

+ +
+
+
+
+``` + +# Ionic 1.x + +The source code for [Ionic 1.x](https://github.com/arielfaur/ionic-audio) +See [http://arielfaur.github.io/ionic-audio/index.html](http://arielfaur.github.io/ionic-audio/index.html) for Demo and Installation + +# Contributing + +1. Fork it! +2. Create your feature branch: `git checkout -b my-new-feature` +3. Commit your changes: `git commit -am 'Add some feature'` +4. Push to the branch: `git push origin my-new-feature` +5. Submit a pull request :D + +Thank you, [contributors]! + +[contributors]: https://github.com/arielfaur/ionic-audio/graphs/contributors + + +# Author + +* **Ariel Faur** [@arielfaur](https://github.com/arielfaur) + +## License + +This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details \ No newline at end of file From 53625b9c2970024bf363959773d3684f797525f5 Mon Sep 17 00:00:00 2001 From: Faizan Hasan Date: Fri, 10 Mar 2017 04:56:54 +0500 Subject: [PATCH 7/8] Updating Package.json @arielfaur you have to change` "ionic-audio": "^2.3.4"` with the latest version when you publish npm --- demo/package.json | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/demo/package.json b/demo/package.json index 724b6fb..514e0ee 100644 --- a/demo/package.json +++ b/demo/package.json @@ -10,23 +10,23 @@ "ionic:serve": "ionic-app-scripts serve" }, "dependencies": { - "@angular/common": "2.2.1", - "@angular/compiler": "2.2.1", - "@angular/compiler-cli": "2.2.1", - "@angular/core": "2.2.1", - "@angular/forms": "2.2.1", - "@angular/http": "2.2.1", - "@angular/platform-browser": "2.2.1", - "@angular/platform-browser-dynamic": "2.2.1", - "@angular/platform-server": "2.2.1", - "@ionic/storage": "1.1.7", - "ionic-angular": "2.1.0", + "@angular/common": "2.4.8", + "@angular/compiler": "2.4.8", + "@angular/compiler-cli": "2.4.8", + "@angular/core": "2.4.8", + "@angular/forms": "2.4.8", + "@angular/http": "2.4.8", + "@angular/platform-browser": "2.4.8", + "@angular/platform-browser-dynamic": "2.4.8", + "@angular/platform-server": "2.4.8", + "@ionic/storage": "2.0.0", + "ionic-angular": "2.2.0", "ionic-native": "2.4.1", "ionicons": "3.0.0", - "rxjs": "5.0.0-beta.12", + "rxjs": "5.0.1", "sw-toolbox": "3.4.0", - "zone.js": "0.6.26", - "ionic-audio": "^2.3.2" + "zone.js": "0.7.2", + "ionic-audio": "^2.3.4" }, "devDependencies": { "@ionic/app-scripts": "1.1.4", From 81da41b0ecaddc73d7f7bf832a0b3c8a465f15bc Mon Sep 17 00:00:00 2001 From: Faizan Hasan Date: Fri, 24 Mar 2017 08:06:15 +0500 Subject: [PATCH 8/8] Removed dependencies and Added into DevDependencies Updated dependencies only for developers. Added `npm run build` --- package.json | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/package.json b/package.json index 508eedb..15ff96a 100644 --- a/package.json +++ b/package.json @@ -6,14 +6,16 @@ "typings": "./dist/index.d.ts", "scripts": { "prepublish": "tsc -p ./", - "release": "npm run prepublish && npm publish", + "build": "npm install && npm run prepublish", + "release": "npm run build && npm publish", "test": "echo \"Error: no test specified\" && exit 1" }, - "dependencies": { + "dependencies": {}, + "devDependencies": { + "@angular/core": "2.4.8", "@angular/common": "2.4.8", "@angular/compiler": "2.4.8", - "@angular/compiler-cli": "2.4.8", - "@angular/core": "2.4.8", + "@angular/compiler-cli": "2.4.8", "@angular/forms": "2.4.8", "@angular/http": "2.4.8", "@angular/platform-browser": "2.4.8", @@ -21,9 +23,7 @@ "@angular/platform-server": "2.4.8", "ionic-angular": "2.2.0", "rxjs": "5.0.1", - "zone.js": "0.7.2" - }, - "devDependencies": { + "zone.js": "0.7.2", "typescript": "2.0.9" }, "repository": {