preview embed type selectors NB: changes to embed.js

This commit is contained in:
cat 2014-08-13 15:14:32 +02:00 committed by Thulinma
parent 20ef805c0c
commit 9b9923b6d5
4 changed files with 127 additions and 61 deletions

View file

@ -1323,35 +1323,57 @@ function buildstreamembed(streamName,embedbase) {
var script = document.createElement('script');
script.src = embedbase+'embed_'+streamName+'.js';
script.onload = function(){
var priority = mistvideo[streamName].source;
if (priority.length > 0) {
priority.sort(function(a,b){
return b.priority - a.priority;
});
var $table = $('<table>').html(
$('<tr>').html(
$('<th>').text('URL')
).append(
$('<th>').text('Type')
).append(
$('<th>').text('Priority')
)
);
for (var i in priority) {
$table.append(
$('<tr>').html(
$('<td>').text(priority[i].url)
).append(
$('<td>').text(priority[i].type)
).append(
$('<td>').addClass('align-center').text(priority[i].priority)
)
);
}
$('#listprotocols').html($table);
if (typeof mistvideo[streamName].error != 'undefined') {
$('#preview-container').text(mistvideo[streamName].error);
}
else {
$('#listprotocols').html('No data in info embed file.');
var priority = mistvideo[streamName].source;
if (priority.length > 0) {
$radio = $('<input>').attr('type','radio').attr('name','forcetype').attr('title','The embed type that is being used.').change(function(){
$('#preview-container').attr('data-forcetype',$(this).val()).html('');
var script = document.createElement('script');
script.src = embedbase+'embed_'+streamName+'.js';
script.onload = function(){
};
document.getElementById('preview-container').appendChild( script );
});
priority.sort(function(a,b){
return b.priority - a.priority;
});
var $table = $('<table>').html(
$('<tr>').html(
$('<th>')
).append(
$('<th>').text('URL')
).append(
$('<th>').text('Type')
).append(
$('<th>').text('Priority')
)
);
for (var i in priority) {
$table.append(
$('<tr>').html(
$('<td>').html(
$radio.clone(true).attr('data-name',priority[i].type).val(i)
)
).append(
$('<td>').text(priority[i].url)
).append(
$('<td>').text(priority[i].type)
).append(
$('<td>').addClass('align-center').text(priority[i].priority)
)
);
}
$('#listprotocols').html($table);
$table.find('[name=forcetype][data-name="'+mistvideo[streamName].embedded_type+'"]').attr('checked','checked');
}
else {
$('#listprotocols').html('No data in info embed file.');
}
}
}
document.getElementById('preview-container').appendChild( script );

View file

@ -294,9 +294,19 @@ function showTab(tabName,streamName) {
},10000);
updateOverview();
if (!settings.settings.config.capabilities) { saveAndReload(); }
break;
case 'protocols':
if (typeof settings.settings.capabilities == 'undefined') {
getData(function(data){
settings.settings.capabilities = data.capabilities;
showTab('protocols');
},{capabilities:true});
return;
}
var $tbody = $('<tbody>').attr('id','protocols-tbody');
$('#page').html(

View file

@ -2,22 +2,31 @@
<head>
<title>Test the stream embedding</title>
<style></style>
<script src=jquery.js></script>
<script src=plugins/jquery.js></script>
<script src='../src/connectors/embed.js'></script>
<script>
var embed_settings = {};
$(function(){
$('button').click(function(){
$('#embedcontainer').html('');
$('button#embed').click(function(){
$('#embedcontainer, #button_container').html('');
var streamName = $(this).parent().children('input').val();
var streamName = $('input[name=streamName]').val();
var embedtype = $('input[name=force]').val();
var info = document.createElement('script');
info.src = 'http://localhost:8080/info_'+streamName+'.js';
document.getElementById('embedcontainer').appendChild(info);
info.onload = function(){
if (embedtype == '') {
$('#embedcontainer').removeAttr('data-forcetype');
}
else {
$('#embedcontainer').attr('data-forcetype',embedtype);
}
$('#embedcontainer').append(
$('<div>').text('Embedded: '+mistembed(streamName))
);
console.log(mistvideo[streamName]);
mistembed(streamName);
};
});
});
@ -26,11 +35,14 @@
</head>
<body>
<label>
Enter the streamname:
<input type=text></input>
<button>Get video info</button>
</label>
<div id=embedcontainer>
Enter the streamname: <input type=text value=bunny name=streamName>
</label><br>
<label>
Force embed type number: <input type=number name=force min=1> (blank for auto)
</label><br>
<button id=embed>Embed</button>
<div id=button_container></div>
<div id=embedcontainer style="width: 100%; height: 35em;">
</div>
</body>
</html>