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

How to use OkHttpDataSource #1157

Closed
palrahul opened this issue Jan 17, 2016 · 20 comments
Closed

How to use OkHttpDataSource #1157

palrahul opened this issue Jan 17, 2016 · 20 comments

Comments

@palrahul
Copy link

Am trying to figure out if/how to replace DefaultHttpDataSource with OkHttpDataSource

Was trying to evaluate the Okhttp for performance and other usecases.

@b95505017
Copy link
Contributor

Checkout my branch which use OkHttp 2.x
https://github.com/b95505017/ExoPlayer/tree/okhttp_http_data_source

I'll upgrade to 3.x after Facebook's Stetho supporting OkHttp 3.x.

@ojw28 ojw28 added the question label Jan 18, 2016
@palrahul
Copy link
Author

thanks this works great, any plans to submit this as a PR

@ojw28
Copy link
Contributor

ojw28 commented Jan 20, 2016

I'm unclear as to why you don't just take the existing demo app and replace each instantiation of DefaultUriDataSource so that instead of this:

DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter, userAgent);

You have this:

DataSource dataSource = new DefaultUriDataSource(context, bandwidthMeter,
    new OkHttpDataSource(okHttpClient, userAgent, null, bandwidthMeter));

Is it just a matter of documenting this more clearly somewhere?

@b95505017
Copy link
Contributor

I'm too stupid...... You're right.

@b95505017
Copy link
Contributor

@biodatacomp check this out
#735 (comment)
That's why I didn't submit as PR. :)

@ojw28
Copy link
Contributor

ojw28 commented Jan 20, 2016

Let's use this issue to track adding documentation to the corresponding Readme file.

@b95505017
Copy link
Contributor

@biodatacomp I've force update my branch to match up with ExoPlayer 1.5.4, including OkHttp3 & Stetho.

@mkjensen
Copy link

I see that OkHttpDataSource is included with the source code but I'm a bit confused about how to get it via a normal dependency like e.g. compile 'com.google.android.exoplayer:extension-okhttp:r1.5.6'. It seems like that is not possible at the moment?

I'm asking for this approach since I think it works nicely for e.g. Glide by using compile 'com.github.bumptech.glide:okhttp-integration:1.4.0@aar'.

@ojw28
Copy link
Contributor

ojw28 commented Jun 19, 2016

This enhancement is tracking:

  1. Adding a sentence or two to the extension readme.
  2. Making the extension available via BinTray.

@ojw28
Copy link
Contributor

ojw28 commented Oct 5, 2016

In theory it should now be possible to include the OkHttp extension for V2 with:

compile 'com.google.android.exoplayer:extension-okhttp:r2.0.1'

Bintray link here. This doesn't seem to work for me at the moment. I'm unclear whether there's just a propagation delay in it being indexed, or whether something else is wrong. If anyone has any ideas, please let me know!

@b95505017
Copy link
Contributor

Could not find ExoPlayer:library:unspecified.

Caused by

    <dependency>
      <groupId>ExoPlayer</groupId>
      <artifactId>library</artifactId>
      <version>unspecified</version>
      <scope>runtime</scope>
    </dependency>

@ojw28
Copy link
Contributor

ojw28 commented Oct 5, 2016

Yeah. Hence the "This doesn't seem to work for me at the moment" part...!

@b95505017
Copy link
Contributor

The path should be the jCenter one

    <dependency>
      <groupId>com.google.android.exoplayer</groupId>
      <artifactId>exoplayer</artifactId>
      <version>r2.0.1</version>
    </dependency>

@ojw28
Copy link
Contributor

ojw28 commented Oct 5, 2016

I don't really understand what you mean. Have you spotted an error? If so, please clarify exactly what it is.

@ojw28
Copy link
Contributor

ojw28 commented Oct 5, 2016

Ah, I see the problem now. I'm not entirely sure how to fix how that gets generated as part of the release process, but will take a look.

@b95505017
Copy link
Contributor

Yes, we should do some trick to prevent compile project(":library") being wrote into pom. It should transform to jcenter artifact path.
Maybe checkout Firebase-UI project.

@ojw28
Copy link
Contributor

ojw28 commented Oct 5, 2016

It's possible that using https://github.com/bintray/gradle-bintray-plugin instead of https://github.com/novoda/bintray-release resolves this problem. It looks like novoda/bintray-release#16 is tracking supporting this case for bintray-release.

@ojw28
Copy link
Contributor

ojw28 commented Oct 5, 2016

I've manually fixed the POM file for now, so the following should work:

compile 'com.google.android.exoplayer:extension-okhttp:r2.0.1'

Note that if you tried whilst it was broken, you may have to do some cache wiping on your machine. File->InvalidateCaches in Android Studio wasn't sufficient for me. Neither was deleting the .gradle directory in the project. I had to also delete the .gradle directory from my home directory (disclaimer: I don't know what the consequences are of doing that; so do it at your own risk; I just know that it helped for me!).

@ypresto
Copy link

ypresto commented Feb 10, 2017

I tried compile 'com.google.android.exoplayer:extension-okhttp:r1.5.14' because I'm relying on library which still uses ExoPlayer v1, but I found there is no such version of extension.
Is there any plans to release it for v1?

@ojw28