pixelfed/public/js/live-player.js

1 line
26 KiB
JavaScript
Raw Normal View History

2023-05-25 06:36:01 +00:00
(self.webpackChunkpixelfed=self.webpackChunkpixelfed||[]).push([[4479],{38248:(t,e,s)=>{"use strict";s.r(e),s.d(e,{default:()=>m});s(95539);var a=s(21443),i=s.n(a),n=s(93041),r=s(78657),o=s(52526),d=s(23952),l=s(80041),c=s(39169),u=s(65981);const m={props:{id:{type:String}},components:{"stream-loading":r.default,"stream-offline":o.default,"profile-card":d.default,"stream-info-card":l.default,"stream-comments":c.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(n.default.isSupported())try{e.muted=!0;var a=new n.default;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)}}}},49597:(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")}}}},30719:(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")}))}}}},95790:(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,isB