Pollinators Secret Mixter In Progress
skip
Home » Forums » Bugs » play-button in firefox on linux only points to m3u 'query'

play-button in firefox on linux only points to m3u 'query'

Stefan Krüger
.
permalink   Mon, May 25, 2015 @ 10:59 PM
Hi Community,

i have moved from windows to linux last week - and now the ‘play-button’ has stopped working - it only gives me an ‘query’ file to download (content type: m3u)
my system is:
Firefox38
—> no Flash installed!
Kubuntu 15.04 64bit
does this player need flash?
if i open the query file in an text editor i can copy the url to the file and past it in my Firefox address-bar and it plays the file - so mp3 in my browser works..

i have looked in the dev-console - but there was no error message
(only a huge amount of warnings about Unknown property (most of them’-moz-border-radius’))

i hope someone can help me :-)

if i can help to find the cause let me know

keep the music playing :-)
sunny greetings
stefan
unreal_dm
.
permalink   Fri, May 29, 2015 @ 12:58 PM
Yes you’ll need the flash player I did the same thing a couple of weeks ago moved over a profile but forgot about flash.
 
.
permalink   Stefan Krüger Sun, Jun 14, 2015 @ 1:36 PM
Hi unreal_dm,

thanks for the reply.
ok i did not want to install flash - so i have written a small user-script:
it searches for the playerdiv and adds a html5 audio element pointing to the file that is found in the player following script tag.
and it works also on pages with more than one player - and if you click on a play button all others will be paused..
to use the script you first have to install the Greasemonkey Addon
this addon allows to run user scripts on a per site/ per url basis.

have fun :-)

sunny greetings
stefan

you can find the script on github or attached:
the script:
Quote:
—————————————-

// ==UserScript==
// @name ccmixter.org player converter
// @namespace https://github.com/s-light/
// @description convertes the file player to raw html5 player so no flash is required.
// @include http://ccmixter.org/*
// @version 0.3
// @grant none
// ==/UserScript==

// function handlePleaseStop(event) {
// console.log(“received pleaseStop event”);
// if (this.paused == false) {
// console.log(“i will pause playing..”);
// this.pause();
// }
// }



function fadeOut(player) {
// console.log(“this”, this);
// console.log(“player”, player);

var stepSize = player.getAttribute(‘stepSize’);

// if fade out is finished pause player
if (player.volume 0 ) {
player.volume = player.volume - stepSize;
} else {
player.volume = 0;
}
window.setTimeout(fadeOut, player.getAttribute(‘fadeStepTime’), player);
}

}

function resetVolume(player) {
// reset volum to original
player.volume = player.getAttribute(‘volumeOriginal’);
console.log(“reset volume”);
}

function startFadeOut(player) {
// console.log(“this”, this);
// console.log(“player”, player);

// backup original volume setting
player.setAttribute(‘volumeOriginal’, player.volume);

// target fadeTime
var fadeTime = 1000; // ms
// target stepSize for smothe fading (range 0..1)
var stepSize = 0.01;

// calculate fadeStepTime
var steps = player.volume / stepSize;
var fadeStepTime = fadeTime / steps

player.setAttribute(‘fadeStepTime’, fadeStepTime);
player.setAttribute(‘stepSize’, stepSize);


// player.pause();
console.log(“fadeOut started.”);
window.setTimeout(fadeOut, player.getAttribute(‘fadeStepTime’), player);
}

function handlePlay(event) {
// console.log(“play event”, event);

// this event idea does not work…
// var myEvent = new Event(‘pleaseStop’);
// document.dispatchEvent(myEvent);

// stop all other
// based on http://stackoverflow.com/a/...
var audios = document.getElementsByTagName(‘audio’);
// console.log( audios.length + ” audios found.”);
for (var i = 0; i < audios.length; ++i) {
// console.log(“audios[” + i + “]:”, audios);
// if current auido is playing than paus it
if(audios != event.target){
if ( !audios.paused) {
startFadeOut(audios);
// audios.pause();
// console.log(“audios” + i + ” paused”);
}
}
}
}

function addAudioPlayer(parent_element, file_name) {
var el_audio = document.createElement(“audio”);
el_audio.controls = true;
el_audio.src = file_name;

// this does not work..
// el_audio.addEventListener(‘pleaseStop’, handlePleaseStop, false);
// el_audio.addEventListener(‘play’, handlePlay, false)

parent_element.appendChild(el_audio);
}


function convertPlayer(player) {

var playercontainer = player;
// get raw file url from next script-tag content.
var fileURLraw = player.nextElementSibling.firstChild.data;

// ” $(‘_ep_XXXXX’).href = ‘ http://ccmixter.org/content...
var searchString = “’).href = ‘”;
var searchStringIndex = fileURLraw.indexOf(searchString);
if (searchStringIndex > 1) {
// we think we have a url
var startPosition = searchStringIndex + searchString.length;
var endPosition = fileURLraw.lastIndexOf(“’”);
var fileURL = fileURLraw.substring(startPosition, endPosition);
// check the fileURL
if (fileURL.startsWith(“ http://ccmixter.org/”)) {
// now add a new html5 player..
console.log(“add Player for ‘” + fileURL +”’”);
addAudioPlayer(playercontainer, fileURL);
} else {
console.error(“url does not start with ccmixter.org”);
}
} else {
console.error(“can’t finde the file url.”);
}

}

function convertAllPlayers(){
console.groupCollapsed(“convertAllPlayers:”);

// plain js
var players = document.getElementsByClassName(“playerdiv”);
for (var i = 0; i < players.length; ++i) {
convertPlayer(players);
}
console.log(“\t found ” + players.length + ” players”);

console.log(“add play handler to document.”);
document.addEventListener(‘play’, handlePlay, true)

console.log(“finished.”);
console.groupEnd();
}


function main() {
// call main function
console.log(“ccmixter.org_player_converter script v0.3”)
convertAllPlayers();
}

main();


—————————————-


edit 10.09.2017: just fixed a small glitch in the fadeout handling
 
.
permalink   unreal_dm Sat, Jun 20, 2015 @ 2:15 AM
Looks good Stefan
I’ll give it a try on the next clean install.