Javascript 在8中显示流文件

Javascript 在8中显示流文件,javascript,angular,typescript,Javascript,Angular,Typescript,我为预览文件音频、视频、图像等创建了一个组件 但我有一个问题: 它没有给我任何东西。url是currect,当我控制台地址文件并在浏览器中复制它时,它会显示文件,但不会在我的组件中显示文件 export interface DialogData { src: string; type: TypeFile; apiControllName: string; } declare const require: any; @Component({ select

我为预览文件
音频
视频
图像
等创建了一个组件

但我有一个问题:

它没有给我任何东西。url是currect,当我控制台地址文件并在浏览器中复制它时,它会显示文件,但不会在我的组件中显示文件

    export interface DialogData {
    src: string;
    type: TypeFile;
    apiControllName: string;
}

declare const require: any;

@Component({
    selector: 'kt-preview',
    templateUrl: './preview.component.html',
    styleUrls: ['./preview.component.scss']
})
export class PreviewComponent implements OnInit, OnDestroy {

    @Output() showButton = new EventEmitter<boolean>();

    subscriptions: Subscription;
    thumbnail: any;
    fileSource: any;
    Video = 'Video';
    Picture = 'Picture';
    Text = 'Text';
    Sound = 'Sound';
    type: any;
    isLoading: boolean;
    showVid: any;
    fileType = TypeFile;
    show = true;
    url: string;
    AdressFile: string;

    constructor(
        @Inject(MAT_DIALOG_DATA) public data: DialogData
        , @Inject(APP_CONFIG) private appConfig: IAppConfig
        , private dialogRef: MatDialogRef<PreviewComponent>
        , private authService: AuthService
        , private sanitizer: DomSanitizer) {

    }



    @HostListener('window:keyup.esc') onKeyUp(): void {
        this.dialogRef.close();
    }

    ngOnInit(): void {
        if (this.data.src.startsWith('data:image/png;base64,')) {
            this.AdressFile = this.data.src;
        } else {
            this.AdressFile = this.appConfig.apiEndpoint + '/' + this.data.src + '/?access_token=' + this.authService.getRawAuthToken(AuthTokenType.AccessToken);
        }
        this.type = this.data.type;
        this.AdressFile = this.url;
        this.show = false;
    }

    ngOnDestroy(): void {
        if (this.subscriptions) {
            this.subscriptions.unsubscribe();
        }
    }

    createImageFromBlob(image: Blob): void {
        const blob = new Blob([image], { type: 'application/octet-stream' });
        this.fileSource = this.sanitizer.bypassSecurityTrustResourceUrl(window.URL.createObjectURL(blob));
    }

    close(): void {
        this.dialogRef.close();
    }
}
导出接口对话框数据{
src:字符串;
类型:TypeFile;
apiControllName:字符串;
}
声明const require:任何;
@组成部分({
选择器:“kt预览”,
templateUrl:'./preview.component.html',
样式URL:['./preview.component.scss']
})
导出类PreviewComponent实现OnInit、OnDestroy{
@Output()showButton=新的EventEmitter();
订阅:订阅;
缩略图:任何;
文件来源:任何;
视频=‘视频’;
图片=‘图片’;
Text='Text';
声音=‘声音’;
类型:任意;
isLoading:布尔值;
showVid:任何;
fileType=TypeFile;
show=true;
url:string;
地址文件:字符串;
建造师(
@注入(MAT_DIALOG_数据)公共数据:DialogData
,@Inject(APP_CONFIG)私有appConfig:IAppConfig
,private dialogRef:MatDialogRef
,私有authService:authService
,私人消毒剂:DOM消毒剂){
}
@HostListener('window:keyup.esc')onKeyUp():void{
this.dialogRef.close();
}
ngOnInit():void{
if(this.data.src.startsWith('data:image/png;base64')){
this.addressfile=this.data.src;
}否则{
this.adresfile=this.appConfig.apidentpoint+'/'+this.data.src+'/?access_token='+this.authService.getRawAuthToken(AuthTokenType.AccessToken);
}
this.type=this.data.type;
this.addressfile=this.url;
this.show=false;
}
ngOnDestroy():void{
if(this.subscriptions){
此为.subscriptions.unsubscribe();
}
}
createImageFromBlob(图像:Blob):无效{
const blob=new blob([image],{type:'application/octet stream'});
this.fileSource=this.sanitizer.bypassSecurityTrustResourceUrl(window.URL.createObjectURL(blob));
}
close():void{
this.dialogRef.close();
}
}
这个html文件:

    <div class="toolbar col-md-12 col-sm-12 col-lg-12 col-xl-12 p-0">
    <div class="topbar col-md-12 col-xl-12 col-sm-12 col-xl-12 col-lg-12">
        <div class="detail-title">
            <label>نمایش</label>
        </div>
        <span>
            <i (click)="close()" class="fas fa-times"></i>
        </span>
    </div>
</div>
<div class="col-md-12 col-sm-12 col-lg-12 col-xl-12 p-0 prev">
    <!-- Video Show -->
    <div *ngIf="data.type===1">
        <video autoplay controls>
            <source src="{{data.src}}" type="video/mp4">
            <source src="{{data.src}}" type="video/ogg">
            Your browser does not support the video tag.
        </video>
    </div>
    <div *ngIf="type===fileType[1]" id="video_bg">
        <video controls autoplay>
            <source [src]="AdressFile" type="video/mp4">
            <source [src]="AdressFile" type="video/ogg">
            Your browser does not support the video tag.
        </video>
    </div>
    <!-- PDF Show -->
    <div *ngIf="data.type===0">
        <a href="{{data.src}}" target="_blank"></a>
    </div>
    <div *ngIf="type===fileType[0]">
        <a [href]="AdressFile" target="_blank"></a>
    </div>
    <!-- Sound Show -->
    <div *ngIf="data.type===2">
        <audio controls>
            <source src="{{data.src}}" type="audio/ogg">
            <source src="{{data.src}}" type="audio/mpeg">
            Your browser does not support the audio element.
        </audio>
    </div>
    <div *ngIf="type===fileType[2]" id="sound_bg">
        <audio controls autoplay>
            <source [src]="AdressFile" type="audio/mp3">
        </audio>
    </div>
    <!-- Image Show -->
    <div *ngIf="data.type===3">
        <div class="img col-md-12 col-xl-12 col-sm-12 col-xl-12 p-0">
            <img *ngIf="!isLoading" src="{{AdressFile}}" class=" float-left" alt="...">
        </div>
    </div>
    <div *ngIf="type===fileType[3]">
        <div class="img col-md-12 col-xl-12 col-sm-12 col-xl-12 p-0">
            <img *ngIf="!isLoading" [src]="AdressFile" class=" float-left" alt="...">
        </div>
    </div>
</div>

نمایش
您的浏览器不支持视频标记。
您的浏览器不支持视频标记。
您的浏览器不支持音频元素。
有什么问题?我如何解决它??