I have been waiting ages for a properly implemented HTML5 Player. Lets face it: Flash sucks!
After the feature had been requested several times by different users without being implemented I decided to do it myself.
Screenshots:
Its a fairly straightforward change and requires only changing one file:
/var/subsonic/jetty/1337/webapp/WEB-INF/jsp/playQueue.jsp
I used the official .deb package on my system (debian). On your system it might reside in another location.
1. Replace this line:
- Code: Select all
<script type="text/javascript" src="<c:url value="/script/jw-player-5.10.js"/>"></script>
with this line:
- Code: Select all
<script type="text/javascript" src="https://content.jwplatform.com/libraries/2bSyTMFk.js"></script>
That link is a "cloud-hosted" JWPlayer 7 including a free license. I signed up for this player specifically for demonstration purposes on this forum. You might want to consider signing up yourself on https://www.jwplayer.com and getting your own personal link.
2. Replace this line:
- Code: Select all
<c:if test="${model.player.web}">createPlayer();</c:if>
With this one:
- Code: Select all
<c:if test="${model.player.web}">createPlayerCallback();</c:if>
3. Replace the complete
- Code: Select all
function createPlayer()
{
[...]
}
with:
- Code: Select all
function createPlayerCallback() {
playQueueService.getPlayQueue(createPlayer);
}
function createPlayer(playQueue) {
song = playQueue.entries[0];
jwplayer("jwplayer").setup({
file: song.streamUrl,
type: song.format,
duration: song.duration,
skin: "five",
height: 33,
width: 350
});
jwplayer().onComplete(function() {onNext(repeatEnabled)});
}
4. Replace the complete
- Code: Select all
function skip(index, position) {
[...]
}
with this:
- Code: Select all
function skip(index, position) {
if (index < 0 || index >= songs.length) {
return;
}
var song = songs[index];
currentStreamUrl = song.streamUrl;
updateCurrentImage();
if (CastPlayer.castSession) {
CastPlayer.loadCastMedia(song, position);
} else {
jwplayer().load({
file: song.streamUrl,
type: song.format,
duration: song.duration
});
jwplayer().play();
console.log(song.streamUrl);
}
updateWindowTitle(song);
<c:if test="${model.notify}">
showNotification(song);
</c:if>
}
5. Search for this:
- Code: Select all
<div id="jwplayer">[...]</div>
and remove everything inside the div so that it looks like this:
- Code: Select all
<div id="jwplayer"></div>
6. Delete all Webplayers in the subsonic settings menu.
That's it you successfully replaced the flash player with the current html5 release of jwplayer!
Please be aware that there is a little incompatibility initially when spawning a new player. It has to do with how the new jwplayer handles media files. This causes the player to not spawn immediately. As a workaround just play 1 or 2 files and refresh the page in your browser. The player should appear immediately.
Have fun with your new HTML5 non-flash Player!
Yours sincerely,
Schnip