commit 06/11/2025
This commit is contained in:
@@ -1347,7 +1347,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="col-6 col-sm-6 col-md-4 col-lg-6 col-xl-6"><select id="listenzone" class="input-add form-select"></select></div>
|
<div class="col-6 col-sm-6 col-md-4 col-lg-6 col-xl-6"><select id="listenzone" class="input-add form-select"></select></div>
|
||||||
<div class="col-2 col-sm-2 col-md-1 col-lg-1 col-xl-1"><button class="btn btn-round-basic color-add pad-play" id="startstoplisten" type="button"><i class="fa fa-play"></i></button></div>
|
<div class="col-2 col-sm-2 col-md-1 col-lg-1 col-xl-1"><button class="btn btn-round-basic color-add pad-play" id="startstoplisten" type="button"><i class="fa fa-play"></i></button></div>
|
||||||
<div class="col-12 col-sm-12 col-md-3 col-lg-3 col-xl-3"><audio class="invisible" id="listenaudio" controls=""></audio></div>
|
<div class="col-12 col-sm-12 col-md-3 col-lg-3 col-xl-3"><audio id="listenaudio" controls="" autoplay=""></audio></div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -254,28 +254,35 @@ class WebApp(val listenPort: Int, val userlist: List<Pair<String, String>>, val
|
|||||||
if (param.isNotEmpty()) {
|
if (param.isNotEmpty()) {
|
||||||
val bc = Get_Barix_Connection_by_ZoneName(param)
|
val bc = Get_Barix_Connection_by_ZoneName(param)
|
||||||
if (bc != null) {
|
if (bc != null) {
|
||||||
|
|
||||||
|
|
||||||
val key = ctx.cookie("client-id") ?: UUID.randomUUID().toString()
|
|
||||||
.also { ctx.cookie("client-id", it) }
|
|
||||||
val pipeIN = PipedInputStream(8192)
|
|
||||||
val pipeOUT = PipedOutputStream(pipeIN)
|
|
||||||
// write WAV Header 44 bytes contains samplingrate 44100 Hz, 16 bit, mono
|
|
||||||
// pipeOUT.write(Generate_WAV_Header())
|
|
||||||
bc.AddPipeOut(key, pipeOUT)
|
|
||||||
ctx.contentType("audio/mpeg")
|
ctx.contentType("audio/mpeg")
|
||||||
ctx.header("Cache-Control", "no-cache, no-store, must-revalidate")
|
ctx.header("Cache-Control", "no-cache, no-store, must-revalidate")
|
||||||
ctx.header("Pragma", "no-cache")
|
ctx.header("Pragma", "no-cache")
|
||||||
ctx.header("Expires", "0")
|
ctx.header("Expires", "0")
|
||||||
|
|
||||||
// 🔥 This one is critical — tells Jetty to send data in HTTP chunks as it becomes available:
|
|
||||||
ctx.header("Transfer-Encoding", "chunked")
|
ctx.header("Transfer-Encoding", "chunked")
|
||||||
|
|
||||||
// Keeps the TCP socket open so the browser doesn’t close after initial data
|
|
||||||
ctx.header("Connection", "keep-alive")
|
ctx.header("Connection", "keep-alive")
|
||||||
|
|
||||||
ctx.result(pipeIN)
|
val key = ctx.cookie("client-id") ?: UUID.randomUUID().toString()
|
||||||
println("LiveAudio Open for zone $param SUCCESS")
|
.also { ctx.cookie("client-id", it) }
|
||||||
|
|
||||||
|
val responseStream = ctx.res().outputStream
|
||||||
|
ctx.async {
|
||||||
|
|
||||||
|
val pipeIN = PipedInputStream(8192)
|
||||||
|
val pipeOUT = PipedOutputStream(pipeIN)
|
||||||
|
bc.AddPipeOut(key, pipeOUT)
|
||||||
|
println("LiveAudio Open for zone $param SUCCESS")
|
||||||
|
try{
|
||||||
|
pipeIN.transferTo(responseStream)
|
||||||
|
responseStream.flush()
|
||||||
|
} catch(e: Exception){
|
||||||
|
|
||||||
|
} finally{
|
||||||
|
println("Cleaning up stream for $key")
|
||||||
|
bc.RemovePipeOut(key)
|
||||||
|
pipeIN.close()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} else ctx.status(400)
|
} else ctx.status(400)
|
||||||
.result(objectmapper.writeValueAsString(resultMessage("Broadcastzone not found")))
|
.result(objectmapper.writeValueAsString(resultMessage("Broadcastzone not found")))
|
||||||
} else ctx.status(400)
|
} else ctx.status(400)
|
||||||
|
|||||||
Reference in New Issue
Block a user