aboutsummaryrefslogtreecommitdiff
path: root/Src/playlist/M3U8Writer.cpp
diff options
context:
space:
mode:
authorJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
committerJef <jef@targetspot.com>2024-09-24 08:54:57 -0400
commit20d28e80a5c861a9d5f449ea911ab75b4f37ad0d (patch)
tree12f17f78986871dd2cfb0a56e5e93b545c1ae0d0 /Src/playlist/M3U8Writer.cpp
parent537bcbc86291b32fc04ae4133ce4d7cac8ebe9a7 (diff)
downloadwinamp-20d28e80a5c861a9d5f449ea911ab75b4f37ad0d.tar.gz
Initial community commit
Diffstat (limited to 'Src/playlist/M3U8Writer.cpp')
-rw-r--r--Src/playlist/M3U8Writer.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/Src/playlist/M3U8Writer.cpp b/Src/playlist/M3U8Writer.cpp
new file mode 100644
index 00000000..72972216
--- /dev/null
+++ b/Src/playlist/M3U8Writer.cpp
@@ -0,0 +1,39 @@
+#include "M3U8Writer.h"
+#include "../nu/AutoChar.h"
+#include <bfc/platform/types.h>
+
+M3U8Writer::M3U8Writer() : fp(0)
+{
+}
+
+int M3U8Writer::Open(const wchar_t *filename)
+{
+ fp = _wfopen(filename, L"wt");
+ if (!fp)
+ return 0;
+
+ fputs( "\xEF\xBB\xBF", fp );
+ fprintf(fp,"#EXTM3U\n");
+
+ return 1;
+}
+
+void M3U8Writer::Write(const wchar_t *filename)
+{
+ fwprintf(fp,L"%s\n", filename);
+}
+
+void M3U8Writer::Write(const wchar_t *filename, const wchar_t *title, int length)
+{
+ fprintf( fp, "#EXTINF:%d,%s\n%s\n", length, (char *) AutoChar( title, CP_UTF8 ), (char *) AutoChar( filename, CP_UTF8 ) );
+}
+
+void M3U8Writer::Write( const wchar_t *p_filename, const wchar_t *p_title, const wchar_t *p_extended_infos, int p_length )
+{
+ fprintf( fp, "#EXTINF:%d %s,%s\n%s\n", p_length, (char *)AutoChar( p_extended_infos, CP_UTF8 ), (char *)AutoChar( p_title, CP_UTF8 ), (char *)AutoChar( p_filename, CP_UTF8 ) );
+}
+
+void M3U8Writer::Close()
+{
+ fclose(fp);
+} \ No newline at end of file