1
0
Fork 0
forked from mirror/pixelfed
pixelfed/public/js/live-player.js

1 line
27 KiB
JavaScript
Raw Normal View History

2022-10-17 08:00:24 +00:00
(self.webpackChunkpixelfed=self.webpackChunkpixelfed||[]).push([[479],{19455:(t,e,s)=>{"use strict";s.r(e),s.d(e,{default:()=>f});s(91942);var a=s(21443),i=s.n(a),n=s(67631),r=s.n(n),o=s(78657),d=s(52526),l=s(23952),c=s(80041),m=s(39169),u=s(65981);const f={props:{id:{type:String}},components:{"stream-loading":o.default,"stream-offline":d.default,"profile-card":l.default,"stream-info-card":c.default,"stream-comments":m.default,"settings-card":u.default},data:function(){return{loggedIn:!1,enabled:!0,isLoaded:!1,user:void 0,profile:void 0,stream:{name:"Offline",description:void 0},streamState:"loading",streamSource:void 0,showSettingsCard:!1,streamInvokeInterval:void 0,streamInvokeIntervalLength:2e3}},mounted:function(){this.fetchProfile()},methods:{fetchProfile:function(){var t=this;axios.get("/api/pixelfed/v1/accounts/"+this.id).then((function(e){t.profile=e.data,t.user=e.data,t.fetchAuthState()}))},fetchAuthState:function(){var t=this;axios.get("/api/v1/accounts/verify_credentials").then((function(e){window._sharedData.curUser=e.data,window._sharedData.user=e.data,t.loggedIn=!0,t.fetchInitialStreamState(!0)})).catch((function(e){t.fetchInitialStreamState(!1)}))},fetchInitialStreamState:function(t){var e=this;if("ready"!==this.streamState){var s=1==t?"/api/live/accounts/stream":"/api/live/accounts/stream/guest";axios.get(s,{params:{profile_id:this.profile.id}}).then((function(t){if(e.isLoaded=!0,t.data&&t.data.hls_url&&t.data.hls_url.length){e.stream=t.data;var s=t.data.hls_url;axios.head(t.data.hls_url).then((function(t){e.streamState="ready",e.streamSource=s,e.initVideo(),clearInterval(e.streamInvokeInterval)})).catch((function(t){e.streamState="offline"}))}else e.streamState="offline"})).catch((function(t){e.isLoaded=!0}))}else clearInterval(this.streamInvokeInterval)},initVideo:function(){var t=this;this.$nextTick((function(){var e=t.$refs.liveVid,s=(new(i())(e,{autoplay:!0,controls:["play","mute","volume","fullscreen"]}),t.streamSource);if(r().isSupported())try{e.muted=!0;var a=new(r());a.loadSource(s),a.attachMedia(e),window.hls=a}catch(t){console.log("Error loading manifest")}else e.src=s}))},openSettings:function(){this.showSettingsCard=!this.showSettingsCard},closeSettings:function(){this.showSettingsCard=!1},triggerStreamStart:function(){"ready"!==this.streamState&&this.setStreamInvokeInterval()},triggerStreamEnd:function(){this.streamState="offline"},setStreamInvokeInterval:function(){var t=this;this.streamInvokeInterval=setInterval((function(){t.fetchInitialStreamState(t.loggedIn)}),this.streamInvokeIntervalLength)}}}},1791:(t,e,s)=>{"use strict";s.r(e),s.d(e,{default:()=>a});const a={props:{profile:{type:Object},stream:{type:Object},showSettings:{type:Boolean,default:!1}},computed:{isOwner:function(){return window._sharedData.user.id===this.profile.id&&this.stream.hls_url}},methods:{openSettings:function(){event.currentTarget.blur(),this.$emit("settings")}}}},40038:(t,e,s)=>{"use strict";s.r(e),s.d(e,{default:()=>a});const a={props:{profile:{type:Object},stream:{type:Object}},data:function(){return{hasChanged:!1}},watch:{stream:{deep:!0,handler:function(t,e){this.hasChanged=JSON.stringify(t)===JSON.stringify(this.getOriginal)}}},computed:{getOriginal:function(){return this.originalStream}},mounted:function(){this.originalStream=this.stream},methods:{closeSettings:function(){event.currentTarget.blur(),this.$emit("close")},updateSettings:function(){var t=this;event.currentTarget.blur(),axios.post("/api/live/stream/edit",{name:this.stream.name,description:this.stream.description}).then((function(e){t.$emit("close")}))}}}},53282:(t,e,s)=>{"use strict";s.r(e),s.d(e,{default:()=>i});var a=s(84554);window.Pusher=s(86606),window.Echo=new a.default({broadcaster:"pusher",key:window._pushr.key,wsHost:window._pushr.host,wsPort:window._pushr.port,wssPort:window._pushr.port,disableStats:!0,enabledTransports:["ws","wss"],forceTLS:!1});const i={props:{show:{type:String},profile:{type:Object},stream:{type:Object}},data:function(){return{user:{id:-1},comment:void 0,comments:[],state:"loading",modMode:!1,viewerCount:1,isBanne