PluginProbe ʕ •ᴥ•ʔ
Broadcast Live Video – Live Streaming : WebRTC, HLS, RTSP, RTMP / trunk
Broadcast Live Video – Live Streaming : WebRTC, HLS, RTSP, RTMP vtrunk
trunk 5.5.1 6.2.1
videowhisper-live-streaming-integration / bp.php
videowhisper-live-streaming-integration Last commit date
htmlchat 3 years ago images 2 years ago inc 1 week ago languages 1 year ago scripts 1 week ago server 1 year ago sounds 3 years ago static 1 week ago bp.php 1 year ago login-logo.png 8 years ago readme.txt 1 week ago screenshot-1.png 2 months ago screenshot-2.png 2 months ago screenshot-3.png 2 months ago screenshot-4.png 2 months ago screenshot-5.png 2 months ago screenshot-6.jpg 1 month ago screenshot-7.jpg 1 month ago template-channel.php 1 year ago videowhisper_streaming.php 1 week ago
bp.php
166 lines
1 <?php
2 // BuddyPress Integration
3
4 if ( ! defined( 'ABSPATH' ) ) {
5 exit; // Exit if accessed directly
6 }
7
8 class liveStreamingGroup extends BP_Group_Extension {
9
10 var $visibility = 'public'; // 'public' will show your extension to non-group members, 'private' means you have to be a member of the group to view your extension.
11
12 var $enable_create_step = true; // If your extension does not need a creation step, set this to false
13 var $enable_nav_item = true; // If your extension does not need a navigation item, set this to false
14 var $enable_edit_item = true; // If your extension does not need an edit screen, set this to false
15
16
17 public function __construct() {
18 $this->name = 'Live Streaming';
19 $this->slug = 'live-streaming';
20
21 $this->create_step_position = 21;
22 $this->nav_item_position = 31;
23 }
24
25
26 public function liveStreamingGroup() {
27 // constructor
28 self::__construct();
29
30 }
31
32
33 function create_screen( $group_id = null ) {
34 if ( ! bp_is_group_creation_step( $this->slug ) ) {
35 return false;
36 }
37 ?>
38
39 <p><?php _e( 'To stream live video on this group just go to Admin > Live Streaming.', 'live-streaming' ); ?></p>
40
41 <?php
42 wp_nonce_field( 'groups_create_save_' . $this->slug );
43 }
44
45
46 function create_screen_save( $group_id = null ) {
47 global $bp;
48
49 check_admin_referer( 'groups_create_save_' . $this->slug );
50
51 /* Save any details submitted here */
52 groups_update_groupmeta( $bp->groups->new_group_id, 'my_meta_name', 'value' );
53 }
54
55
56 function edit_screen( $group_id = null ) {
57 if ( ! bp_is_group_admin_screen( $this->slug ) ) {
58 return false;
59 }
60 ?>
61 <h2><?php echo esc_attr( $this->name ); ?></h2>
62 <?php
63 global $bp;
64 $root_url = get_bloginfo( 'url' ) . '/';
65
66 if ( class_exists( 'VWliveStreaming' ) ) {
67 VWliveStreaming::cleanSessions( 1 );
68 VWliveStreaming::enqueueUI();
69 }
70
71 global $wpdb;
72 $table_name = $wpdb->prefix . 'vw_sessions';
73 $wpdb->flush();
74
75 $channelName = $bp->groups->current_group->slug;
76 $options = get_option( 'VWliveStreamingOptions' );
77
78 // broadcasting?
79 $sql = $wpdb->prepare( "SELECT * FROM $table_name WHERE session = %s AND status = %d", $channelName, 1 );
80 $session = $wpdb->get_row( $sql );
81 if ( $session ) {
82 ?>
83 <p>A live broadcast session is already in progress for this group. A new session can be started 30s after previous completes. Click <a href="<?php echo esc_url( $root_url ) . 'groups/' . esc_attr( $channelName ) . '/' . esc_attr( $this->slug ) . '/'; ?> ">here</a> to watch current session.</p>
84 <?php
85 } else {
86
87 // find post
88 $postID = $wpdb->get_var( $wpdb->prepare( "SELECT ID FROM $wpdb->posts WHERE `post_title` = %s AND `post_type` = %s LIMIT 0,1", $channelName, $options['custom_post'] ) );
89
90 $current_user = wp_get_current_user();
91
92 $post = array(
93 'post_content' => $bp->groups->current_group->description,
94 'post_name' => $channelName,
95 'post_title' => $channelName,
96 'post_author' => $current_user->ID,
97 'post_type' => $options['custom_post'],
98 'post_status' => 'publish',
99 );
100
101 if ( ! $postID ) {
102 echo __( 'First broadcast: creating group channel.', 'live-streaming' ) . ' <b>' . esc_html( $channelName ) . '</b>';
103
104 // var_dump($bp->groups->current_group);
105 $postID = wp_insert_post( $post );
106
107 } else {
108 $post['ID'] = $postID;
109 wp_update_post( $post );
110 }
111
112 echo '<a class="ui button primary" href="' . add_query_arg( array( 'broadcast' => '' ), get_permalink( $postID ) ) . '">' . __( 'Broadcast', 'live-streaming' ) . ' ' . esc_html( $channelName ) . '</a>';
113 // echo do_shortcode('[videowhisper_broadcast channel="' .$channelName. '"]');
114 }
115 }
116
117
118 function edit_screen_save( $group_id = null ) {
119 global $bp;
120
121 if ( ! isset( $_POST['save'] ) ) {
122 return false;
123 }
124
125 check_admin_referer( 'groups_edit_save_' . $this->slug );
126
127 /* Insert your edit screen save code here */
128
129 /* To post an error/success message to the screen, use the following */
130 if ( ! $success ) {
131 bp_core_add_message( __( 'There was an error saving, please try again', 'live-streaming' ), 'error' );
132 } else {
133 bp_core_add_message( __( 'Settings saved successfully', 'live-streaming' ) );
134 }
135
136 bp_core_redirect( bp_get_group_permalink( $bp->groups->current_group ) . '/admin/' . $this->slug );
137 }
138
139
140 function display( $group_id = null ) {
141 /* Use this function to display the actual content of your group extension when the nav item is selected */
142 global $bp;
143 $root_url = get_bloginfo( 'url' ) . '/';
144
145 echo do_shortcode( '[videowhisper_watch channel="' . $bp->groups->current_group->slug . '"]' );
146 }
147
148
149 function widget_display() {
150 ?>
151 <div class="info-group">
152 <h4><?php echo esc_attr( $this->name ); ?></h4>
153 <p>
154 Group Live Streaming allows broadcasting a live video on the group.
155 </p>
156 </div>
157 test
158 <?php
159 }
160
161
162 }
163
164
165 bp_register_group_extension( 'liveStreamingGroup' );
166