Try stream recovery with a custom error message
Table of contents
Sample implementation
.flowplayer {
max-width: 30em;
}
Code
Libraries
<!-- <head> -->
<link rel="stylesheet" href="//cdn.flowplayer.com/releases/native/3/stable/style/flowplayer.css" />
<!-- <body> -->
<script src="//cdn.flowplayer.com/releases/native/3/stable/flowplayer.min.js"></script>
<script src="//cdn.flowplayer.com/releases/native/3/stable/plugins/hls.min.js"></script>
<script src="//cdn.flowplayer.com/releases/native/3/stable/plugins/message.min.js"></script>
HTML code
<div id="player"></div>
Javascript
var api = flowplayer('#player', {
//example token, use your own when trying this yourself
token: "eyJraWQiOiJxaEZ6dWR4dmJuTDMiLCJ0eXAiOiJKV1QiLCJhbGciOiJFUzI1NiJ9.eyJjIjoie1wiYWNsXCI6NixcImlkXCI6XCJxaEZ6dWR4dmJuTDNcIixcImRvbWFpblwiOltcImZsb3dwbGF5ZXIuY29tXCJdfSIsImlzcyI6IkZsb3dwbGF5ZXIifQ.pdpIEfbRN_6P-ayyNsEazPPPjr0RSmd8SjJyqp8w8BYXTYsg11FjCODutzLZ6jkSm5hHTqfg05cCVuHcFIfI1w",
src: "//edge.flowplayer.org/invalid.m3u8",
preload: "auto"
})
api.on(flowplayer.events.ERROR, function(ev) {
ev.preventDefault()
api.setState(flowplayer.states.ERRORED, true)
api.emit(flowplayer.message.events.SHOW_MESSAGE, { message: 'Stream offline, reconnecting..'})
setTimeout(function() {
api.setState(flowplayer.states.ERRORED, false)
// Try again in 3 seconds
// normally you should just call api.load()
// we change the source for demo purposes to a working stream
api.setSrc('//edge.flowplayer.org/bauhaus.m3u8')
api.load()
}, 3000)
})