aboutsummaryrefslogtreecommitdiff
path: root/icecast_page.module
diff options
context:
space:
mode:
Diffstat (limited to 'icecast_page.module')
-rw-r--r--icecast_page.module75
1 files changed, 75 insertions, 0 deletions
diff --git a/icecast_page.module b/icecast_page.module
new file mode 100644
index 0000000..f4cbf62
--- /dev/null
+++ b/icecast_page.module
@@ -0,0 +1,75 @@
+<?php
+
+/**
+ * @file
+ *
+ * Icecast page module.
+ */
+
+/**
+ * Implements hook_menu()
+ */
+function icecast_page_menu() {
+ /*
+ *$items['blog'] = array(
+ * 'title' => 'blogs',
+ * 'page callback' => 'blog_page',
+ * 'access arguments' => array('access content'),
+ * 'type' => MENU_SUGGESTED_ITEM,
+ *);
+ */
+ $items['stream'] = array(
+ 'title' => 'Icecast Stream',
+ 'page callback' => 'icecast_page',
+ 'access arguments' => array('access content'),
+ 'type' => MENU_CALLBACK,
+ );
+
+ return $items;
+}
+
+/**
+ * Implements hook_theme()
+ */
+function icecast_page_theme() {
+ return array(
+ 'icecast_page' => array(
+ 'arguments' => array('listen_url' => NULL),
+ 'template' => 'icecast_page', ),
+ 'qwebirc' => array(
+ 'arguments' => array('mount' => NULL),
+ 'template' => 'qwebirc', ),
+ 'icecast_page_footer' => array(
+ 'arguments' => array('listen_url' => NULL),
+ 'template' => 'icecast_page_footer', ),
+ );
+}
+
+/**
+ * Page callback.
+ *
+ * @param $sid
+ * Stream Id.
+ */
+function icecast_page($sid = NULL) {
+ $sid = (int) $sid;
+ $query = 'SELECT server_name, description, listen_url FROM {yp_stream} WHERE sid = %d';
+ $result = db_fetch_array(db_query(db_rewrite_sql($query), $sid));
+
+ if ($sid == NULL || empty($result['listen_url'])) {
+ drupal_not_found();
+ return;
+ }
+
+ drupal_set_title(t('Live: @server_name', array('@server_name' => check_plain($result['server_name']))));
+
+ $mount = basename($result['listen_url'], '.ogg');
+ $mount = basename($mount, '.ogv');
+ $mount = basename($mount, '.mp3');
+
+ $output = theme('icecast_page', $result['listen_url']);
+ $output .= theme('qwebirc', $mount);
+ $output .= theme('icecast_page_footer', $result['listen_url']);
+
+ return $output;
+}