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