Jelajahi Sumber

Fix mime type of audio messages

Danilo Bargen 7 tahun lalu
induk
melakukan
7cf1346437
2 mengubah file dengan 9 tambahan dan 4 penghapusan
  1. 5 4
      src/directives/message_media.ts
  2. 4 0
      src/filters.ts

+ 5 - 4
src/directives/message_media.ts

@@ -133,11 +133,12 @@ export default [
                 };
 
                 // Play a Audio file in a dialog
-                this.playAudio = (buffer: ArrayBuffer) => {
+                this.playAudio = (blobInfo: threema.BlobInfo) => {
                     $mdDialog.show({
                         controllerAs: 'ctrl',
                         controller: function() {
-                            this.blobBuffer = buffer;
+                            this.blobBuffer = blobInfo.buffer;
+                            this.mimeType = blobInfo.mimetype;
                             this.cancel = () => {
                                 $mdDialog.cancel();
                             };
@@ -152,7 +153,7 @@ export default [
                                     <md-dialog-content layout="row" layout-align="center">
                                         <audio
                                             controls
-                                            autoplay ng-src="{{ ctrl.blobBuffer | bufferToUrl: 'audio/ogg' }}">
+                                            autoplay ng-src="{{ ctrl.blobBuffer | bufferToUrl:ctrl.mimeType }}">
                                             Your browser does not support the <code>audio</code> element.
                                         </audio>
                                     </md-dialog-content>
@@ -207,7 +208,7 @@ export default [
                                         break;
                                     case 'audio':
                                         // Show inline
-                                        this.playAudio(blobInfo.buffer);
+                                        this.playAudio(blobInfo);
                                         break;
                                     default:
                                         $log.warn('Ignored download request for message type', this.message.type);

+ 4 - 0
src/filters.ts

@@ -262,6 +262,10 @@ angular.module('3ema.filters', [])
             case 'image/jpeg':
             case 'image/png':
             case 'image/webp':
+            case 'audio/mp4':
+            case 'audio/aac':
+            case 'audio/ogg':
+            case 'audio/webm':
                 // OK
                 break;
             default: