Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some url with some Api version Not work #4

Closed
webwayscript opened this issue Sep 1, 2020 · 21 comments
Closed

Some url with some Api version Not work #4

webwayscript opened this issue Sep 1, 2020 · 21 comments

Comments

@webwayscript
Copy link

webwayscript commented Sep 1, 2020

Old Api version 18
1.M3u8 Not work
2. Redirected Url working fine

New Api version 29
1.M3u8 working fine
2. Redirect url not work

Both working fine with exoplayer demo app

http://playerservices.streamtheworld.com/api/livestream-redirect/ARRBEAT_S01.aac ( Redirected play)
https://vidhttps.r.worldssl.net/thanthi-origin/liveabr/playlist.m3u8

We added
' android:usesCleartextTraffic="true"
android:networkSecurityConfig="@xml/network_security_config"

@jrfeng
Copy link
Owner

jrfeng commented Sep 1, 2020

ExoPlayer doesn't follow cross-protocol redirects by default.

Enable cross-protocol redirects:

DefaultHttpDataSourceFactory httpDataSourceFactory =
                new DefaultHttpDataSourceFactory(
                        Util.getUserAgent(context, context.getPackageName()),
                        null,
                        DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS,
                        DefaultHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS,
                        true/*allowCrossProtocolRedirects*/);

DefaultDataSourceFactory dataSourceFactory = new DefaultDataSourceFactory(
        context, httpDataSourceFactory);

Play m3u8 media:

  1. add dependency: exoplayer-dls
implementation 'com.google.android.exoplayer:exoplayer-hls:2.11.7'
  1. create a HlsMediaSource.Factory instance:
public class MyFactory extends PlayerService.ComponentFactory {
    HlsMediaSource.Factory mHlsMediaSourceFactory;

    @Override
    public void init(Context context) {
        ...
        mHlsMediaSourceFactory = new HlsMediaSource.Factory(dataSourceFactory);
    }
    ...
}
  1. use HlsMediaSource.Factory instance create a ExoMusicPlayer:
@Inject
@NonNull
@Override
public MusicPlayer createMusicPlayer(Context context) {
    return new ExoMusicPlayer(context, mHlsMediaSourceFactory);
}

@webwayscript
Copy link
Author

ok you can add it in your SNAPSHOT? we are waiting for further testing

@jrfeng
Copy link
Owner

jrfeng commented Sep 1, 2020

This repository has added support for jitpack, you can built it yourself: https://jitpack.io/#jrfeng/snow

@webwayscript
Copy link
Author

i Dont know why ..

implementation 'com.github.jrfeng.snow:player:master-651f631386-1'

`Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve 
com.github.jrfeng.snow:player:master-651f631386-1.`

@webwayscript
Copy link
Author

jitpack/jitpack.io#3758

@jrfeng
Copy link
Owner

jrfeng commented Sep 1, 2020

@webwayscript
Copy link
Author

Yes its not work

maven { url 'https://www.jitpack.io' }
and
implementation 'com.github.jrfeng.snow:player:master-651f631386-1'

error:

 `Unable to resolve dependency for ':app@debugAndroidTest/compileClasspath': Could not resolve 
 com.github.jrfeng.snow:player:master-651f631386-1.`

Pls check

"make the library readable to everyone."

@jrfeng
Copy link
Owner

jrfeng commented Sep 1, 2020

OK, I'll publish a new release, you can try it again.

@webwayscript
Copy link
Author

using implementation 'com.github.jrfeng.snow:player:1.0-alpha5'
after invalided /cache /restarted

Same issue Old Api version 18
ur: https://vidhttps.r.worldssl.net/thanthi-origin/liveabr/playlist.m3u8

 `09-01 11:23:28.494 2306-2306/com.example.snowtest E/TAG: onConnected: true
 09-01 11:23:42.025 2306-2318/com.example.snowtest E/MediaPlayer: error (1, -1004)
 09-01 11:23:42.025 2306-2306/com.example.snowtest E/MediaPlayer: Error (1,-1004)
 09-01 11:23:42.025 2306-2306/com.example.snowtest E/MediaMusicPlayer: MediaPlayer Error[what: 1, extra: -1004]

09-01 11:23:42.025 2306-2306/com.example.snowtest E/MusicPlayer: errorCode:5`

Same url working fine with api 29 emulator

Same issue Old Api version 20
url : http://playerservices.streamtheworld.com/api/livestream-redirect/HARRISJAYARAJ_S01.aac
Not no sound nio error (Not work)
Working fine Api version 18 emulator

