fix pleroma audio bug

This commit is contained in:
Nicolas Constant 2019-07-05 17:22:49 -04:00
parent 30e9fdc2d9
commit 74de21f5e6
No known key found for this signature in database
GPG Key ID: 1E9F677FB01A5688
5 changed files with 25 additions and 7 deletions

View File

@ -4,7 +4,7 @@ import { faTimes, faAngleLeft, faAngleRight } from "@fortawesome/free-solid-svg-
import { Subject } from 'rxjs';
import { OpenMediaEvent } from '../../models/common.model';
import { Attachment } from '../../services/models/mastodon.interfaces';
import { Attachment, PleromaAttachment } from '../../services/models/mastodon.interfaces';
@Component({
@ -136,6 +136,7 @@ class AttachmentsWrapper implements Attachment {
this.text_url = attachment.text_url;
this.meta = attachment.meta;
this.description = attachment.description;
this.pleroma = attachment.pleroma;
this.index = index;
}
@ -148,6 +149,7 @@ class AttachmentsWrapper implements Attachment {
text_url: string;
meta: any;
description: string;
pleroma: PleromaAttachment;
index: number;
}

View File

@ -81,7 +81,7 @@
</div>
<div *ngIf="isAudio">
<audio controls class="audio">
<source src="{{ attachments[0].url }}" type="audio/{{ attachments[0].meta.audio_encode }}">
<source src="{{ attachments[0].url }}" type="{{ audioType }}">
Your browser does not support the audio element.
</audio>
</div>

View File

@ -1,16 +1,16 @@
import { Component, OnInit, Input, ViewChild, ElementRef } from '@angular/core';
import { faPlay, faPause, faExpand, faVolumeUp, faVolumeMute } from "@fortawesome/free-solid-svg-icons";
import { Attachment } from '../../../../services/models/mastodon.interfaces';
import { NavigationService } from '../../../../services/navigation.service';
import { OpenMediaEvent } from '../../../../models/common.model';
import { faPlay, faPause, faExpand, faVolumeUp, faVolumeMute } from "@fortawesome/free-solid-svg-icons";
@Component({
selector: 'app-attachements',
templateUrl: './attachements.component.html',
styleUrls: ['./attachements.component.scss']
})
export class AttachementsComponent implements OnInit {
export class AttachementsComponent implements OnInit {
private _attachments: Attachment[];
isImage: boolean;
isGifv: boolean;
@ -26,7 +26,7 @@ export class AttachementsComponent implements OnInit {
isPlaying: boolean = false;
isMuted: boolean = false;
// imageUrls: string[];
audioType: string;
@Input('attachments')
set attachments(value: Attachment[]) {
@ -40,6 +40,7 @@ export class AttachementsComponent implements OnInit {
this.isVideo = true;
} else if (this._attachments[0].type === 'audio') {
this.isAudio = true;
this.setAudioData(this._attachments[0]);
}
}
get attachments(): Attachment[] {
@ -90,4 +91,12 @@ export class AttachementsComponent implements OnInit {
this.isMuted = !this.isMuted;
this.getVideo().muted = this.isMuted;
}
setAudioData(att: Attachment): any {
if(att.meta && att.meta.audio_encode){
this.audioType = `audio/${att.meta.audio_encode}`;
} else if(att.pleroma && att.pleroma.mime_type){
this.audioType = att.pleroma.mime_type;
}
}
}

View File

@ -166,7 +166,8 @@ export class UserProfileComponent implements OnInit {
url: avatarUrl,
meta: null,
text_url: '',
description: ''
description: '',
pleroma: null
}
this.navigationService.openMedia({
selectedIndex: 0,

View File

@ -78,6 +78,12 @@ export interface Attachment {
text_url: string;
meta: any;
description: string;
pleroma: PleromaAttachment;
}
export interface PleromaAttachment {
mime_type: string;
}
export interface Card {