Skip to content

Commit

Permalink
remove "grab current playing from radio" code.
Browse files Browse the repository at this point in the history
  • Loading branch information
artemanufrij committed Jan 14, 2018
1 parent 3eb8c59 commit 3f4dafa
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 99 deletions.
15 changes: 15 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
// Verwendet IntelliSense zum Ermitteln möglicher Attribute.
// Zeigen Sie auf vorhandene Attribute, um die zugehörigen Beschreibungen anzuzeigen.
// Weitere Informationen finden Sie unter https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug",
"type": "gdb",
"request": "launch",
"target": "./build/src/com.github.artemanufrij.playmymusic",
"cwd": "${workspaceRoot}"
}
]
}
16 changes: 16 additions & 0 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "make",
"type": "shell",
"command": "cd ${workspaceFolder}/build && make",
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
6 changes: 5 additions & 1 deletion data/com.github.artemanufrij.playmymusic.appdata.xml
Original file line number Diff line number Diff line change
Expand Up @@ -58,12 +58,16 @@
</screenshot>
</screenshots>
<releases>
<release version="0.4.3" date="2018-01-20">
<release version="0.4.3" date="2018-01-15">
<description>
<p>Fix:</p>
<ul>
<li>Spinner visibility while library is being scanned</li>
</ul>
<p>Translation:</p>
<ul>
<li>Spanish (by Alain)</li>
</ul>
</description>
</release>
<release version="0.4.2" date="2018-01-07">
Expand Down
29 changes: 7 additions & 22 deletions src/Interfaces/SoundIndicator.vala
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ namespace PlayMyMusic.Interfaces {

[DBus(name = "org.mpris.MediaPlayer2")]
public class SoundIndicatorRoot : GLib.Object {
PlayMyMusic.PlayMyMusicApp app;
PlayMyMusicApp app;

construct {
this.app = PlayMyMusic.PlayMyMusicApp.instance;
this.app = PlayMyMusicApp.instance;
}

public string DesktopEntry {
Expand All @@ -90,19 +90,15 @@ namespace PlayMyMusic.Interfaces {

[DBus(name = "org.mpris.MediaPlayer2.Player")]
public class SoundIndicatorPlayer : GLib.Object {
PlayMyMusic.Services.Player player;
PlayMyMusic.Services.TagManager tg_manager;
Services.Player player;
DBusConnection connection;
PlayMyMusic.PlayMyMusicApp app;
PlayMyMusicApp app;

public SoundIndicatorPlayer (DBusConnection connection) {
this.app = PlayMyMusic.PlayMyMusicApp.instance;
this.app = PlayMyMusicApp.instance;
this.connection = connection;
player = PlayMyMusic.Services.Player.instance;
player = Services.Player.instance;
player.state_changed.connect_after (player_state_changed);

tg_manager = PlayMyMusic.Services.TagManager.instance;
tg_manager.discovered_new_radio_content.connect (radio_content);
}

private static string[] get_simple_string_array (string text) {
Expand Down Expand Up @@ -162,7 +158,7 @@ namespace PlayMyMusic.Interfaces {
property = "Playing";
var metadata = new HashTable<string, Variant> (null, null);
if (player.current_track != null) {
if (player.play_mode == PlayMyMusic.Services.PlayMode.AUDIO_CD) {
if (player.play_mode == Services.PlayMode.AUDIO_CD) {
metadata.insert("xesam:title", player.current_track.title);
metadata.insert("xesam:artist", get_simple_string_array (player.current_track.audio_cd.title));
} else {
Expand Down Expand Up @@ -193,16 +189,5 @@ namespace PlayMyMusic.Interfaces {
}
send_properties ("PlaybackStatus", property);
}

private void radio_content (string uri, string content) {
if (player.current_radio != null && player.current_radio.file == uri) {
var metadata = new HashTable<string, Variant> (null, null);
var file = File.new_for_path (player.current_radio.cover_path);
metadata.insert("mpris:artUrl", file.get_uri ());
metadata.insert("xesam:title", player.current_radio.title);
metadata.insert("xesam:artist", get_simple_string_array (content));
send_properties ("Metadata", metadata);
}
}
}
}
31 changes: 1 addition & 30 deletions src/Services/Player.vala
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ namespace PlayMyMusic.Services {
public signal void current_progress_changed (double percent);
public signal void current_duration_changed (int64 duration);
uint progress_timer = 0;
uint radio_tag_grabber_timer = 0;

PlayMyMusic.Settings settings;

Expand Down Expand Up @@ -100,19 +99,14 @@ namespace PlayMyMusic.Services {

state_changed.connect ((state) => {
stop_progress_signal ();
stop_radio_grabber ();
if (state != Gst.State.NULL) {
playbin.set_state (state);
} else {
Interfaces.Inhibitor.instance.uninhibit ();
}
switch (state) {
case Gst.State.PLAYING:
if (play_mode == PlayMode.RADIO) {
start_radio_grabber ();
} else {
start_progress_signal ();
}
start_progress_signal ();
Interfaces.Inhibitor.instance.inhibit ();
break;
case Gst.State.READY:
Expand Down Expand Up @@ -147,29 +141,6 @@ namespace PlayMyMusic.Services {
});
}

public void stop_radio_grabber () {
if (radio_tag_grabber_timer != 0) {
Source.remove (radio_tag_grabber_timer);
radio_tag_grabber_timer = 0;
}
}

public void start_radio_grabber () {
return;
Services.LibraryManager.instance.tg_manager.add_discover_uri (current_radio.file);
radio_tag_grabber_timer = GLib.Timeout.add (6000, () => {
if (current_radio == null) {
stop_radio_grabber ();
return false;
}

stdout.printf ("%s\n", current_radio.file);

Services.LibraryManager.instance.tg_manager.add_discover_uri (current_radio.file);
return true;
});
}

public void set_radio (PlayMyMusic.Objects.Radio? radio) {
if (radio == current_radio || radio == null || radio.file == null) {
return;
Expand Down
31 changes: 7 additions & 24 deletions src/Services/TagManager.vala
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ namespace PlayMyMusic.Services {
}

public signal void discovered_new_item (PlayMyMusic.Objects.Artist artist, PlayMyMusic.Objects.Album album, PlayMyMusic.Objects.Track track);
public signal void discovered_new_radio_content (string radio_uri, string content);
public signal void discover_started ();
public signal void discover_finished ();

Expand All @@ -63,19 +62,6 @@ namespace PlayMyMusic.Services {
string uri = info.get_uri ();
if (info.get_result () != Gst.PbUtils.DiscovererResult.OK) {
warning ("DISCOVER ERROR: '%d' %s %s\n(%s)", err.code, err.message, info.get_result ().to_string (), uri);
} else if (uri.has_prefix ("http")) {
var tags = info.get_tags ();
string? o;
if (!tags.get_string (Gst.Tags.TITLE, out o)) {
if (!tags.get_string (Gst.Tags.ARTIST, out o)) {
if (!tags.get_string (Gst.Tags.ALBUM_ARTIST, out o)) {
tags.get_string (Gst.Tags.ALBUM, out o);
}
}
}
if (o != null && o != "") {
discovered_new_radio_content (uri, o);
}
} else {
var tags = info.get_tags ();
if (tags != null) {
Expand Down Expand Up @@ -156,24 +142,21 @@ namespace PlayMyMusic.Services {
}
}

if (!uri.has_prefix ("http")) {
discover_counter--;
if (discover_counter == 0) {
discover_finished ();
}
discover_counter--;
if (discover_counter == 0) {
discover_finished ();
}

info.dispose ();
return null;
});
}

public void add_discover_uri (string uri) {
if (!uri.has_prefix ("http")) {
if (discover_counter == 0) {
discover_started ();
}
discover_counter++;
if (discover_counter == 0) {
discover_started ();
}
discover_counter++;
discoverer.discover_uri_async (uri);
}
}
Expand Down
24 changes: 13 additions & 11 deletions src/Widgets/Views/AlbumsView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -165,18 +165,20 @@ namespace PlayMyMusic.Widgets.Views {
}

private void do_sort () {
if (timer_sort != 0) {
Source.remove (timer_sort);
timer_sort = 0;
}
lock (timer_sort) {
if (timer_sort != 0) {
Source.remove (timer_sort);
timer_sort = 0;
}

timer_sort = Timeout.add (500, () => {
albums.set_sort_func (albums_sort_func);
albums.set_sort_func (null);
Source.remove (timer_sort);
timer_sort = 0;
return false;
});
timer_sort = Timeout.add (500, () => {
albums.set_sort_func (albums_sort_func);
albums.set_sort_func (null);
Source.remove (timer_sort);
timer_sort = 0;
return false;
});
}
}

public void activate_by_track (Objects.Track track) {
Expand Down
24 changes: 13 additions & 11 deletions src/Widgets/Views/ArtistsView.vala
Original file line number Diff line number Diff line change
Expand Up @@ -129,18 +129,20 @@ namespace PlayMyMusic.Widgets.Views {
}

private void do_sort () {
if (timer_sort != 0) {
Source.remove (timer_sort);
timer_sort = 0;
}
lock (timer_sort) {
if (timer_sort != 0) {
Source.remove (timer_sort);
timer_sort = 0;
}

timer_sort = Timeout.add (500, () => {
artists.set_sort_func (artists_sort_func);
artists.set_sort_func (null);
Source.remove (timer_sort);
timer_sort = 0;
return false;
});
timer_sort = Timeout.add (500, () => {
artists.set_sort_func (artists_sort_func);
artists.set_sort_func (null);
Source.remove (timer_sort);
timer_sort = 0;
return false;
});
}
}

public void activate_by_track (Objects.Track track) {
Expand Down

0 comments on commit 3f4dafa

Please sign in to comment.