Hello,
I have a problem with the Media Plugin, it doesn’t work on my android device. This is my info :
@ionic/cli-utils : 1.19.2
ionic (Ionic CLI) : 3.20.0
cordova (Cordova CLI) : 8.0.0
@ionic/app-scripts : 3.1.8
Cordova Platforms : android 6.4.0
Ionic Framework : ionic-angular 3.9.2
Node : v9.5.0
npm : 5.6.0
OS : Windows 10
My app.module.ts file :
import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';
import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';
import { Media } from '@ionic-native/media';
@NgModule({
declarations: [
MyApp,
HomePage
],
imports: [
BrowserModule,
IonicModule.forRoot(MyApp)
],
bootstrap: [IonicApp],
entryComponents: [
MyApp,
HomePage
],
providers: [
StatusBar,
SplashScreen,
Media,
{provide: ErrorHandler, useClass: IonicErrorHandler}
]`Preformatted text`
})
export class AppModule {}
my home.ts file :
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import { Media, MediaObject } from '@ionic-native/media';
@Component({
selector: 'page-home',
templateUrl: 'home.html'
})
export class HomePage {
music: MediaObject;
constructor(
public navCtrl: NavController,
public media: Media
) {}
ionViewDidLoad(){
this.music = this.media.create('../../assets/music/music.mp3');
this.music.setVolume(1.0);
this.music.play();
}
}
My music is entitled “music.mp3” and it’s saved in assets/music/ but when i run my app on my device (ionic cordova run android), nothing happen, no sound… I have a Huawei P10 with Android 7.0. I don’t understand what is the source of the problem.
Thanks for help !