Also no notification icon api level 18..
notification icon showing working fine api level29

@jrfeng
Copy link
Owner

jrfeng commented Sep 1, 2020

@webwayscript OK, I'll check it out.

@jrfeng
Copy link
Owner

jrfeng commented Sep 1, 2020

This doesn't seem to be a bug in this project.

Maybe you can check this StackOverflow post: https://stackoverflow.com/a/51285550/4768512

@webwayscript
Copy link
Author

yes .. this is the problem.. I think we need fix inside our app or your project library?
ok i will check it inside my app

@webwayscript
Copy link
Author

No its not work .. also not work all m3u8 in old apimlevel 18
another url : http://airlsmp6-lh.akamaihd.net/i/AIRLSMP134_1@369210/master.m3u8

also i try with

oncreat ;

  `try {
    ProviderInstaller.installIfNeeded(getApplicationContext());
    SSLContext sslContext;
    sslContext = SSLContext.getInstance("TLSv1.2");
    sslContext.init(null, null, null);
    sslContext.createSSLEngine();
} catch (GooglePlayServicesRepairableException | GooglePlayServicesNotAvailableException
        | NoSuchAlgorithmException | KeyManagementException e) {
    e.printStackTrace();
}`

implementation 'com.google.android.gms:play-services-auth:18.1.0'

not work m3u8 in old api level

@webwayscript
Copy link
Author

I received following error when i use your GitHub project
Ex url": http://airlsmp6-lh.akamaihd.net/i/AIRLSMP134_1@369210/master.m3u8

`snow.player.debug E/ExoMusicPlayer: com.google.android.exoplayer2.ExoPlaybackException: 
com.google.android.exoplayer2.source.UnrecognizedInputFormatException: None of the available extractors 
(MatroskaExtractor, FragmentedMp4Extractor, Mp4Extractor, Mp3Extractor, AdtsExtractor, Ac3Extractor, TsExtractor, 
FlvExtractor, OggExtractor, PsExtractor, WavExtractor, AmrExtractor, Ac4Extractor, FlacExtractor) could read the stream.`

@jrfeng
Copy link
Owner

jrfeng commented Sep 1, 2020

Maybe you should check your audio source. This is not a bug in this project, I can't help for this, sorry.

@webwayscript
Copy link
Author

@webwayscript
Copy link
Author

http://airlsmp6-lh.akamaihd.net/i/AIRLSMP134_1@369210/master.m3u8
this source very popular and no 1 audio video source from akamaihd.net...

@jrfeng
Copy link
Owner

jrfeng commented Sep 1, 2020

https://github.com/jrfeng/snow/blob/master/exo/src/main/java/snow/player/exo/ExoMusicPlayer.java
there is no HlsMediaSourceFactory ...

Maybe you should learn how to use ExoPlayer? Don't mind, I'll create a helper to simplify this operation.

@webwayscript
Copy link
Author

webwayscript commented Sep 1, 2020

i use like this all urls working fine.

`private OkHttpDataSourceFactory dataSourceFactory;
private SimpleExoPlayer exoPlayer;

onCreate
    OkHttpClient okHttpClient;
okHttpClient = new OkHttpClient.Builder()
				.connectTimeout(10, TimeUnit.SECONDS)
				.writeTimeout(10, TimeUnit.SECONDS)
				.readTimeout(10, TimeUnit.SECONDS)
				.build();
exoPlayer = new SimpleExoPlayer.Builder(context).build();
dataSourceFactory = new OkHttpDataSourceFactory(okHttpClient, Util.getUserAgent(context, useragent));

 private void prepareToPlay(Uri uri) {
	if( String.valueOf(uri).contains("m3u8") ) {
		MediaSource videoSource = new HlsMediaSource.Factory(dataSourceFactory).createMediaSource(uri);
		exoPlayer.prepare(videoSource);
	}else{
		MediaSource videoSource = new ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(uri);
		exoPlayer.prepare(videoSource);
	}
}`

This code all m3u8 with or with https working fine .. and also all redirected working fine.. its working fine from api level 16 up to latest version.. I dont know why its not working with your library

Just now i found you using more code in MyFactory.java.. May be okhttp fix all https problem ..

@jrfeng
Copy link
Owner

jrfeng commented Sep 1, 2020

@webwayscript Thanks for feedback, I'll check it carefully.

@jrfeng
Copy link
Owner

jrfeng commented Sep 1, 2020

@webwayscript Can you provide some url of m3u8 media? If it's private, you can send it to my email: jrfeng331@qq.com

@jrfeng jrfeng closed this as completed Sep 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants