Tool Grator Post JW
នេះជាកូដដែលបានកែប្រែទៅជាទម្រង់ **Modern Interface** និងដំណើរការបានលឿនរលូនជាងមុន ដោយប្រើប្រាស់ CSS Flexbox, custom design properties ពណ៌ `#04abc1` និង JavaScript Events ថ្មីៗ ដើម្បីឱ្យកម្មវិធីចាក់វីដេអូ (Player Controls) មើលទៅប្លែក ទំនើប និងស្អាតជាងមុន៖
“`php
15 ) );
header( ‘Content-Type: text/vtt; charset=utf-8’ );
header( ‘Access-Control-Allow-Origin: *’ );
if ( ! is_wp_error( $response ) ) {
echo wp_remote_retrieve_body( $response );
} else {
echo “WEBVTT\n\n00:00:00.000 –> 00:00:05.000\nError loading subtitles.”;
}
exit;
}
}
// ==========================================
// 2. THE PLAYER SHORTCODE
// ==========================================
function tvpop_jw_player_shortcode( $atts ) {
$atts = shortcode_atts(
array(
‘file’ => ”,
‘sub1’ => ”, // For Khmer (Default)
‘sub2’ => ”, // For English
),
$atts,
‘tvpop_JW’
);
if ( empty( $atts[‘file’] ) ) {
return ”;
}
$player_id = ‘tvpopPlayer_’ . uniqid();
$video_file = esc_url( $atts[‘file’] );
// Prepare the subtitle tracks and route them through our proxy
$tracks_js = ”;
if ( ! empty( $atts[‘sub1’] ) ) {
$sub1_proxy = site_url( ‘?tvpop_vtt_proxy=’ . urlencode( $atts[‘sub1’] ) );
$tracks_js .= ‘{ file: “‘ . esc_url( $sub1_proxy ) . ‘”, label: “Khmer”, kind: “captions”, default: true },’;
}
if ( ! empty( $atts[‘sub2’] ) ) {
$sub2_proxy = site_url( ‘?tvpop_vtt_proxy=’ . urlencode( $atts[‘sub2’] ) );
$tracks_js .= ‘{ file: “‘ . esc_url( $sub2_proxy ) . ‘”, label: “English”, kind: “captions” },’;
}
ob_start();
?>
const vastDataTag_ = 'data:text/xml;charset=utf-8,' + encodeURIComponent(customVastXML_);
jwplayer("").setup({ file: "", width: "100%", aspectratio: "16:9", autostart: true, phls: true, // Enables fast HLS playback optimization
captions: { fontFamily: "'Google Sans', sans-serif", fontSize: 19, color: "#04abc1", // Custom Request Hex Color[cite: 1] edgeStyle: "none", backgroundColor: "rgba(0, 0, 0, 0.65)", backgroundOpacity: 65 },
tracks: [ ],
advertising: { client: "vast", schedule: [ { offset: "pre", tag: vastDataTag_ } ] } });
