├── .gitignore ├── .prettierrc ├── README.md ├── angular.json ├── browserslist ├── config.xml ├── ionic.config.json ├── karma.conf.js ├── package-lock.json ├── package.json ├── preview ├── demo │ └── demo.gif └── interface │ ├── android.jpg │ └── ios.png ├── resources ├── README.md ├── android │ ├── icon │ │ ├── drawable-hdpi-icon.png │ │ ├── drawable-ldpi-icon.png │ │ ├── drawable-mdpi-icon.png │ │ ├── drawable-xhdpi-icon.png │ │ ├── drawable-xxhdpi-icon.png │ │ └── drawable-xxxhdpi-icon.png │ ├── splash │ │ ├── drawable-land-hdpi-screen.png │ │ ├── drawable-land-ldpi-screen.png │ │ ├── drawable-land-mdpi-screen.png │ │ ├── drawable-land-xhdpi-screen.png │ │ ├── drawable-land-xxhdpi-screen.png │ │ ├── drawable-land-xxxhdpi-screen.png │ │ ├── drawable-port-hdpi-screen.png │ │ ├── drawable-port-ldpi-screen.png │ │ ├── drawable-port-mdpi-screen.png │ │ ├── drawable-port-xhdpi-screen.png │ │ ├── drawable-port-xxhdpi-screen.png │ │ └── drawable-port-xxxhdpi-screen.png │ └── xml │ │ └── network_security_config.xml ├── icon.png ├── ios │ ├── icon │ │ ├── icon-1024.png │ │ ├── icon-20.png │ │ ├── icon-20@2x.png │ │ ├── icon-20@3x.png │ │ ├── icon-24@2x.png │ │ ├── icon-27.5@2x.png │ │ ├── icon-29.png │ │ ├── icon-29@2x.png │ │ ├── icon-29@3x.png │ │ ├── icon-40.png │ │ ├── icon-40@2x.png │ │ ├── icon-40@3x.png │ │ ├── icon-44@2x.png │ │ ├── icon-50.png │ │ ├── icon-50@2x.png │ │ ├── icon-60.png │ │ ├── icon-60@2x.png │ │ ├── icon-60@3x.png │ │ ├── icon-72.png │ │ ├── icon-72@2x.png │ │ ├── icon-76.png │ │ ├── icon-76@2x.png │ │ ├── icon-83.5@2x.png │ │ ├── icon-86@2x.png │ │ ├── icon-98@2x.png │ │ ├── icon-small.png │ │ ├── icon-small@2x.png │ │ ├── icon-small@3x.png │ │ ├── icon.png │ │ └── icon@2x.png │ └── splash │ │ ├── Default-2436h.png │ │ ├── Default-568h@2x~iphone.png │ │ ├── Default-667h.png │ │ ├── Default-736h.png │ │ ├── Default-Landscape-2436h.png │ │ ├── Default-Landscape-736h.png │ │ ├── Default-Landscape@2x~ipad.png │ │ ├── Default-Landscape@~ipadpro.png │ │ ├── Default-Landscape~ipad.png │ │ ├── Default-Portrait@2x~ipad.png │ │ ├── Default-Portrait@~ipadpro.png │ │ ├── Default-Portrait~ipad.png │ │ ├── Default@2x~iphone.png │ │ ├── Default@2x~universal~anyany.png │ │ └── Default~iphone.png └── splash.png ├── src ├── app │ ├── app-routing.module.ts │ ├── app.component.html │ ├── app.component.scss │ ├── app.component.spec.ts │ ├── app.component.ts │ ├── app.module.ts │ └── home │ │ ├── home.module.ts │ │ ├── home.page.html │ │ ├── home.page.scss │ │ ├── home.page.spec.ts │ │ └── home.page.ts ├── assets │ ├── icon │ │ └── favicon.png │ └── img │ │ └── icon.png ├── environments │ ├── environment.prod.ts │ └── environment.ts ├── global.scss ├── index.html ├── main.ts ├── polyfills.ts ├── test.ts ├── theme │ └── variables.scss └── zone-flags.ts ├── tsconfig.app.json ├── tsconfig.json └── tsconfig.spec.json /.gitignore: -------------------------------------------------------------------------------- 1 | # Specifies intentionally untracked files to ignore when using Git 2 | # http://git-scm.com/docs/gitignore 3 | 4 | *~ 5 | *.sw[mnpcod] 6 | *.log 7 | *.tmp 8 | *.tmp.* 9 | log.txt 10 | *.sublime-project 11 | *.sublime-workspace 12 | .vscode/ 13 | npm-debug.log* 14 | 15 | .idea/ 16 | .ionic/ 17 | .sourcemaps/ 18 | .sass-cache/ 19 | .tmp/ 20 | .versions/ 21 | coverage/ 22 | www/ 23 | dist/ 24 | node_modules/ 25 | tmp/ 26 | temp/ 27 | platforms/ 28 | plugins/ 29 | plugins/android.json 30 | plugins/ios.json 31 | $RECYCLE.BIN/ 32 | 33 | .DS_Store 34 | Thumbs.db 35 | UserInterfaceState.xcuserstate 36 | -------------------------------------------------------------------------------- /.prettierrc: -------------------------------------------------------------------------------- 1 | { 2 | "singleQuote": true, 3 | "tabWidth": 2, 4 | "semi": true 5 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Ionic Audio Player (updated w/ Ionic v4 & Angular v8 in 2019) 2 | 3 | This is a simple audio player created with **Ionic 4+** / **Angular 8+** (updated in 2019) 4 | 5 | It features a **play/pause** button, **skip back/forward** buttons and a **progress bar** that displays the current position of the audio file. It also supports setting arbitrary positions using the **progress bar**. 6 | 7 | The app will automatically download the speech ***I Have a Dream*** from the Internet and prep for playing. You'll have to have an actual Android or iOS device to use this app. 8 | 9 | To peek into the code, feel free to clone the repo and navigate your way through. I think it's pretty straightforward. 10 | 11 | To try it out, use the following commands to install the app on an actual device: 12 | 13 | - For Android devices: make sure you have a wired connection from your phone to your Mac/PC, then run `ionic cordova run android --prod` in terminal. 14 | - For iOS devices: make sure you have a Mac, and run `ionic cordova prepare ios`. Then use Xcode to open up the project and install it to your iOS devices. 15 | 16 | ## Ionic Native Plugins 17 | 18 | - [File](https://ionicframework.com/docs/native/file/) 19 | - [File Transfer](https://ionicframework.com/docs/native/file-transfer/) 20 | - [Media](https://ionicframework.com/docs/native/media/) 21 | 22 | ## Support Platforms 23 | 24 | - Android 25 | - iOS 26 | 27 | ## UI Preview 28 | 29 | ### Android 30 | 31 | android 32 | 33 | ### iOS 34 | 35 | android 36 | 37 | ### GIF 38 | 39 | demo 40 | 41 | ## References 42 | 43 | Thanks to the following posts and sources, I was able to come up with this solution: 44 | 45 | - [Help: Using Cordova Media to create progress bar with ion-range](https://forum.ionicframework.com/t/using-cordova-media-to-create-progress-bar-with-ion-range/92368) 46 | - [Ionic Component: Range](http://ionicframework.com/docs/api/components/range/Range/) 47 | - [MediaManager isn't getting the correct duration #42](https://github.com/arielfaur/ionic-audio/issues/42) 48 | - [Cordova Media Capture - Find duration of audio file](https://stackoverflow.com/questions/38266702/cordova-media-capture-find-duration-of-audio-file) 49 | 50 | ## Author 51 | 52 | Created by [Michael Xieyang Liu](https://lxieyang.github.io) 53 | 54 | Last updated: Aug 20, 2019 55 | -------------------------------------------------------------------------------- /angular.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json", 3 | "version": 1, 4 | "defaultProject": "app", 5 | "newProjectRoot": "projects", 6 | "projects": { 7 | "app": { 8 | "root": "", 9 | "sourceRoot": "src", 10 | "projectType": "application", 11 | "prefix": "app", 12 | "schematics": {}, 13 | "architect": { 14 | "build": { 15 | "builder": "@angular-devkit/build-angular:browser", 16 | "options": { 17 | "outputPath": "www", 18 | "index": "src/index.html", 19 | "main": "src/main.ts", 20 | "polyfills": "src/polyfills.ts", 21 | "tsConfig": "tsconfig.app.json", 22 | "assets": [ 23 | { 24 | "glob": "**/*", 25 | "input": "src/assets", 26 | "output": "assets" 27 | }, 28 | { 29 | "glob": "**/*.svg", 30 | "input": "node_modules/ionicons/dist/ionicons/svg", 31 | "output": "./svg" 32 | } 33 | ], 34 | "styles": [ 35 | { 36 | "input": "src/theme/variables.scss" 37 | }, 38 | { 39 | "input": "src/global.scss" 40 | } 41 | ], 42 | "scripts": [] 43 | }, 44 | "configurations": { 45 | "production": { 46 | "fileReplacements": [ 47 | { 48 | "replace": "src/environments/environment.ts", 49 | "with": "src/environments/environment.prod.ts" 50 | } 51 | ], 52 | "optimization": true, 53 | "outputHashing": "all", 54 | "sourceMap": false, 55 | "extractCss": true, 56 | "namedChunks": false, 57 | "aot": true, 58 | "extractLicenses": true, 59 | "vendorChunk": false, 60 | "buildOptimizer": true, 61 | "budgets": [ 62 | { 63 | "type": "initial", 64 | "maximumWarning": "2mb", 65 | "maximumError": "5mb" 66 | } 67 | ] 68 | }, 69 | "ci": { 70 | "progress": false 71 | } 72 | } 73 | }, 74 | "serve": { 75 | "builder": "@angular-devkit/build-angular:dev-server", 76 | "options": { 77 | "browserTarget": "app:build" 78 | }, 79 | "configurations": { 80 | "production": { 81 | "browserTarget": "app:build:production" 82 | }, 83 | "ci": { 84 | "progress": false 85 | } 86 | } 87 | }, 88 | "extract-i18n": { 89 | "builder": "@angular-devkit/build-angular:extract-i18n", 90 | "options": { 91 | "browserTarget": "app:build" 92 | } 93 | }, 94 | "test": { 95 | "builder": "@angular-devkit/build-angular:karma", 96 | "options": { 97 | "main": "src/test.ts", 98 | "polyfills": "src/polyfills.ts", 99 | "tsConfig": "tsconfig.spec.json", 100 | "karmaConfig": "karma.conf.js", 101 | "styles": [], 102 | "scripts": [], 103 | "assets": [ 104 | { 105 | "glob": "favicon.ico", 106 | "input": "src/", 107 | "output": "/" 108 | }, 109 | { 110 | "glob": "**/*", 111 | "input": "src/assets", 112 | "output": "/assets" 113 | } 114 | ] 115 | }, 116 | "configurations": { 117 | "ci": { 118 | "progress": false, 119 | "watch": false 120 | } 121 | } 122 | }, 123 | "lint": { 124 | "builder": "@angular-devkit/build-angular:tslint", 125 | "options": { 126 | "tsConfig": [ 127 | "tsconfig.app.json", 128 | "tsconfig.spec.json", 129 | "e2e/tsconfig.json" 130 | ], 131 | "exclude": ["**/node_modules/**"] 132 | } 133 | }, 134 | "e2e": { 135 | "builder": "@angular-devkit/build-angular:protractor", 136 | "options": { 137 | "protractorConfig": "e2e/protractor.conf.js", 138 | "devServerTarget": "app:serve" 139 | }, 140 | "configurations": { 141 | "production": { 142 | "devServerTarget": "app:serve:production" 143 | }, 144 | "ci": { 145 | "devServerTarget": "app:serve:ci" 146 | } 147 | } 148 | }, 149 | "ionic-cordova-build": { 150 | "builder": "@ionic/angular-toolkit:cordova-build", 151 | "options": { 152 | "browserTarget": "app:build" 153 | }, 154 | "configurations": { 155 | "production": { 156 | "browserTarget": "app:build:production" 157 | } 158 | } 159 | }, 160 | "ionic-cordova-serve": { 161 | "builder": "@ionic/angular-toolkit:cordova-serve", 162 | "options": { 163 | "cordovaBuildTarget": "app:ionic-cordova-build", 164 | "devServerTarget": "app:serve" 165 | }, 166 | "configurations": { 167 | "production": { 168 | "cordovaBuildTarget": "app:ionic-cordova-build:production", 169 | "devServerTarget": "app:serve:production" 170 | } 171 | } 172 | } 173 | } 174 | } 175 | }, 176 | "cli": { 177 | "defaultCollection": "@ionic/angular-toolkit" 178 | }, 179 | "schematics": { 180 | "@ionic/angular-toolkit:component": { 181 | "styleext": "scss" 182 | }, 183 | "@ionic/angular-toolkit:page": { 184 | "styleext": "scss" 185 | } 186 | } 187 | } 188 | -------------------------------------------------------------------------------- /browserslist: -------------------------------------------------------------------------------- 1 | # This file is used by the build system to adjust CSS and JS output to support the specified browsers below. 2 | # For additional information regarding the format and rule options, please see: 3 | # https://github.com/browserslist/browserslist#queries 4 | 5 | # You can see what browsers were selected by your queries by running: 6 | # npx browserslist 7 | 8 | > 0.5% 9 | last 2 versions 10 | Firefox ESR 11 | not dead 12 | not IE 9-11 # For IE 9-11 support, remove 'not'. 13 | -------------------------------------------------------------------------------- /config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | I Have a Dream 4 | An awesome Ionic/Cordova app. 5 | Michael Xieyang Liu 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | 74 | 75 | 76 | 77 | 78 | 79 | 80 | 81 | 82 | 83 | 84 | 85 | 86 | 87 | 88 | 89 | 90 | 91 | 92 | 93 | 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | 103 | -------------------------------------------------------------------------------- /ionic.config.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "audio-playback", 3 | "integrations": { 4 | "cordova": {} 5 | }, 6 | "type": "angular" 7 | } 8 | -------------------------------------------------------------------------------- /karma.conf.js: -------------------------------------------------------------------------------- 1 | // Karma configuration file, see link for more information 2 | // https://karma-runner.github.io/1.0/config/configuration-file.html 3 | 4 | module.exports = function (config) { 5 | config.set({ 6 | basePath: '', 7 | frameworks: ['jasmine', '@angular-devkit/build-angular'], 8 | plugins: [ 9 | require('karma-jasmine'), 10 | require('karma-chrome-launcher'), 11 | require('karma-jasmine-html-reporter'), 12 | require('karma-coverage-istanbul-reporter'), 13 | require('@angular-devkit/build-angular/plugins/karma') 14 | ], 15 | client: { 16 | clearContext: false // leave Jasmine Spec Runner output visible in browser 17 | }, 18 | coverageIstanbulReporter: { 19 | dir: require('path').join(__dirname, '../coverage'), 20 | reports: ['html', 'lcovonly', 'text-summary'], 21 | fixWebpackSourcePaths: true 22 | }, 23 | reporters: ['progress', 'kjhtml'], 24 | port: 9876, 25 | colors: true, 26 | logLevel: config.LOG_INFO, 27 | autoWatch: true, 28 | browsers: ['Chrome'], 29 | singleRun: false 30 | }); 31 | }; 32 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "audio-playback", 3 | "version": "2.0.0", 4 | "author": "Ionic Framework", 5 | "homepage": "https://ionicframework.com/", 6 | "scripts": { 7 | "ng": "ng", 8 | "start": "ng serve", 9 | "build": "ng build", 10 | "test": "ng test", 11 | "lint": "ng lint", 12 | "e2e": "ng e2e" 13 | }, 14 | "private": true, 15 | "dependencies": { 16 | "@angular/common": "~8.1.2", 17 | "@angular/compiler": "~8.1.2", 18 | "@angular/core": "~8.1.2", 19 | "@angular/forms": "~8.1.2", 20 | "@angular/platform-browser": "~8.1.2", 21 | "@angular/platform-browser-dynamic": "~8.1.2", 22 | "@angular/router": "~8.1.2", 23 | "@ionic-native/core": "^5.0.0", 24 | "@ionic-native/file": "^5.12.0", 25 | "@ionic-native/file-transfer": "^5.12.0", 26 | "@ionic-native/media": "^5.12.0", 27 | "@ionic-native/splash-screen": "^5.0.0", 28 | "@ionic-native/status-bar": "^5.0.0", 29 | "@ionic/angular": "^4.7.1", 30 | "cordova-android": "^8.0.0", 31 | "cordova-ios": "5.0.1", 32 | "cordova-plugin-file": "^6.0.2", 33 | "cordova-plugin-file-transfer": "^1.7.1", 34 | "cordova-plugin-media": "^5.0.3", 35 | "core-js": "^2.5.4", 36 | "rxjs": "~6.5.1", 37 | "tslib": "^1.9.0", 38 | "zone.js": "~0.9.1" 39 | }, 40 | "devDependencies": { 41 | "@angular-devkit/architect": "~0.801.2", 42 | "@angular-devkit/build-angular": "~0.801.2", 43 | "@angular-devkit/core": "~8.1.2", 44 | "@angular-devkit/schematics": "~8.1.2", 45 | "@angular/cli": "~8.1.2", 46 | "@angular/compiler": "~8.1.2", 47 | "@angular/compiler-cli": "~8.1.2", 48 | "@angular/language-service": "~8.1.2", 49 | "@ionic/angular-toolkit": "~2.0.0", 50 | "@types/jasmine": "~3.3.8", 51 | "@types/jasminewd2": "~2.0.3", 52 | "@types/node": "~8.9.4", 53 | "codelyzer": "^5.0.0", 54 | "cordova-plugin-device": "^2.0.2", 55 | "cordova-plugin-ionic-keyboard": "^2.1.3", 56 | "cordova-plugin-ionic-webview": "^4.1.1", 57 | "cordova-plugin-splashscreen": "^5.0.2", 58 | "cordova-plugin-statusbar": "^2.4.2", 59 | "cordova-plugin-whitelist": "^1.3.3", 60 | "jasmine-core": "~3.4.0", 61 | "jasmine-spec-reporter": "~4.2.1", 62 | "karma": "~4.1.0", 63 | "karma-chrome-launcher": "~2.2.0", 64 | "karma-coverage-istanbul-reporter": "~2.0.1", 65 | "karma-jasmine": "~2.0.1", 66 | "karma-jasmine-html-reporter": "^1.4.0", 67 | "protractor": "~5.4.0", 68 | "ts-node": "~7.0.0", 69 | "tslint": "~5.15.0", 70 | "typescript": "~3.4.3" 71 | }, 72 | "description": "An Ionic project", 73 | "cordova": { 74 | "plugins": { 75 | "cordova-plugin-file": {}, 76 | "cordova-plugin-file-transfer": {}, 77 | "cordova-plugin-media": {}, 78 | "cordova-plugin-whitelist": {}, 79 | "cordova-plugin-statusbar": {}, 80 | "cordova-plugin-device": {}, 81 | "cordova-plugin-splashscreen": {}, 82 | "cordova-plugin-ionic-webview": { 83 | "ANDROID_SUPPORT_ANNOTATIONS_VERSION": "27.+" 84 | }, 85 | "cordova-plugin-ionic-keyboard": {} 86 | }, 87 | "platforms": [ 88 | "android", 89 | "ios" 90 | ] 91 | } 92 | } -------------------------------------------------------------------------------- /preview/demo/demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/preview/demo/demo.gif -------------------------------------------------------------------------------- /preview/interface/android.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/preview/interface/android.jpg -------------------------------------------------------------------------------- /preview/interface/ios.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/preview/interface/ios.png -------------------------------------------------------------------------------- /resources/README.md: -------------------------------------------------------------------------------- 1 | These are Cordova resources. You can replace icon.png and splash.png and run 2 | `ionic cordova resources` to generate custom icons and splash screens for your 3 | app. See `ionic cordova resources --help` for details. 4 | 5 | Cordova reference documentation: 6 | 7 | - Icons: https://cordova.apache.org/docs/en/latest/config_ref/images.html 8 | - Splash Screens: https://cordova.apache.org/docs/en/latest/reference/cordova-plugin-splashscreen/ 9 | -------------------------------------------------------------------------------- /resources/android/icon/drawable-hdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/android/icon/drawable-hdpi-icon.png -------------------------------------------------------------------------------- /resources/android/icon/drawable-ldpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/android/icon/drawable-ldpi-icon.png -------------------------------------------------------------------------------- /resources/android/icon/drawable-mdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/android/icon/drawable-mdpi-icon.png -------------------------------------------------------------------------------- /resources/android/icon/drawable-xhdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/android/icon/drawable-xhdpi-icon.png -------------------------------------------------------------------------------- /resources/android/icon/drawable-xxhdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/android/icon/drawable-xxhdpi-icon.png -------------------------------------------------------------------------------- /resources/android/icon/drawable-xxxhdpi-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/android/icon/drawable-xxxhdpi-icon.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-land-hdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/android/splash/drawable-land-hdpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-land-ldpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/android/splash/drawable-land-ldpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-land-mdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/android/splash/drawable-land-mdpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-land-xhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/android/splash/drawable-land-xhdpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-land-xxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/android/splash/drawable-land-xxhdpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-land-xxxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/android/splash/drawable-land-xxxhdpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-port-hdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/android/splash/drawable-port-hdpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-port-ldpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/android/splash/drawable-port-ldpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-port-mdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/android/splash/drawable-port-mdpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-port-xhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/android/splash/drawable-port-xhdpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-port-xxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/android/splash/drawable-port-xxhdpi-screen.png -------------------------------------------------------------------------------- /resources/android/splash/drawable-port-xxxhdpi-screen.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/android/splash/drawable-port-xxxhdpi-screen.png -------------------------------------------------------------------------------- /resources/android/xml/network_security_config.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | localhost 5 | 6 | 7 | -------------------------------------------------------------------------------- /resources/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/icon.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-1024.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/icon/icon-1024.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/icon/icon-20.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-20@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/icon/icon-20@2x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-20@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/icon/icon-20@3x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-24@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/icon/icon-24@2x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-27.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/icon/icon-27.5@2x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-29.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/icon/icon-29.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-29@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/icon/icon-29@2x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-29@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/icon/icon-29@3x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-40.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/icon/icon-40.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-40@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/icon/icon-40@2x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-40@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/icon/icon-40@3x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-44@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/icon/icon-44@2x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/icon/icon-50.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-50@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/icon/icon-50@2x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-60.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/icon/icon-60.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-60@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/icon/icon-60@2x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-60@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/icon/icon-60@3x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-72.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/icon/icon-72.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-72@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/icon/icon-72@2x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-76.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/icon/icon-76.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-76@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/icon/icon-76@2x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-83.5@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/icon/icon-83.5@2x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-86@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/icon/icon-86@2x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-98@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/icon/icon-98@2x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-small.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/icon/icon-small.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-small@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/icon/icon-small@2x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon-small@3x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/icon/icon-small@3x.png -------------------------------------------------------------------------------- /resources/ios/icon/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/icon/icon.png -------------------------------------------------------------------------------- /resources/ios/icon/icon@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/icon/icon@2x.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-2436h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/splash/Default-2436h.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-568h@2x~iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/splash/Default-568h@2x~iphone.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-667h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/splash/Default-667h.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-736h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/splash/Default-736h.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-Landscape-2436h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/splash/Default-Landscape-2436h.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-Landscape-736h.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/splash/Default-Landscape-736h.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-Landscape@2x~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/splash/Default-Landscape@2x~ipad.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-Landscape@~ipadpro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/splash/Default-Landscape@~ipadpro.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-Landscape~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/splash/Default-Landscape~ipad.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-Portrait@2x~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/splash/Default-Portrait@2x~ipad.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-Portrait@~ipadpro.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/splash/Default-Portrait@~ipadpro.png -------------------------------------------------------------------------------- /resources/ios/splash/Default-Portrait~ipad.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/splash/Default-Portrait~ipad.png -------------------------------------------------------------------------------- /resources/ios/splash/Default@2x~iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/splash/Default@2x~iphone.png -------------------------------------------------------------------------------- /resources/ios/splash/Default@2x~universal~anyany.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/splash/Default@2x~universal~anyany.png -------------------------------------------------------------------------------- /resources/ios/splash/Default~iphone.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/ios/splash/Default~iphone.png -------------------------------------------------------------------------------- /resources/splash.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/resources/splash.png -------------------------------------------------------------------------------- /src/app/app-routing.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { PreloadAllModules, RouterModule, Routes } from '@angular/router'; 3 | 4 | const routes: Routes = [ 5 | { path: '', redirectTo: 'home', pathMatch: 'full' }, 6 | { path: 'home', loadChildren: () => import('./home/home.module').then( m => m.HomePageModule)}, 7 | ]; 8 | 9 | @NgModule({ 10 | imports: [ 11 | RouterModule.forRoot(routes, { preloadingStrategy: PreloadAllModules }) 12 | ], 13 | exports: [RouterModule] 14 | }) 15 | export class AppRoutingModule { } 16 | -------------------------------------------------------------------------------- /src/app/app.component.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/app/app.component.scss: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/src/app/app.component.scss -------------------------------------------------------------------------------- /src/app/app.component.spec.ts: -------------------------------------------------------------------------------- 1 | import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core'; 2 | import { TestBed, async } from '@angular/core/testing'; 3 | 4 | import { Platform } from '@ionic/angular'; 5 | import { SplashScreen } from '@ionic-native/splash-screen/ngx'; 6 | import { StatusBar } from '@ionic-native/status-bar/ngx'; 7 | 8 | import { AppComponent } from './app.component'; 9 | 10 | describe('AppComponent', () => { 11 | 12 | let statusBarSpy, splashScreenSpy, platformReadySpy, platformSpy; 13 | 14 | beforeEach(async(() => { 15 | statusBarSpy = jasmine.createSpyObj('StatusBar', ['styleDefault']); 16 | splashScreenSpy = jasmine.createSpyObj('SplashScreen', ['hide']); 17 | platformReadySpy = Promise.resolve(); 18 | platformSpy = jasmine.createSpyObj('Platform', { ready: platformReadySpy }); 19 | 20 | TestBed.configureTestingModule({ 21 | declarations: [AppComponent], 22 | schemas: [CUSTOM_ELEMENTS_SCHEMA], 23 | providers: [ 24 | { provide: StatusBar, useValue: statusBarSpy }, 25 | { provide: SplashScreen, useValue: splashScreenSpy }, 26 | { provide: Platform, useValue: platformSpy }, 27 | ], 28 | }).compileComponents(); 29 | })); 30 | 31 | it('should create the app', () => { 32 | const fixture = TestBed.createComponent(AppComponent); 33 | const app = fixture.debugElement.componentInstance; 34 | expect(app).toBeTruthy(); 35 | }); 36 | 37 | it('should initialize the app', async () => { 38 | TestBed.createComponent(AppComponent); 39 | expect(platformSpy.ready).toHaveBeenCalled(); 40 | await platformReadySpy; 41 | expect(statusBarSpy.styleDefault).toHaveBeenCalled(); 42 | expect(splashScreenSpy.hide).toHaveBeenCalled(); 43 | }); 44 | 45 | // TODO: add more tests! 46 | 47 | }); 48 | -------------------------------------------------------------------------------- /src/app/app.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | import { Platform } from '@ionic/angular'; 4 | import { SplashScreen } from '@ionic-native/splash-screen/ngx'; 5 | import { StatusBar } from '@ionic-native/status-bar/ngx'; 6 | 7 | @Component({ 8 | selector: 'app-root', 9 | templateUrl: 'app.component.html', 10 | styleUrls: ['app.component.scss'] 11 | }) 12 | export class AppComponent { 13 | constructor( 14 | private platform: Platform, 15 | private splashScreen: SplashScreen, 16 | private statusBar: StatusBar 17 | ) { 18 | this.initializeApp(); 19 | } 20 | 21 | initializeApp() { 22 | this.platform.ready().then(() => { 23 | this.statusBar.styleDefault(); 24 | if (this.platform.is('android')) { 25 | this.statusBar.styleLightContent(); 26 | } 27 | this.splashScreen.hide(); 28 | }); 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /src/app/app.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { BrowserModule } from '@angular/platform-browser'; 3 | import { RouteReuseStrategy } from '@angular/router'; 4 | import { DatePipe } from '@angular/common'; 5 | 6 | import { IonicModule, IonicRouteStrategy } from '@ionic/angular'; 7 | import { SplashScreen } from '@ionic-native/splash-screen/ngx'; 8 | import { StatusBar } from '@ionic-native/status-bar/ngx'; 9 | import { File } from '@ionic-native/file/ngx'; 10 | import { 11 | FileTransfer, 12 | FileTransferObject 13 | } from '@ionic-native/file-transfer/ngx'; 14 | import { Media } from '@ionic-native/media/ngx'; 15 | 16 | import { AppComponent } from './app.component'; 17 | import { AppRoutingModule } from './app-routing.module'; 18 | 19 | @NgModule({ 20 | declarations: [AppComponent], 21 | entryComponents: [], 22 | imports: [BrowserModule, IonicModule.forRoot(), AppRoutingModule], 23 | providers: [ 24 | StatusBar, 25 | SplashScreen, 26 | Media, 27 | File, 28 | FileTransfer, 29 | FileTransferObject, 30 | DatePipe, 31 | { provide: RouteReuseStrategy, useClass: IonicRouteStrategy } 32 | ], 33 | bootstrap: [AppComponent] 34 | }) 35 | export class AppModule {} 36 | -------------------------------------------------------------------------------- /src/app/home/home.module.ts: -------------------------------------------------------------------------------- 1 | import { NgModule } from '@angular/core'; 2 | import { CommonModule } from '@angular/common'; 3 | import { IonicModule } from '@ionic/angular'; 4 | import { FormsModule } from '@angular/forms'; 5 | import { RouterModule } from '@angular/router'; 6 | 7 | import { HomePage } from './home.page'; 8 | 9 | @NgModule({ 10 | imports: [ 11 | CommonModule, 12 | FormsModule, 13 | IonicModule, 14 | RouterModule.forChild([ 15 | { 16 | path: '', 17 | component: HomePage 18 | } 19 | ]) 20 | ], 21 | declarations: [HomePage] 22 | }) 23 | export class HomePageModule {} 24 | -------------------------------------------------------------------------------- /src/app/home/home.page.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 |
6 |

