This tutorial walks you through creating an M3U playlist that's compatible with the xPola Player, an advanced media player capable of playing multiple formats. The steps below will help you structure and customize your M3U playlist to include features like logos, user-agent headers, and multi-server support.
Steps to Create an M3U Playlist
Step 1: Start by opening a text editor, such as Notepad++ or any other code editor, and create a new file. Save it with a relevant name, such as playlist.m3u.
Step 2: At the very beginning of your playlist file, add the following line to indicate that the file is an M3U playlist:
#EXTM3U
Step 3: Add each media entry following this structure. You can include details like group titles, channel logos, and video names. Below is an example:
#EXTINF:-1 group-title="Group Name" tvg-logo="https://example.com/images/logo.jpeg", Video Name 1
https://example.com/file/video.m3u8
Advanced M3U Configurations
To configure the playlist with specific headers like user-agent, referrer, or player type, use the appropriate commands as shown below.
Adding User-Agent
To include a specific user-agent header for the stream, use:
#EXTINF:-1 group-title="Group Name" tvg-logo="https://example.com/images/logo.jpeg", Video Name 1
#EXTVLCOPT:http-user-agent=your-agent-here
https://example.com/file/video.m3u8
Adding Subtitle
To include a subtitle for the stream, use:
#EXTINF:-1 group-title="Group Name" tvg-logo="https://example.com/images/logo.jpeg", Video Name 1
#EXTVLCOPT:http-subtitle=https://raw.githubusercontent.com/ninawatch/test2/refs/heads/main/test.vtt
https://commondatastorage.googleapis.com/gtv-videos-bucket/sample/BigBuckBunny.mp4
Adding Authentication
To include authentication for the stream, use:
#EXTINF:-1 group-title="Group Name" tvg-logo="https://example.com/images/logo.jpeg", Video Name 1
#EXTVLCOPT:http-auth=https://example.com/authentication.php
https://example.com/file/video.m3u8
Adding Referrer
To specify a referrer, add:
#EXTINF:-1 group-title="Group Name" tvg-logo="https://example.com/images/logo.jpeg", Video Name 1
#EXTVLCOPT:http-referrer=https://domaine.com/
https://example.com/file/video.m3u8
Setting the HTTP Origin
To set the HTTP origin for a video link, use the following line:
#EXTINF:-1 group-title="Group Name" tvg-logo="https://example.com/images/logo.jpeg", Video Name 1
#EXTVLCOPT:http-origin=https://domaine.com
https://example.com/file/video.m3u8
This option is used to specify the HTTP origin header when accessing the video link. It's essential for certain streams or servers that require an origin value to ensure the request is valid, usually to check the origin of the request for security or access control purposes.
Setting the X-Requested-With Header
To set the X-Requested-With header for a video link, use the following line:
#EXTINF:-1 group-title="Group Name" tvg-logo="https://example.com/images/logo.jpeg", Video Name 1
#EXTVLCOPT:http-requested=com.android.browser
https://example.com/file/video.m3u8
This option is used to specify the X-Requested-With HTTP header when accessing the video link. This header is often required by servers to identify the client making the request, commonly for security, access control, or compatibility purposes.
Setting Custom Cookies for a Video Stream
This option allows you to pass custom cookies to the video stream URL. Cookies can be used for authentication, session handling, or other purposes required by the server to grant access to the media content.
#EXTINF:-1 group-title="Group Name" tvg-logo="https://example.com/images/logo.jpeg", Video Name 1
#EXTVLCOPT:http-cookie=name=value;name2=value2
https://example.com/file/example.m3u8
How it works: You define one or more cookies using the format name=value. You can set multiple cookies by separating them with semicolons. When the media player sends the request to access the video, it will include these cookies in the request headers, just as a browser would. This is useful when the server requires specific cookie values to grant access to the video stream.
Setting the Player Type
To configure the player type, use the following options:
#EXTINF:-1 group-title="Group Name" tvg-logo="https://example.com/images/logo.jpeg", Video Name 1
#EXTVLCOPT:http-player-type=webplayer
https://example.com/file/video.html
#EXTINF:-1 group-title="Group Name" tvg-logo="https://example.com/images/logo.jpeg", Video Name 2
#EXTVLCOPT:http-player-type=m3u
https://example.com/file/playlist.m3u
Available player types: webplayer, browser, external, m3u. This option tells the player how to handle the content based on its format.
DRM Configurations
You can specify DRM license configurations for ClearKey, Widevine, or PlayReady:
#EXTINF:-1 group-title="Group Name" tvg-logo="https://example.com/images/logo.jpeg", Video Name 1
#EXTVLCOPT:http-drm-scheme=clearkey
#EXTVLCOPT:http-drm-license=xxxxxxxxxxxxxxxxx:yyyyyyyyyyyyyyyyyy
https://example.com/file/stream.mpd
#EXTINF:-1 group-title="Group Name" tvg-logo="https://example.com/images/logo.jpeg", Video Name 1
#KODIPROP:inputstream.adaptive.license_type=clearkey
#KODIPROP:inputstream.adaptive.license_key=xxxxxxxxxxxxxxxxx:yyyyyyyyyyyyyyyyyy
https://example.com/file/stream.mpd
Automatically Fetching a Video Stream from a Webpage
This option is particularly useful when you have a webpage with an embedded video player or video link, and you want the media player to find and play the video stream without showing the webpage itself.
#EXTINF:-1 group-title="Group Name" tvg-logo="https://example.com/images/logo.jpeg", Video Name 1
#EXTVLCOPT:http-find=any_key_word_in_the_link;m3u8
https://example.com/file/example.html
How it works: You provide the link to a webpage that contains the video player or video URL, and specify a keyword (like "m3u8") that is part of the actual video link. The player will open the webpage in the background, search for the video link that matches the keyword, extract it, and play the video directly in the player without displaying the webpage.
PHP and HTML Integration
If you want to open videos in the xPola Player app directly from a web page, you can use the following PHP or HTML code snippets. These examples show how to encode a video URL and pass it to the xPola Player via an intent in Android:
PHP Integration
<?php
$videoUrl = "https://example.com/file/playlist.m3u8";
?>
<button onClick="location.href='intent://<?php echo base64_encode($videoUrl); ?>#Intent;scheme=xmtv;package=com.xpola.player;end'">Play</button>
HTML/JavaScript Integration
<!DOCTYPE html>
<html>
<head>
<title>Play Video</title>
</head>
<body>
<button onclick="playVideo()">Play Video</button>
<script>
function playVideo() {
let videoUrl = "https://example.com/file/playlist.m3u8|referer=https://example.com/";
location.href = 'intent://' + btoa(videoUrl) + '#Intent;scheme=xmtv;package=com.xpola.player;end';
}
</script>
</body>
</html>
xPola Player Features
xPola Player is a versatile media player that supports a wide range of formats and provides advanced features for an enhanced viewing experience.
Multiple Format Support
Supports MP4, MP3, TS, MPEG, MOV, MKV, HTML, PHP pages, and M3U playlists for maximum compatibility.
Advanced Streaming
Handles HLS streams, adaptive bitrate streaming, and supports multi-server configurations for reliability.
DRM Support
Compatible with ClearKey, Widevine, and PlayReady DRM systems for protected content playback.
Custom Headers
Allows setting custom HTTP headers like User-Agent, Referrer, and Cookies for accessing restricted content.
Subtitle Support
Supports external subtitle files and closed captions for an inclusive viewing experience.
Easy Integration
Simple integration with websites using PHP or JavaScript for direct playback from web pages.