4

After following the example given at the developer guide, i'm getting the following:

05-23 16:25:22.002 11893-11942/com.app.videotest E/ExoPlayerImplInternal: Source error.


Setup:

// 1. Create a default TrackSelector
        BandwidthMeter bandwidthMeter = new DefaultBandwidthMeter();
        TrackSelection.Factory videoTrackSelectionFactory =
                new AdaptiveTrackSelection.Factory(bandwidthMeter);
        TrackSelector trackSelector =
                new DefaultTrackSelector(videoTrackSelectionFactory);

        // 2. Create the player
        SimpleExoPlayer player =
                ExoPlayerFactory.newSimpleInstance(this, trackSelector);

        // Bind the player to the view.
        PlayerView playerView = findViewById(R.id.player_view);
        playerView.setPlayer(player);

        // Produces DataSource instances through which media data is loaded.
        DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this,
                Util.getUserAgent(this, "yourApplicationName"), null);
        // This is the MediaSource representing the media to be played.
        MediaSource videoSource = new ExtractorMediaSource.Factory(dataSourceFactory)
                .createMediaSource(Uri.parse("http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4"));
        // Prepare the player with the source.
        player.prepare(videoSource);

layout:

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <com.google.android.exoplayer2.ui.PlayerView
        android:id="@+id/player_view"
        android:layout_width="200dp"
        android:layout_height="200dp" />
</android.support.constraint.ConstraintLayout>

complete log:

05-23 16:25:18.919 11893-11893/? D/AppTracker: App Event: start
05-23 16:25:18.931 11893-11943/? D/OpenGLRenderer: HWUI GL Pipeline
05-23 16:25:18.946 11893-11945/? I/DpmTcmClient: RegisterTcmMonitor from: com.android.okhttp.TcmIdleTimerMonitor
05-23 16:25:18.951 11893-11945/? D/NetworkSecurityConfig: No Network Security Config specified, using platform default
05-23 16:25:18.982 11893-11943/? I/Adreno: QUALCOMM build                   : 08cdca0, I5f270ba9bc
    Build Date                       : 09/18/17
    OpenGL ES Shader Compiler Version: EV031.20.00.04
    Local Branch                     : 
    Remote Branch                    : refs/tags/AU_LINUX_ANDROID_LA.UM.6.5.R1.08.00.00.312.025
    Remote Branch                    : NONE
    Reconstruct Branch               : NOTHING
05-23 16:25:18.982 11893-11943/? I/vndksupport: sphal namespace is not configured for this process. Loading /vendor/lib64/hw/gralloc.msm8996.so from the current namespace instead.
05-23 16:25:18.985 11893-11943/? I/Adreno: PFP: 0x005ff087, ME: 0x005ff063
05-23 16:25:18.990 11893-11943/? I/OpenGLRenderer: Initialized EGL, version 1.4
05-23 16:25:18.990 11893-11943/? D/OpenGLRenderer: Swap behavior 2
05-23 16:25:19.072 11893-11943/? I/vndksupport: sphal namespace is not configured for this process. Loading /vendor/lib64/hw/gralloc.msm8996.so from the current namespace instead.
05-23 16:25:21.057 11893-11920/com.app.videotest I/zygote64: Do partial code cache collection, code=28KB, data=28KB
05-23 16:25:21.059 11893-11920/com.app.videotest I/zygote64: After code cache collection, code=28KB, data=28KB
    Increasing code cache capacity to 128KB
05-23 16:25:22.002 11893-11942/com.app.videotest E/ExoPlayerImplInternal: Source error.

The url is definitely working (and I have tried several others). What am I missing?

Update:
the player does work when I load the video locally. Doesn't solve my problem though.

Phantômaxx
  • 37,901
  • 21
  • 84
  • 115
Barazu
  • 489
  • 6
  • 10
  • Try to paste a longer log from logcat, maybe there is something missing above – jantursky May 23 '18 at 13:38
  • this is the complete log, there's nothing above – Barazu May 23 '18 at 13:41
  • And do you have the connection to the internet? Or what if you could download the video file in the assets and load it locally? I'm trying to solve that, but I haven't your whole source code, so it couldn't be in some cases easy to reproduce the problem. – jantursky May 23 '18 at 13:43
  • I do have internet connection. I'll try to load a video locally and post an update.
    Essentially what I posted is all there is to it - I have just the one activity with the ExoPlayer setup code in it's `onCreate` method and nothing else.
    – Barazu May 23 '18 at 13:46
  • Ok, so try this `DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this, Util.getUserAgent(this, "yourApplicationName"));` and add constraints for PlayerView like `app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintRight_toRightOf="parent" app:layout_constraintLeft_toLeftOf="parent" app:layout_constraintTop_toTopOf="parent"` – jantursky May 23 '18 at 13:50
  • Same error. worth mentioning that the `PlayerView` is showing, so the xml is probably not what's causing the error. – Barazu May 23 '18 at 13:54
  • Works when loaded locally. – Barazu May 23 '18 at 14:25
  • This guide should help you [Guide](https://google.github.io/ExoPlayer/guide.html). – jantursky May 23 '18 at 14:30
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/171624/discussion-between-barazu-and-jantursky). – Barazu May 23 '18 at 14:41
  • Did you change your network? – raxerz Sep 24 '18 at 19:41

1 Answers1

0

Are you using Android 8? In my case, I have error

Caused by: java.io.IOException: Cleartext HTTP traffic to clips.vorwaerts-gmbh.de not permitted

Then, based on this thread, you need to modify your manifest (the simplest one) into these :

<?xml version="1.0" encoding="utf-8"?>
<manifest ...>
    <uses-permission android:name="android.permission.INTERNET" />
    <application
        ...
        android:usesCleartextTraffic="true"
        ...>
        ...
    </application>
</manifest>

See detail on link above

Aji Imawan
  • 11
  • 3