{{ title }}

7 |
8 | 9 | 10 |
11 | ihaveadream 12 |
13 |
14 | 15 | 16 |
17 | 18 | 19 | {{ position*1000 | date:'mm:ss' }} 20 | --:-- 21 | {{ duration*1000 | date:'mm:ss' }} 22 | 23 |
24 |
25 | 26 | 27 | 28 | 29 | 30 | 32 |      33 | 34 | 35 | 36 | 37 | 39 | 40 | 41 | 42 | 44 | 45 | 46 | 47 | 48 | 49 | 51 |      52 | 53 | 54 | 55 | 56 | 57 |
58 |
-------------------------------------------------------------------------------- /src/app/home/home.page.scss: -------------------------------------------------------------------------------- 1 | .avatar { 2 | display: block; 3 | width: 250px; 4 | height: 250px; 5 | border-radius: 50%; 6 | background-image: url('https://s-media-cache-ak0.pinimg.com/originals/82/8d/9c/828d9ce86050123bd1ec659604fab945.jpg'); 7 | background-repeat: no-repeat; 8 | background-position: center center; 9 | background-size: cover; 10 | 11 | margin: 0 auto; 12 | border: 2px solid #f1f1f1; 13 | box-shadow: 0 0 5px #999; 14 | } 15 | 16 | .play-pause-btn { 17 | display: inline-block; 18 | width: 80px; 19 | height: 80px; 20 | box-shadow: 0 0 10px #999; 21 | font-size: 2.3em; 22 | border-radius: 50%; 23 | } 24 | 25 | .skip-btn { 26 | display: inline-block; 27 | vertical-align: middle; 28 | border-radius: 50%; 29 | width: 50px; 30 | height: 50px; 31 | box-shadow: 0 0 10px #999; 32 | } -------------------------------------------------------------------------------- /src/app/home/home.page.spec.ts: -------------------------------------------------------------------------------- 1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing'; 2 | import { IonicModule } from '@ionic/angular'; 3 | 4 | import { HomePage } from './home.page'; 5 | 6 | describe('HomePage', () => { 7 | let component: HomePage; 8 | let fixture: ComponentFixture; 9 | 10 | beforeEach(async(() => { 11 | TestBed.configureTestingModule({ 12 | declarations: [ HomePage ], 13 | imports: [IonicModule.forRoot()] 14 | }).compileComponents(); 15 | 16 | fixture = TestBed.createComponent(HomePage); 17 | component = fixture.componentInstance; 18 | fixture.detectChanges(); 19 | })); 20 | 21 | it('should create', () => { 22 | expect(component).toBeTruthy(); 23 | }); 24 | }); 25 | -------------------------------------------------------------------------------- /src/app/home/home.page.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit } from '@angular/core'; 2 | import { 3 | NavController, 4 | LoadingController, 5 | Platform, 6 | ToastController 7 | } from '@ionic/angular'; 8 | import { DatePipe } from '@angular/common'; 9 | 10 | import { 11 | FileTransfer, 12 | FileTransferObject 13 | } from '@ionic-native/file-transfer/ngx'; 14 | import { File } from '@ionic-native/file/ngx'; 15 | import { Media, MediaObject } from '@ionic-native/media/ngx'; 16 | 17 | @Component({ 18 | selector: 'app-home', 19 | templateUrl: 'home.page.html', 20 | styleUrls: ['home.page.scss'] 21 | }) 22 | export class HomePage implements OnInit { 23 | title = 'I Have a Dream'; 24 | filename = 'I_Have_a_Dream.mp3'; 25 | curr_playing_file: MediaObject; 26 | storageDirectory: any; 27 | 28 | is_playing: boolean = false; 29 | is_in_play: boolean = false; 30 | is_ready: boolean = false; 31 | 32 | message: any; 33 | 34 | duration: any = -1; 35 | position: any = 0; 36 | 37 | get_duration_interval: any; 38 | get_position_interval: any; 39 | 40 | constructor( 41 | private platform: Platform, 42 | private loadingCtrl: LoadingController, 43 | private toastCtrl: ToastController, 44 | private file: File, 45 | private transfer: FileTransfer, 46 | private media: Media, 47 | private datePipe: DatePipe 48 | ) { 49 | this.platform.ready().then(() => { 50 | if (this.platform.is('ios')) { 51 | this.storageDirectory = this.file.dataDirectory; 52 | } else if (this.platform.is('android')) { 53 | this.storageDirectory = this.file.externalDataDirectory; 54 | } else { 55 | this.storageDirectory = this.file.cacheDirectory; 56 | } 57 | }); 58 | } 59 | 60 | ngOnInit() { 61 | this.prepareAudioFile(); 62 | } 63 | 64 | prepareAudioFile() { 65 | let url = 66 | 'https://ia800207.us.archive.org/29/items/MLKDream/MLKDream_64kb.mp3'; 67 | this.platform.ready().then(() => { 68 | this.file 69 | .resolveDirectoryUrl(this.storageDirectory) 70 | .then(resolvedDirectory => { 71 | // inspired by: https://github.com/ionic-team/ionic-native/issues/1711 72 | console.log('resolved directory: ' + resolvedDirectory.nativeURL); 73 | this.file 74 | .checkFile(resolvedDirectory.nativeURL, this.filename) 75 | .then(data => { 76 | if (data == true) { 77 | // exist 78 | this.getDurationAndSetToPlay(); 79 | } else { 80 | // not sure if File plugin will return false. go to download 81 | console.log('not found!'); 82 | throw { code: 1, message: 'NOT_FOUND_ERR' }; 83 | } 84 | }) 85 | .catch(async err => { 86 | console.log('Error occurred while checking local files:'); 87 | console.log(err); 88 | if (err.code == 1) { 89 | // not found! download! 90 | console.log('not found! download!'); 91 | let loadingEl = await this.loadingCtrl.create({ 92 | message: 'Downloading the song from the web...' 93 | }); 94 | loadingEl.present(); 95 | const fileTransfer: FileTransferObject = this.transfer.create(); 96 | fileTransfer 97 | .download(url, this.storageDirectory + this.filename) 98 | .then(entry => { 99 | console.log('download complete' + entry.toURL()); 100 | loadingEl.dismiss(); 101 | this.getDurationAndSetToPlay(); 102 | }) 103 | .catch(err_2 => { 104 | console.log('Download error!'); 105 | loadingEl.dismiss(); 106 | console.log(err_2); 107 | }); 108 | } 109 | }); 110 | }); 111 | }); 112 | } 113 | 114 | createAudioFile(pathToDirectory, filename): MediaObject { 115 | if (this.platform.is('ios')) { 116 | //ios 117 | return this.media.create( 118 | pathToDirectory.replace(/^file:\/\//, '') + '/' + filename 119 | ); 120 | } else { 121 | // android 122 | return this.media.create(pathToDirectory + filename); 123 | } 124 | } 125 | 126 | getDurationAndSetToPlay() { 127 | this.curr_playing_file = this.createAudioFile( 128 | this.storageDirectory, 129 | this.filename 130 | ); 131 | 132 | this.curr_playing_file.play(); 133 | this.curr_playing_file.setVolume(0.0); // you don't want users to notice that you are playing the file 134 | let self = this; 135 | this.get_duration_interval = setInterval(function() { 136 | if (self.duration == -1) { 137 | self.duration = ~~self.curr_playing_file.getDuration(); // make it an integer 138 | } else { 139 | self.curr_playing_file.stop(); 140 | self.curr_playing_file.release(); 141 | self.setRecordingToPlay(); 142 | clearInterval(self.get_duration_interval); 143 | } 144 | }, 100); 145 | } 146 | 147 | getAndSetCurrentAudioPosition() { 148 | let diff = 1; 149 | let self = this; 150 | this.get_position_interval = setInterval(function() { 151 | let last_position = self.position; 152 | self.curr_playing_file.getCurrentPosition().then(position => { 153 | if (position >= 0 && position < self.duration) { 154 | if (Math.abs(last_position - position) >= diff) { 155 | // set position 156 | self.curr_playing_file.seekTo(last_position * 1000); 157 | } else { 158 | // update position for display 159 | self.position = position; 160 | } 161 | } else if (position >= self.duration) { 162 | self.stopPlayRecording(); 163 | self.setRecordingToPlay(); 164 | } 165 | }); 166 | }, 100); 167 | } 168 | 169 | setRecordingToPlay() { 170 | this.curr_playing_file = this.createAudioFile( 171 | this.storageDirectory, 172 | this.filename 173 | ); 174 | this.curr_playing_file.onStatusUpdate.subscribe(status => { 175 | // 2: playing 176 | // 3: pause 177 | // 4: stop 178 | this.message = status; 179 | switch (status) { 180 | case 1: 181 | this.is_in_play = false; 182 | break; 183 | case 2: // 2: playing 184 | this.is_in_play = true; 185 | this.is_playing = true; 186 | break; 187 | case 3: // 3: pause 188 | this.is_in_play = true; 189 | this.is_playing = false; 190 | break; 191 | case 4: // 4: stop 192 | default: 193 | this.is_in_play = false; 194 | this.is_playing = false; 195 | break; 196 | } 197 | }); 198 | console.log('audio file set'); 199 | this.message = 'audio file set'; 200 | this.is_ready = true; 201 | this.getAndSetCurrentAudioPosition(); 202 | } 203 | 204 | playRecording() { 205 | this.curr_playing_file.play(); 206 | this.toastCtrl 207 | .create({ 208 | message: `Start playing from ${this.fmtMSS(this.position)}`, 209 | duration: 2000 210 | }) 211 | .then(toastEl => toastEl.present()); 212 | } 213 | 214 | pausePlayRecording() { 215 | this.curr_playing_file.pause(); 216 | this.toastCtrl 217 | .create({ 218 | message: `Paused at ${this.fmtMSS(this.position)}`, 219 | duration: 2000 220 | }) 221 | .then(toastEl => toastEl.present()); 222 | } 223 | 224 | stopPlayRecording() { 225 | this.curr_playing_file.stop(); 226 | this.curr_playing_file.release(); 227 | clearInterval(this.get_position_interval); 228 | this.position = 0; 229 | } 230 | 231 | controlSeconds(action) { 232 | let step = 15; 233 | 234 | let number = this.position; 235 | switch (action) { 236 | case 'back': 237 | this.position = number < step ? 0.001 : number - step; 238 | this.toastCtrl 239 | .create({ 240 | message: `Went back ${step} seconds`, 241 | duration: 2000 242 | }) 243 | .then(toastEl => toastEl.present()); 244 | break; 245 | case 'forward': 246 | this.position = 247 | number + step < this.duration ? number + step : this.duration; 248 | this.toastCtrl 249 | .create({ 250 | message: `Went forward ${step} seconds`, 251 | duration: 2000 252 | }) 253 | .then(toastEl => toastEl.present()); 254 | break; 255 | default: 256 | break; 257 | } 258 | } 259 | 260 | fmtMSS(s) { 261 | return this.datePipe.transform(s * 1000, 'mm:ss'); 262 | 263 | /** The following has been replaced with Angular DatePipe */ 264 | // // accepts seconds as Number or String. Returns m:ss 265 | // return ( 266 | // (s - // take value s and subtract (will try to convert String to Number) 267 | // (s %= 60)) / // the new value of s, now holding the remainder of s divided by 60 268 | // // (will also try to convert String to Number) 269 | // 60 + // and divide the resulting Number by 60 270 | // // (can never result in a fractional value = no need for rounding) 271 | // // to which we concatenate a String (converts the Number to String) 272 | // // who's reference is chosen by the conditional operator: 273 | // (9 < s // if seconds is larger than 9 274 | // ? ':' // then we don't need to prepend a zero 275 | // : ':0') + // else we do need to prepend a zero 276 | // s 277 | // ); // and we add Number s to the string (converting it to String as well) 278 | } 279 | } 280 | -------------------------------------------------------------------------------- /src/assets/icon/favicon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/src/assets/icon/favicon.png -------------------------------------------------------------------------------- /src/assets/img/icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/lxieyang/ionic-audio-player/67e94bc844a193c9383f9075692c5e22cb77501f/src/assets/img/icon.png -------------------------------------------------------------------------------- /src/environments/environment.prod.ts: -------------------------------------------------------------------------------- 1 | export const environment = { 2 | production: true 3 | }; 4 | -------------------------------------------------------------------------------- /src/environments/environment.ts: -------------------------------------------------------------------------------- 1 | // This file can be replaced during build by using the `fileReplacements` array. 2 | // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`. 3 | // The list of file replacements can be found in `angular.json`. 4 | 5 | export const environment = { 6 | production: false 7 | }; 8 | 9 | /* 10 | * For easier debugging in development mode, you can import the following file 11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`. 12 | * 13 | * This import should be commented out in production mode because it will have a negative impact 14 | * on performance if an error is thrown. 15 | */ 16 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI. 17 | -------------------------------------------------------------------------------- /src/global.scss: -------------------------------------------------------------------------------- 1 | /* 2 | * App Global CSS 3 | * ---------------------------------------------------------------------------- 4 | * Put style rules here that you want to apply globally. These styles are for 5 | * the entire app and not just one component. Additionally, this file can be 6 | * used as an entry point to import other CSS/Sass files to be included in the 7 | * output CSS. 8 | * For more information on global stylesheets, visit the documentation: 9 | * https://ionicframework.com/docs/layout/global-stylesheets 10 | */ 11 | 12 | /* Core CSS required for Ionic components to work properly */ 13 | @import "~@ionic/angular/css/core.css"; 14 | 15 | /* Basic CSS for apps built with Ionic */ 16 | @import "~@ionic/angular/css/normalize.css"; 17 | @import "~@ionic/angular/css/structure.css"; 18 | @import "~@ionic/angular/css/typography.css"; 19 | @import '~@ionic/angular/css/display.css'; 20 | 21 | /* Optional CSS utils that can be commented out */ 22 | @import "~@ionic/angular/css/padding.css"; 23 | @import "~@ionic/angular/css/float-elements.css"; 24 | @import "~@ionic/angular/css/text-alignment.css"; 25 | @import "~@ionic/angular/css/text-transformation.css"; 26 | @import "~@ionic/angular/css/flex-utils.css"; 27 | -------------------------------------------------------------------------------- /src/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | Ionic App 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | -------------------------------------------------------------------------------- /src/main.ts: -------------------------------------------------------------------------------- 1 | import { enableProdMode } from '@angular/core'; 2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic'; 3 | 4 | import { AppModule } from './app/app.module'; 5 | import { environment } from './environments/environment'; 6 | 7 | if (environment.production) { 8 | enableProdMode(); 9 | } 10 | 11 | platformBrowserDynamic().bootstrapModule(AppModule) 12 | .catch(err => console.log(err)); 13 | -------------------------------------------------------------------------------- /src/polyfills.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * This file includes polyfills needed by Angular and is loaded before the app. 3 | * You can add your own extra polyfills to this file. 4 | * 5 | * This file is divided into 2 sections: 6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers. 7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main 8 | * file. 9 | * 10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that 11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera), 12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile. 13 | * 14 | * Learn more in https://angular.io/guide/browser-support 15 | */ 16 | 17 | /*************************************************************************************************** 18 | * BROWSER POLYFILLS 19 | */ 20 | 21 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */ 22 | // import 'classlist.js'; // Run `npm install --save classlist.js`. 23 | 24 | /** 25 | * Web Animations `@angular/platform-browser/animations` 26 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari. 27 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0). 28 | */ 29 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`. 30 | 31 | /** 32 | * By default, zone.js will patch all possible macroTask and DomEvents 33 | * user can disable parts of macroTask/DomEvents patch by setting following flags 34 | * because those flags need to be set before `zone.js` being loaded, and webpack 35 | * will put import in the top of bundle, so user need to create a separate file 36 | * in this directory (for example: zone-flags.ts), and put the following flags 37 | * into that file, and then add the following code before importing zone.js. 38 | * import './zone-flags.ts'; 39 | * 40 | * The flags allowed in zone-flags.ts are listed here. 41 | * 42 | * The following flags will work for all browsers. 43 | * 44 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame 45 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick 46 | * (window as any).__zone_symbol__BLACK_LISTED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames 47 | * 48 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js 49 | * with the following flag, it will bypass `zone.js` patch for IE/Edge 50 | * 51 | * (window as any).__Zone_enable_cross_context_check = true; 52 | * 53 | */ 54 | 55 | import './zone-flags.ts'; 56 | 57 | /*************************************************************************************************** 58 | * Zone JS is required by default for Angular itself. 59 | */ 60 | 61 | import 'zone.js/dist/zone'; // Included with Angular CLI. 62 | 63 | 64 | /*************************************************************************************************** 65 | * APPLICATION IMPORTS 66 | */ 67 | -------------------------------------------------------------------------------- /src/test.ts: -------------------------------------------------------------------------------- 1 | // This file is required by karma.conf.js and loads recursively all the .spec and framework files 2 | 3 | import 'zone.js/dist/zone-testing'; 4 | import { getTestBed } from '@angular/core/testing'; 5 | import { 6 | BrowserDynamicTestingModule, 7 | platformBrowserDynamicTesting 8 | } from '@angular/platform-browser-dynamic/testing'; 9 | 10 | declare const require: any; 11 | 12 | // First, initialize the Angular testing environment. 13 | getTestBed().initTestEnvironment( 14 | BrowserDynamicTestingModule, 15 | platformBrowserDynamicTesting() 16 | ); 17 | // Then we find all the tests. 18 | const context = require.context('./', true, /\.spec\.ts$/); 19 | // And load the modules. 20 | context.keys().map(context); 21 | -------------------------------------------------------------------------------- /src/theme/variables.scss: -------------------------------------------------------------------------------- 1 | // Ionic Variables and Theming. For more info, please see: 2 | // http://ionicframework.com/docs/theming/ 3 | 4 | /** Ionic CSS Variables **/ 5 | :root { 6 | /** primary **/ 7 | --ion-color-primary: #3880ff; 8 | --ion-color-primary-rgb: 56, 128, 255; 9 | --ion-color-primary-contrast: #ffffff; 10 | --ion-color-primary-contrast-rgb: 255, 255, 255; 11 | --ion-color-primary-shade: #3171e0; 12 | --ion-color-primary-tint: #4c8dff; 13 | 14 | /** secondary **/ 15 | --ion-color-secondary: #0cd1e8; 16 | --ion-color-secondary-rgb: 12, 209, 232; 17 | --ion-color-secondary-contrast: #ffffff; 18 | --ion-color-secondary-contrast-rgb: 255, 255, 255; 19 | --ion-color-secondary-shade: #0bb8cc; 20 | --ion-color-secondary-tint: #24d6ea; 21 | 22 | /** tertiary **/ 23 | --ion-color-tertiary: #7044ff; 24 | --ion-color-tertiary-rgb: 112, 68, 255; 25 | --ion-color-tertiary-contrast: #ffffff; 26 | --ion-color-tertiary-contrast-rgb: 255, 255, 255; 27 | --ion-color-tertiary-shade: #633ce0; 28 | --ion-color-tertiary-tint: #7e57ff; 29 | 30 | /** success **/ 31 | --ion-color-success: #10dc60; 32 | --ion-color-success-rgb: 16, 220, 96; 33 | --ion-color-success-contrast: #ffffff; 34 | --ion-color-success-contrast-rgb: 255, 255, 255; 35 | --ion-color-success-shade: #0ec254; 36 | --ion-color-success-tint: #28e070; 37 | 38 | /** warning **/ 39 | --ion-color-warning: #ffce00; 40 | --ion-color-warning-rgb: 255, 206, 0; 41 | --ion-color-warning-contrast: #ffffff; 42 | --ion-color-warning-contrast-rgb: 255, 255, 255; 43 | --ion-color-warning-shade: #e0b500; 44 | --ion-color-warning-tint: #ffd31a; 45 | 46 | /** danger **/ 47 | --ion-color-danger: #f04141; 48 | --ion-color-danger-rgb: 245, 61, 61; 49 | --ion-color-danger-contrast: #ffffff; 50 | --ion-color-danger-contrast-rgb: 255, 255, 255; 51 | --ion-color-danger-shade: #d33939; 52 | --ion-color-danger-tint: #f25454; 53 | 54 | /** dark **/ 55 | --ion-color-dark: #222428; 56 | --ion-color-dark-rgb: 34, 34, 34; 57 | --ion-color-dark-contrast: #ffffff; 58 | --ion-color-dark-contrast-rgb: 255, 255, 255; 59 | --ion-color-dark-shade: #1e2023; 60 | --ion-color-dark-tint: #383a3e; 61 | 62 | /** medium **/ 63 | --ion-color-medium: #989aa2; 64 | --ion-color-medium-rgb: 152, 154, 162; 65 | --ion-color-medium-contrast: #ffffff; 66 | --ion-color-medium-contrast-rgb: 255, 255, 255; 67 | --ion-color-medium-shade: #86888f; 68 | --ion-color-medium-tint: #a2a4ab; 69 | 70 | /** light **/ 71 | --ion-color-light: #f4f5f8; 72 | --ion-color-light-rgb: 244, 244, 244; 73 | --ion-color-light-contrast: #000000; 74 | --ion-color-light-contrast-rgb: 0, 0, 0; 75 | --ion-color-light-shade: #d7d8da; 76 | --ion-color-light-tint: #f5f6f9; 77 | } 78 | -------------------------------------------------------------------------------- /src/zone-flags.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * Prevents Angular change detection from 3 | * running with certain Web Component callbacks 4 | */ 5 | (window as any).__Zone_disable_customElements = true; 6 | -------------------------------------------------------------------------------- /tsconfig.app.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./out-tsc/app", 5 | "types": [] 6 | }, 7 | "include": [ 8 | "src/**/*.ts" 9 | ], 10 | "exclude": [ 11 | "src/test.ts", 12 | "src/**/*.spec.ts" 13 | ] 14 | } 15 | -------------------------------------------------------------------------------- /tsconfig.json: -------------------------------------------------------------------------------- 1 | { 2 | "compileOnSave": false, 3 | "compilerOptions": { 4 | "baseUrl": "./", 5 | "outDir": "./dist/out-tsc", 6 | "sourceMap": true, 7 | "declaration": false, 8 | "module": "esnext", 9 | "moduleResolution": "node", 10 | "emitDecoratorMetadata": true, 11 | "experimentalDecorators": true, 12 | "importHelpers": true, 13 | "target": "es2015", 14 | "typeRoots": [ 15 | "node_modules/@types" 16 | ], 17 | "lib": [ 18 | "es2018", 19 | "dom" 20 | ] 21 | }, 22 | "angularCompilerOptions": { 23 | "fullTemplateTypeCheck": true, 24 | "strictInjectionParameters": true 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /tsconfig.spec.json: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "./tsconfig.json", 3 | "compilerOptions": { 4 | "outDir": "./out-tsc/spec", 5 | "types": [ 6 | "jasmine", 7 | "node" 8 | ] 9 | }, 10 | "files": [ 11 | "src/test.ts", 12 | "src/zone-flags.ts", 13 | "src/polyfills.ts" 14 | ], 15 | "include": [ 16 | "src/**/*.spec.ts", 17 | "src/**/*.d.ts" 18 | ] 19 | } 20 | --------------------------------------------------------------------------------