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
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:
#EXTVLCOPT:http-user-agent=your-agent-here
For example:
#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 Referrer
To specify a referrer, add:
#EXTVLCOPT:http-referrer=https://domaine.com/
Example:
#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:
#EXTVLCOPT:http-origin=https://domaine.com
Example:
#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 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.
#EXTVLCOPT:http-cookie=name=value;name2=value2
Example:
#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.
For example, if the server requires session authentication or other information stored in cookies, you can set these values to ensure the player can access and play the content properly.
Setting the Player Type to Web Player
To configure the player type as "webplayer", use the following line:
#EXTVLCOPT:http-player-type=webplayer
#EXTVLCOPT:http-player-type=browser
#EXTVLCOPT:http-player-type=browser
#EXTVLCOPT:http-player-type=external
#EXTVLCOPT:http-player-type=m3u
Example:
#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 1
#EXTVLCOPT:http-player-type=m3u
https://example.com/file/playlist.m3u
This option tells the player to open the link in a web player format. It's useful when the content is designed to be played directly in a browser or web-based media player rather than a standalone app or media player.
Advanced Configurations
To handle multi-server streams or advanced player configurations, you can add multiple server links in the following format:
#EXTINF:-1 group-title="Group Name" tvg-logo="https://example.com/images/logo.jpeg", Video Name 1
servers=["https://server1.com/playlist.m3u8|referer=https://example.com/",
"https://server2.com/playlist.m3u8|user-agent=CustomAgent"]
You can also 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
OR
#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.
#EXTVLCOPT:http-find=any_key_word_in_the_link;m3u8
Example:
#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.
This is useful for avoiding unnecessary webpage content and directly streaming the video by automatically finding the correct video link from the page.
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
$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>
Similar HTML-based buttons can be created to trigger playback directly in xPola Player:
<!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>