/lib/class/localplay_controller.abstract.php

https://gitlab.com/x33n/ampache · PHP · 113 lines · 51 code · 15 blank · 47 comment · 3 complexity · fe0af774293bb6e498fad013f61f2e84 MD5 · raw file

  1. <?php
  2. /* vim:set softtabstop=4 shiftwidth=4 expandtab: */
  3. /**
  4. *
  5. * LICENSE: GNU General Public License, version 2 (GPLv2)
  6. * Copyright 2001 - 2015 Ampache.org
  7. *
  8. * This program is free software; you can redistribute it and/or
  9. * modify it under the terms of the GNU General Public License v2
  10. * as published by the Free Software Foundation.
  11. *
  12. * This program is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  15. * GNU General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this program; if not, write to the Free Software
  19. * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  20. *
  21. */
  22. /*
  23. * localplay_controller Class
  24. *
  25. * This is the abstract class for any localplay controller
  26. *
  27. */
  28. abstract class localplay_controller
  29. {
  30. // Required Functions
  31. abstract public function add_url(Stream_URL $url); // Takes an array of song_ids
  32. abstract public function delete_track($object_id); // Takes a single object_id and removes it from the playlist
  33. abstract public function play();
  34. abstract public function stop();
  35. abstract public function get();
  36. abstract public function connect();
  37. abstract public function status();
  38. abstract public function get_version(); // Returns the version of this plugin
  39. abstract public function get_description(); // Returns the description
  40. abstract public function is_installed(); // Returns an boolean t/f
  41. abstract public function install();
  42. abstract public function uninstall();
  43. // For display we need the following 'instance' functions
  44. abstract public function add_instance($data);
  45. abstract public function delete_instance($id);
  46. abstract public function update_instance($id,$post);
  47. abstract public function get_instances();
  48. abstract public function instance_fields();
  49. abstract public function set_active_instance($uid);
  50. abstract public function get_active_instance();
  51. /**
  52. * get_url
  53. * This returns the URL for the passed object
  54. */
  55. public function get_url($object)
  56. {
  57. // This might not be an object!
  58. if (!is_object($object)) {
  59. // Stupiidly we'll just blindly add it for now
  60. return $object;
  61. }
  62. $class = get_class($object);
  63. $url = call_user_func(array($class,'play_url'),$object->id);
  64. return $url;
  65. } // get_url
  66. /**
  67. * get_file
  68. * This returns the Filename for the passed object, not
  69. * always possible
  70. *
  71. * @SuppressWarnings(PHPMD.UnusedFormalParameter)
  72. */
  73. public function get_file($object)
  74. {
  75. } // get_file
  76. /**
  77. * parse_url
  78. * This takes an Ampache URL and then returns the 'primary' part of it
  79. * So that it's easier for localplay modules to return valid song information
  80. */
  81. public function parse_url($url)
  82. {
  83. // Define possible 'primary' keys
  84. $primary_array = array('oid','demo_id','random');
  85. $data = array();
  86. $variables = parse_url($url,PHP_URL_QUERY);
  87. if ($variables) {
  88. parse_str($variables,$data);
  89. foreach ($primary_array as $pkey) {
  90. if ($data[$pkey]) {
  91. $data['primary_key'] = $pkey;
  92. return $data;
  93. }
  94. } // end foreach
  95. }
  96. return $data;
  97. } // parse_url
  98. } // end localplay_controller interface