Quantcast
Channel: Ionic Forum - Latest topics
Viewing all articles
Browse latest Browse all 70434

Cordova-plugin-media and ionic-native/media do not work

$
0
0

@VictorNorman wrote:

I have the simplest of ionic apps. I put up a button on the screen and when you push it, the app should play an mp3 file. Here is the whole code of my home.page.ts file, which is almost identical to the code here: https://ionicframework.com/docs/native/media

import { Component } from '@angular/core';

import { Media, MediaObject } from '@ionic-native/media/ngx';

@Component({
  selector: 'app-home',
  templateUrl: 'home.page.html',
  styleUrls: ['home.page.scss'],
})
export class HomePage {

  private file: MediaObject;

  constructor(private media: Media) {
    this.file = this.media.create('assets/1.mp3');
  }

  play() {
    this.file.play();
  }
}

When I build and install on an android device via Android Studio, the Log shows this error:

2019-04-11 11:53:13.521 10986-11133/io.ionic.starter V/Capacitor/Plugin: To native (Cordova plugin): callbackId: INVALID, service: Media, action: startPlayingAudio, actionArgs: ["0e340ba6-b7f6-f2e5-2cef-b5c9220e4006","assets\/1.mp3",null]
2019-04-11 11:53:13.527 10986-11133/io.ionic.starter W/AudioManager: Use of stream types is deprecated for operations other than volume control
2019-04-11 11:53:13.527 10986-11133/io.ionic.starter W/AudioManager: See the documentation of requestAudioFocus() for what to use instead with android.media.AudioAttributes to qualify your playback use case
2019-04-11 11:53:13.529 1605-5066/? I/MediaFocusControl: requestAudioFocus() from uid/pid 10198/10986 clientId=android.media.AudioManager@cf3d468org.apache.cordova.media.AudioHandler$1@ef95081 callingPack=io.ionic.starter req=1 flags=0x0 sdk=27

What am I doing wrong, or am I seeing an error in the cordova stuff or ionic-native stuff? Here is my set up:

Ionic:

   ionic (Ionic CLI)             : 4.12.0 (/usr/local/lib/node_modules/ionic)
   Ionic Framework               : @ionic/angular 4.2.0
   @angular-devkit/build-angular : 0.13.8
   @angular-devkit/schematics    : 7.2.4
   @angular/cli                  : 7.3.8
   @ionic/angular-toolkit        : 1.4.1

Capacitor:

   capacitor (Capacitor CLI) : 1.0.0-beta.19
   @capacitor/core           : 1.0.0-beta.19

Cordova:

   cordova (Cordova CLI) : 9.0.0
   Cordova Platforms     : none
   Cordova Plugins       : no whitelisted plugins (1 plugins total)

System:

   Android SDK Tools : 26.1.1 (/Users/vtn2/Library/Android/sdk)
   NodeJS            : v10.14.2 (/usr/local/bin/node)
   npm               : 6.4.1
   OS                : macOS Mojave

package.json:

{
  "name": "test",
  "version": "0.0.1",
  "author": "Ionic Framework",
  "homepage": "https://ionicframework.com/",
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "build": "ng build",
    "test": "ng test",
    "lint": "ng lint",
    "e2e": "ng e2e"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "^7.2.2",
    "@angular/core": "^7.2.2",
    "@angular/forms": "^7.2.2",
    "@angular/http": "^7.2.2",
    "@angular/platform-browser": "^7.2.2",
    "@angular/platform-browser-dynamic": "^7.2.2",
    "@angular/router": "^7.2.2",
    "@capacitor/android": "^1.0.0-beta.19",
    "@capacitor/cli": "1.0.0-beta.19",
    "@capacitor/core": "1.0.0-beta.19",
    "@ionic-native/core": "^5.0.0",
    "@ionic-native/media": "^5.4.0",
    "@ionic-native/splash-screen": "^5.0.0",
    "@ionic-native/status-bar": "^5.0.0",
    "@ionic/angular": "^4.1.0",
    "cordova-plugin-file": "^6.0.1",
    "cordova-plugin-media": "5.0.2",
    "core-js": "^2.5.4",
    "rxjs": "~6.3.3",
    "zone.js": "~0.8.29"
  },
  "devDependencies": {
    "@angular-devkit/architect": "~0.12.3",
    "@angular-devkit/build-angular": "~0.13.0",
    "@angular-devkit/core": "~7.2.3",
    "@angular-devkit/schematics": "~7.2.3",
    "@angular/cli": "~7.3.1",
    "@angular/compiler": "~7.2.2",
    "@angular/compiler-cli": "~7.2.2",
    "@angular/language-service": "~7.2.2",
    "@ionic/angular-toolkit": "~1.4.0",
    "@types/node": "~10.14.2",
    "@types/jasmine": "~2.8.8",
    "@types/jasminewd2": "~2.0.3",
    "codelyzer": "~4.5.0",
    "jasmine-core": "~2.99.1",
    "jasmine-spec-reporter": "~4.2.1",
    "karma": "~3.1.4",
    "karma-chrome-launcher": "~2.2.0",
    "karma-coverage-istanbul-reporter": "~2.0.1",
    "karma-jasmine": "~1.1.2",
    "karma-jasmine-html-reporter": "^0.2.2",
    "protractor": "~5.4.0",
    "ts-node": "~8.0.0",
    "tslint": "~5.12.0",
    "typescript": "~3.1.6"
  },
  "description": "An Ionic project",
  "cordova": {
    "plugins": {
      "cordova-plugin-media": {}
    }
  }
}

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 70434

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>