Reply to this topicStart new topic
> Помощ с html player
touchdown
публикация 8.02.2013г. в 13:09ч.
Коментар: #1


Новак
*

Група: Потребители
Съобщения: 6
Дата на регистрация: 5.05.2012г.
Потребител # 22 033





Добър ден ще може ли калко помощ относно html код който възпроизвежда psl файл и по този начин е възможно слушането на интернет радио и през телефон,имам написан код но неиска да възпроизведе pls файла прикачил съм кода ако е възможно да го погледнете,благодаря предваритлено.
КОД
[/code]
<! DOCTYPE html>
<html>
<head>
<title>Radio PartyStyle</title>
<!-- needed for IE9 to ensure it treats page as HTML5 properly -->
<meta http-equiv="X-UA-Compatible" content="IE=9" >
</head>
<body>
<p>Audio PLS processor<p>
<audio id="audio" controls="controls"></audio >
<p id="title">Radio PartyStyle</p>

<script>
// Make XHR request for the pls file
if (window.XMLHttpRequest) {
    // code for IE7 +, Firefox, Chrome, Opera, Safari
    xhr = new XMLHttpRequest();
} else {
    // code for IE6, IE5
    xhr = new ActiveXObject("Microsoft.XMLHTTP");
}
xhr.open("GET", "http://79.124.67.186:8018/listen.pls", false);
xhr.send();
xhrDoc = xhr.responseText;

var pls = {};

// split into lines
pls.Entries = xhrDoc.split("\n");
// Entry 0 is [playlist]
// Entry 1 is NumberOfEntries=n
pls.Count = pls.Entries[1].split("=")[1];
// Entry 2,3,4 = File#=,Title#=,Length#=
// repeat from 1 to NumberOfEntries

pls.Items = [];
pls.curItem = 0;
pls.listOk = true;
for (var i = 0; i < pls.Count; i ++ ) {
    pls.Items.push( {
        file: pls.Entries[i + 2].split("=")[1],
        title: pls.Entries[i + 3].split("=")[1],
        length: pls.Entries[i + 4].split("=")[1]
        });
}
// get the audio element
pls.audio = document.getElementById("audio");

// hook onEnded and onError events to jump to next PLS item
pls.audio.addEventListener("error", audioEvent, false);
pls.audio.addEventListener("ended", audioEvent, false);

// load audio tag with first source
pls.listOk = loadPLS(pls.curItem ++ );

function audioEvent(event) {
    // if the listOk is still true (ie not at the end of the list)
    // step to the next item either on ended or error
    if (pls.listOk) {
        pls.listOk = loadPLS(pls.curItem ++ );
    } else {
        // action to indicate end of stream    
    }
}
function loadPLS(whichItem) {
    if (whichItem >= pls.Count) {
        return false;
    } else {
        pls.audio.autoplay = false;
        pls.audio.src = pls.Items[whichItem].file;
        var title = document.getElementById("title");
        title.innerText = pls.Items[whichItem].title + "[" + pls.curItem + "/" + pls.Items[whichItem].file + "]";
        return true;
    }
}
</script>
</body>
</html>[code]
Go to the top of the page
 
+Quote Post



Reply to this topicStart new topic
1 потребители преглеждат тази тема в момента (1 гости, 0 анонимни потребители)
Потребители, преглеждащи темата в момента:

 

RSS Олекотена Версия Сега е: 09:06 - 9.06.2026г.

Калдейта Ком ЕООД - © 2003-. Всички права запазени.