added autoplay
This commit is contained in:
parent
fe8aadd8ff
commit
f7045a140c
|
@ -14,7 +14,8 @@
|
|||
top: 15px;
|
||||
right: 20px;
|
||||
font-size: 24px;
|
||||
color: $font-link-primary;
|
||||
color: $font-link-primary;
|
||||
|
||||
&:hover {
|
||||
color: $font-link-primary-hover;
|
||||
}
|
||||
|
@ -33,6 +34,5 @@
|
|||
width: 95vw;
|
||||
max-height: 600px;
|
||||
max-width: 950px;
|
||||
border: 1px solid greenyellow;
|
||||
}
|
||||
}
|
|
@ -1,4 +1,4 @@
|
|||
import { Component, OnInit, Input, Output } from '@angular/core';
|
||||
import { Component, OnInit, Input, Output, ElementRef, ViewChild } from '@angular/core';
|
||||
import { SafeHtml } from '@angular/platform-browser';
|
||||
import { faChevronLeft, faChevronRight, faTimes } from "@fortawesome/free-solid-svg-icons";
|
||||
import { Subject } from 'rxjs';
|
||||
|
@ -13,6 +13,7 @@ import { Attachment } from '../../services/models/mastodon.interfaces';
|
|||
styleUrls: ['./media-viewer.component.scss']
|
||||
})
|
||||
export class MediaViewerComponent implements OnInit {
|
||||
|
||||
private _mediaEvent: OpenMediaEvent;
|
||||
|
||||
faChevronLeft = faChevronLeft;
|
||||
|
@ -30,6 +31,7 @@ export class MediaViewerComponent implements OnInit {
|
|||
|
||||
if (value.iframe) {
|
||||
this.html = value.iframe;
|
||||
this.autoplayIframe();
|
||||
} else {
|
||||
const attachment = value.attachments[value.selectedIndex];
|
||||
this.loadAttachment(attachment);
|
||||
|
@ -40,6 +42,7 @@ export class MediaViewerComponent implements OnInit {
|
|||
}
|
||||
|
||||
@Output() closeSubject = new Subject<boolean>();
|
||||
@ViewChild('video') myVideo: ElementRef;
|
||||
|
||||
constructor() { }
|
||||
|
||||
|
@ -56,6 +59,16 @@ export class MediaViewerComponent implements OnInit {
|
|||
}
|
||||
}
|
||||
|
||||
private autoplayIframe(): any {
|
||||
setTimeout(() => {
|
||||
if(this.myVideo.nativeElement.childNodes[0].src.includes('?')){
|
||||
this.myVideo.nativeElement.childNodes[0].src+='&autoplay=1&auto_play=1';
|
||||
} else {
|
||||
this.myVideo.nativeElement.childNodes[0].src+='?autoplay=1&auto_play=1';
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
|
||||
close(): boolean {
|
||||
this.closeSubject.next(true);
|
||||
return false;
|
||||
|
|
Loading…
Reference in New Issue