HamidrezaAmz / MagicalExoPlayer

The Easiest Way To Play/Stream Video And Audio Using Google ExoPlayer In Your Android Application
MIT License
345 stars 77 forks source link

not able to play mkv file #18

Closed pateljigar7210 closed 2 years ago

Inside4ndroid commented 4 years ago

I have this issue when trying to play mkv files....

here is the erro log >

2020-07-08 15:17:07.448 22820-23082/com.app.strix E/ExoPlayerImplInternal: Source error com.google.android.exoplayer2.ParserException: org.xmlpull.v1.XmlPullParserException: unterminated entity ref (position:TEXT @1:385 in java.io.InputStreamReader@dadf4b5) at com.google.android.exoplayer2.source.dash.manifest.DashManifestParser.parse(DashManifestParser.java:96) at com.google.android.exoplayer2.source.dash.manifest.DashManifestParser.parse(DashManifestParser.java:61) at com.google.android.exoplayer2.upstream.ParsingLoadable.load(ParsingLoadable.java:172) at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:391) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641) at java.lang.Thread.run(Thread.java:764) Caused by: org.xmlpull.v1.XmlPullParserException: unterminated entity ref (position:TEXT @1:385 in java.io.InputStreamReader@dadf4b5) at org.kxml2.io.KXmlParser.readEntity(KXmlParser.java:1220) at org.kxml2.io.KXmlParser.readValue(KXmlParser.java:1402) at org.kxml2.io.KXmlParser.next(KXmlParser.java:393) at org.kxml2.io.KXmlParser.next(KXmlParser.java:313) at com.google.android.exoplayer2.source.dash.manifest.DashManifestParser.parse(DashManifestParser.java:89) at com.google.android.exoplayer2.source.dash.manifest.DashManifestParser.parse(DashManifestParser.java:61)  at com.google.android.exoplayer2.upstream.ParsingLoadable.load(ParsingLoadable.java:172)  at com.google.android.exoplayer2.upstream.Loader$LoadTask.run(Loader.java:391)  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)  at java.lang.Thread.run(Thread.java:764) 

Inside4ndroid commented 4 years ago

Whoops i fixed it lol...

for those who would like to know how

first add this line to PublicValues.java in the utils folder >

public static final String KEY_MKV = "mkv";

now in the AndExoPlayerView add this the the MediaSource buildMediaSource method >

else if (validUrl && uri.getLastPathSegment().contains(PublicValues.KEY_MKV)) {

            DefaultHttpDataSourceFactory sourceFactory = new DefaultHttpDataSourceFactory(PublicValues.KEY_USER_AGENT);
            if (extraHeaders != null) {
                for (Map.Entry<String, String> entry : extraHeaders.entrySet())
                    sourceFactory.getDefaultRequestProperties().set(entry.getKey(), entry.getValue());
            }

            return new ProgressiveMediaSource.Factory(sourceFactory)
                    .createMediaSource(uri);

        } else if (!validUrl && uri.getLastPathSegment().contains(PublicValues.KEY_MKV)) {
            return new ProgressiveMediaSource.Factory(new DefaultDataSourceFactory(context, PublicValues.KEY_USER_AGENT))
                    .createMediaSource(uri);

        }

now when you pass an mkv url as source it will play without any issues :)

Happy coding :)

HamidrezaAmz commented 3 years ago

Hey @pateljigar7210 New version of MagicalExoPlayer released, now player support .mkv files, Just update ;)