Simple M3U Playlist Parser for IPTV Streams (Android/Java)
Simple M3U Playlist Parser for IPTV Streams (Android/Java)
Table Of Contents [Toggle]
This post is is about one simple java class which can parse m3u playlists containing radio and IPTV video streams.
Simply add the SimpleM3UParser.java
class to your Java or Android project to get started.
Parse streams, display in list and play
With this class it’s very easy to get a list of streams:
List<SimpleM3UParser.M3U_Entry> playlist = new SimpleM3UParser().parse("/filepath/to/streams.m3u");
Below is a screenshot of my personal IPTV Android app that my family uses since years to watch IPTV streams. It uses SimpleM3UParser. The screenshot also contains the file structure and structure of a m3u/m3u8 playlist for live streams. (same structure as seen at examples in source code file)
The list in the screenshot is a ListView with simple Image/TextViews. When clicking a item, playback starts. If you want to play using an external media player app on Android, here’s a snippet for VLC media player:
Intent intent = new Intent(Intent.ACTION_VIEW);
intent.setDataAndTypeAndNormalize(Uri.parse(playlist.get(INDEX).getUrl()), "video/*");
intent.setPackage("org.videolan.vlc");
activity.startActivity(intent);
Give me the code!
Code for parser and complete examples is available for Download from GitHub and licensed Apache 2.0.
Additional info
- Looking for URLs of legal live streams? Take a look at KodiNerds-IPTV.
- What is the reason for this blog post?
- I noticed multiple people asking for a simple free & open source app for watching IPTV streams, especially in F-Droid community chat & forum.
- Be it open source or not, this is blog post and associated code may be the starting point of your new IPTV & streaming app!