Player.pm 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. package Plugins::SqueezeESP32::Player;
  2. use strict;
  3. use base qw(Slim::Player::SqueezePlay);
  4. use Slim::Utils::Log;
  5. use Slim::Utils::Prefs;
  6. my $prefs = preferences('plugin.squeezeesp32');
  7. my $log = logger('plugin.squeezeesp32');
  8. sub model { 'squeezeesp32' }
  9. sub modelName { 'SqueezeESP32' }
  10. sub hasIR { 0 }
  11. sub init {
  12. my $client = shift;
  13. $prefs->client($client)->init( {
  14. eq => [0, 0, 0, 0, 0, 0, 0, 0, 0, 0],
  15. }
  16. );
  17. $client->SUPER::init(@_);
  18. Plugins::SqueezeESP32::Plugin::config_artwork($client);
  19. }
  20. # Allow the player to define it's display width (and probably more)
  21. sub playerSettingsFrame {
  22. my $client = shift;
  23. my $data_ref = shift;
  24. my $value;
  25. my $id = unpack('C', $$data_ref);
  26. # New SETD command 0xfe for display width & height
  27. if ($id == 0xfe) {
  28. $value = (unpack('Cn', $$data_ref))[1];
  29. if ($value > 100 && $value < 400) {
  30. $prefs->client($client)->set('width', $value);
  31. my $height = (unpack('Cnn', $$data_ref))[2];
  32. $prefs->client($client)->set('height', $height || 0);
  33. $client->display->modes($client->display->build_modes);
  34. $client->display->widthOverride(1, $value);
  35. $client->update;
  36. $log->info("Setting player $value" . "x" . "$height for ", $client->name);
  37. }
  38. }
  39. $client->SUPER::playerSettingsFrame($data_ref);
  40. }
  41. sub hasScrolling {
  42. return 1;
  43. }
  44. sub reconnect {
  45. my $client = shift;
  46. $client->pluginData('artwork_md5', '');
  47. $client->SUPER::reconnect(@_);
  48. Plugins::SqueezeESP32::Plugin::send_equalizer($client);
  49. }
  50. 1;