make all stations playable
This commit is contained in:
parent
0907a573b0
commit
ee1a3bfc59
@ -5,33 +5,20 @@
|
||||
<overwrite>false</overwrite>
|
||||
<charset>utf8</charset>
|
||||
<table>
|
||||
<name>*dbprefix*radio_streams</name>
|
||||
<name>*dbprefix*radio_stations</name>
|
||||
<declaration>
|
||||
<field>
|
||||
<name>id</name>
|
||||
<type>integer</type>
|
||||
<default>0</default>
|
||||
<notnull>true</notnull>
|
||||
<autoincrement>1</autoincrement>
|
||||
<length>4</length>
|
||||
<length>6</length>
|
||||
</field>
|
||||
<field>
|
||||
<name>name</name>
|
||||
<name>user_id</name>
|
||||
<type>text</type>
|
||||
<length>200</length>
|
||||
<default></default>
|
||||
<notnull>true</notnull>
|
||||
<length>64</length>
|
||||
</field>
|
||||
<field>
|
||||
<name>url</name>
|
||||
<type>text</type>
|
||||
<notnull>true</notnull>
|
||||
<length>100</length>
|
||||
</field>
|
||||
<field>
|
||||
<name>image</name>
|
||||
<type>text</type>
|
||||
<notnull>true</notnull>
|
||||
<length>100</length>
|
||||
</field>
|
||||
</declaration>
|
||||
</table>
|
||||
|
@ -3,7 +3,7 @@
|
||||
<id>radio</id>
|
||||
<name>Radio</name>
|
||||
<description>Listening to your favorite radio stations in Nextcloud</description>
|
||||
<version>0.2</version>
|
||||
<version>0.3</version>
|
||||
<licence>MIT</licence>
|
||||
<author>Jonas Heinrich</author>
|
||||
<dependencies>
|
||||
|
@ -10,3 +10,12 @@ $this->create('radio_index', '/')
|
||||
->actionInclude('radio/index.php');
|
||||
$this->create('radio_ajax_seturl', 'ajax/seturl.php')
|
||||
->actionInclude('radio/ajax/seturl.php');
|
||||
|
||||
return [
|
||||
'resources' => [
|
||||
'station' => ['url' => '/stations'],
|
||||
],
|
||||
'routes' => [
|
||||
['name' => 'page#index', 'url' => '/', 'verb' => 'GET'],
|
||||
]
|
||||
];
|
||||
|
@ -1 +0,0 @@
|
||||
0.1
|
@ -7,15 +7,11 @@ use OCP\AppFramework\Db\Entity;
|
||||
|
||||
class Stream extends Entity implements JsonSerializable {
|
||||
|
||||
protected $title;
|
||||
protected $content;
|
||||
protected $userId;
|
||||
|
||||
public function jsonSerialize() {
|
||||
return [
|
||||
'name' => $this->name,
|
||||
'url' => $this->url,
|
||||
'image' => $this->image
|
||||
'id' => $this->id
|
||||
];
|
||||
}
|
||||
}
|
||||
|
45
js/main.js
45
js/main.js
@ -1,13 +1,25 @@
|
||||
$(window).on('load', function(){
|
||||
|
||||
$('body').on('click', 'tr', function() {
|
||||
var sourceUrl = $(this).attr('data-src');
|
||||
$("#player").attr("src", sourceUrl);
|
||||
$('#player').trigger('play');
|
||||
var stationid = $(this).attr('data-id');
|
||||
play_station(stationid);
|
||||
});
|
||||
|
||||
function play_station(stationid){
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "http://www.radio-browser.info/webservice/v2/json/url/"+stationid,
|
||||
dataType: 'json',
|
||||
success: function(data){
|
||||
var sourceUrl = data['url'];
|
||||
$("#player").attr("src", sourceUrl);
|
||||
$('#player').trigger('play');
|
||||
return true;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
function render_result(data){
|
||||
$("tbody > tr").remove();
|
||||
$.each(data, function(i, station) {
|
||||
$('tbody').append('<tr data-src='+station['url']+' data-id='+station['id']+'>\
|
||||
<td class="filename">\
|
||||
@ -26,6 +38,21 @@ $(window).on('load', function(){
|
||||
});
|
||||
}
|
||||
|
||||
function get_station_ids(){
|
||||
return ["89920","44707"]
|
||||
};
|
||||
|
||||
function render_stations(station_ids){
|
||||
for (stationid in station_ids){
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "https://www.radio-browser.info/webservice/json/stations/byid/"+station_ids[stationid],
|
||||
dataType: 'json',
|
||||
success: render_result
|
||||
});
|
||||
};
|
||||
};
|
||||
|
||||
function radio_query(type, query){
|
||||
switch (type) {
|
||||
case 0:
|
||||
@ -50,7 +77,8 @@ $(window).on('load', function(){
|
||||
};
|
||||
|
||||
function switch_menu(type) {
|
||||
$('#app-navigation').find('li').removeClass("active");;
|
||||
$('#app-navigation').find('li').removeClass("active");
|
||||
$("tbody > tr").remove();
|
||||
switch (type) {
|
||||
case 0:
|
||||
$('li.nav-files').addClass('active');
|
||||
@ -62,11 +90,14 @@ $(window).on('load', function(){
|
||||
break;
|
||||
case 2:
|
||||
$('li.nav-favorite').addClass('active');
|
||||
station_ids = get_station_ids()
|
||||
render_stations(station_ids)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
$('#radiosearch').submit(function() {
|
||||
$("tbody > tr").remove();
|
||||
var query = $('#radioquery').val();
|
||||
radio_query(0, query);
|
||||
});
|
||||
@ -79,5 +110,9 @@ $(window).on('load', function(){
|
||||
switch_menu(1);
|
||||
});
|
||||
|
||||
$('a.nav-icon-favorites').click(function() {
|
||||
switch_menu(2);
|
||||
});
|
||||
|
||||
switch_menu(0);
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user