我对离子Cordova和打字稿不熟悉,但一直在尝试通过创建可将视频流式传输到服务器的应用程序来提高技能。在Android 8及更低版本上,该应用程序可以正常访问相机,但在Android 9上,访问相机后该应用程序将崩溃。
我已经升级了cordova相机插件,但是没有效果
这是我当前的app.component.ts
import { EncoderPage } from './../pages/encoder/encoder';
import { UploadPage } from './../pages/upload/upload';
import { AboutPage } from './../pages/about/about';
import { LoginPage } from './../pages/login/login';
import { Component, ViewChild } from '@angular/core';
import { Nav, Platform, App, AlertController, LoadingController } from 'ionic-angular';
import { StatusBar } from '@ionic-native/status-bar';
import { SplashScreen } from '@ionic-native/splash-screen';
import { UserProvider } from '../providers/user/user';
import { TabsPage } from '../pages/tabs/tabs';
import { InAppBrowser } from '@ionic-native/in-app-browser';
import { CategoryPage } from '../pages/category/category';
import { HttpClient } from '@angular/common/http';
import { LoginProvider } from '../providers/login/login';
import { SettingsProvider } from '../providers/settings/settings';
@Component({
templateUrl: 'app.html'
})
export class MyApp {
@ViewChild(Nav) nav: Nav;
rootPage: any = LoginPage;
public selectedTheme: String;
public loader;
constructor(
public http: HttpClient,
public app: App,
public platform: Platform,
public statusBar: StatusBar,
public splashScreen: SplashScreen,
private user: UserProvider,
public settings: SettingsProvider,
private iab: InAppBrowser,
public alertCtrl: AlertController,
private loginP: LoginProvider,
public loadingCtrl: LoadingController) {
this.settings.getActiveTheme().subscribe(val => this.selectedTheme = val);
this.initializeApp();
}
initializeApp() {
this.platform.ready().then(() => {
// Okay, so the platform is ready and our plugins are available.
// Here you can do any higher level native things you might need.
this.statusBar.styleDefault();
this.splashScreen.hide();
});
}
openPage(page) {
//console.log(page);
switch (page) {
case 'UploadPage':
if (!this.platform.is('android') && !this.platform.is('ios')) {
this.showAlert("Upload Videos", "This is only available on Android and iOS devices");
//this.nav.push(UploadPage);
} else {
this.nav.push(UploadPage);
}
break;
case 'AboutPage':
this.nav.push(AboutPage);
break;
case 'EncoderPage':
this.nav.push(EncoderPage);
break;
}
}
showAlert(title, subTitle) {
let alert = this.alertCtrl.create({
title: title,
subTitle: subTitle,
buttons: ['OK']
});
alert.present();
}
logout() {
this.user.logout();
this.goToLogin();
}
reportSite() {
const confirm = this.alertCtrl.create({
title: 'Report site: ' + this.user.site + '?',
message: 'This site will be sent for analysis, if the abuse is confirmed, this site may be banned, do you confirm?',
inputs: [
{
name: 'report_details',
placeholder: 'Please provide report details'
},
],
buttons: [
{
text: 'Cancel',
handler: () => {
console.log('Disagree clicked');
}
},
{
text: 'Yes, Report it',
handler: (data) => {
this.loader = this.loadingCtrl.create({ content: "Creating Report" });
this.loader.present();
this.loginP.report(data.report_details)
.subscribe(data => {
//console.log("Report response ... ");
//console.log(JSON.stringify(data));
if (typeof data === undefined) {
this.showAlert('Error', 'report undefined');
} else {
const response = (data as any);
if (response.error) {
this.showAlert("Error", response.msg);
} else {
const alert = this.alertCtrl.create({
title: 'Thank you for your help!',
subTitle: 'Your report was sent!',
buttons: ['OK']
});
alert.present();
}
}
this.loader.dismiss();
}, error => {
//console.log(JSON.stringify(error));
this.showAlert("Error", "Unknow Error report");
this.showAlert("Error", JSON.stringify(error));
this.loader.dismiss();
});
}
}
]
});
confirm.present();
}
goToLogin() {
this.nav.setRoot(LoginPage);
}
createAccount() {
const browser = this.iab.create(this.user.site + "signUp", '_blank', 'location=yes, toolbar=yes,closebuttoncaption=done');
}
goToCategory(clean_name, name) {
this.app.getRootNav().push(CategoryPage, {
clean_name: clean_name,
name: name
});
}
}
我认为问题出在权限上,但我不能确定,因为从Android 7及更低版本开始摄像头访问没有问题