Replace Default Mediaplayer

By default rtMedia uses mediaelement.js which WordPress provides. If you want to replace it with some other player than first of all you will need to remove current applied player.

You can remove default player and can assign your custom player after calling following code.

var rtm_player;
jQuery('.rtmedia-container').find('video').each(function() {
rtm_player = jQuery(this)[0].player;
rtm_player.remove();
});
jQuery('.rtmedia-container').find('audio').each(function() {
rtm_player = jQuery(this)[0].player;
rtm_player.remove();
});

Next, you will need to download the custom library you want to use. Add this library to your child theme and enqueue the needed JavaScript file in your theme’s custom JavaScript file.

For example:


//jwplayer JQuery file
wp_enqueue_script( 'custom-jwplayer-js', get_template_directory_uri(). '/js/jwplayer.js', array( 'jquery' ), '20160717', false );

Now you need to bind your custom player. Below is the sample code to bind JWPLAYER to rtMedia video.

var media_element = jQuery( '#rtmedia-single-media-container .rtmedia-media' );
var media_element_id = jQuery( media_element ).attr( 'id' );
//Path for video
var media_path_video = jQuery( '#rtmedia-single-media-container video' ).attr( 'src' );
//Path for audio
var media_path_audio = jQuery( '#rtmedia-single-media-container audio' ).attr( 'src' );
// jwplayer for video
jwplayer( media_element_id ).setup({
file: media_path_video,
height: 360,
width: 640
});
// jwplayer for audio
jwplayer( media_element_id ).setup({
file: media_path_audio,
height: 30,
width: 640
});