• Resolved Bigue Nique

    (@biguenique)


    We have an audio podcast, and we recently released a video version for an episode. I had no problem embedding the video version from where it is hosted into the article, along the audio-only version from Seriously Simple Podcasting. One problem I see with this method is that the video listens are not tracked by Seriously Simple Stats. Especially since the video version is as twice as popular as the audio-only version!

    Seriously Simple Podcasting natively supports videos, but it seems I can only present users with either the audio or the video, not both. I’d like to make sure the audio-only is always available with each episode, but also be able to track listens from the video player in the stats.

    Is there a way to tweak SSP to show (and track listens for) both versions?
    Or, alternatively, is there a way to track the embedded video plays as well?

    That’d be awesome.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
  • Plugin Author Serhiy Zakharchenko

    (@zahardoc)

    Hello @biguenique!

    It’s not a trivial task, but I’ll try to help you.

    What you need, is to change the URL of the video file with the URL with the following template:

    https://{yoursite.com}/podcast-player/{episode_id}/video.mp4?video_file={file_url}

    Where {yoursite.com} – is radiomassecritique.tk

    {episode_id} – your episode ID, you can check it in the URL when you edit the episode, for example – https://radiomassecritique.tk/wp-admin/post.php?post=5898&action=edit means that episode ID is 5898

    {file_url} – path to the video file

    For example, on this page – https://radiomassecritique.tk/2022/10/20/lavigueur-beliveau-vaccination-des-enfants/, the video URL is

    https://player.odycdn.com/api/v3/streams/free/20221020-Radio-Masse-critique-E15.720p/14995ca209b44eb462f2ae73555800c6b755e6c9/72f1e0.mp4,

    so you’ll need to change it to something like this:

    https://radiomassecritique.tk/podcast-player/5898/video.mp4?video_file=https://player.odycdn.com/api/v3/streams/free/20221020-Radio-Masse-critique-E15.720p/14995ca209b44eb462f2ae73555800c6b755e6c9/72f1e0.mp4

    After that, add the following snippet to your functions.php file:

    add_filter( 'ssp_is_podcast_download', function ( $download, $episode_id ) {
    	if ( ! $download ) {
    		return $download;
    	}
    
    	if ( empty( $_GET['video_file'] ) ) {
    		return $download;
    	}
    
    	$video_file = $_GET['video_file'];
    
    	global $wp_query;
    
    	// Get file referrer
    	$referrer = '';
    	if ( isset( $wp_query->query_vars['podcast_ref'] ) && $wp_query->query_vars['podcast_ref'] ) {
    		$referrer = $wp_query->query_vars['podcast_ref'];
    	} else {
    		if ( isset( $_GET['ref'] ) ) {
    			$referrer = esc_attr( $_GET['ref'] );
    		}
    	}
    
    	$episode = get_post( $episode_id );
    
    	do_action( 'ssp_file_download', $video_file, $episode, $referrer );
    
    	wp_redirect( $video_file );
    
    	exit;
    }, 10, 2 );

    It will do the magic of tracking the video listen, and redirecting it to the file itself.

    Hope this helps.

    Best regards,
    Sergiy, development team.

Viewing 1 replies (of 1 total)
  • The topic ‘Provide audio + video (and track both)’ is closed to new replies.