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

Providing a Minimal Example #383

Closed
Schizo opened this issue Apr 5, 2015 · 5 comments
Closed

Providing a Minimal Example #383

Schizo opened this issue Apr 5, 2015 · 5 comments

Comments

@Schizo
Copy link

Schizo commented Apr 5, 2015

Having the huge Examples is quite good to get a good feeling of exoplayer's wide range of possibilities. However, it would be very helpful to have a minimal working example, which shows what is needed to play a video from file or link.

Uri uri = Uri.parse("http://html5demos.com/assets/dizzy.mp4");
        final int numRenderers = 2;


        // Build the sample source
        DefaultSampleSource sampleSource =
                new DefaultSampleSource(new FrameworkSampleExtractor(this, uri, null), 2);

        // Build the track renderers
        TrackRenderer videoRenderer = new MediaCodecVideoTrackRenderer(sampleSource, MediaCodec.VIDEO_SCALING_MODE_SCALE_TO_FIT);
        TrackRenderer audioRenderer = new MediaCodecAudioTrackRenderer(sampleSource);

        // Build the ExoPlayer and start playback
        ExoPlayer exoPlayer = ExoPlayer.Factory.newInstance(numRenderers);
        exoPlayer.prepare(videoRenderer, audioRenderer);

        // Pass the surface to the video renderer.
        exoPlayer.sendMessage(videoRenderer, MediaCodecVideoTrackRenderer.MSG_SET_SURFACE, surfaceView);

        exoPlayer.setPlayWhenReady(true);

The above code yields:
04-06 01:47:18.920 Unsupported mime video/mpeg2
04-06 01:47:18.921 Unsupported mime audio/mpeg-L2
04-06 01:47:18.923 Unrecognized level 0 for video/x-vnd.on2.vp8

@ojw28
Copy link
Contributor

ojw28 commented Apr 13, 2015

We'll probably be doing this by moving the "player" package from the demo app to inside the library, as a higher level abstraction that covers playback for most of the common use cases. You'll still be able to use the lower level ExoPlayer interface directly for more advanced use cases.

Does that sound good/sensible to you?

@Schizo
Copy link
Author

Schizo commented Apr 22, 2015

What kind of abstraction will this provide? I am not sure if this is necessary, if there is a good documentation and examples (like ffmpeg provides) it should be easy for everyone.

When using maven repo the demo is not included, does it have a reason?

@ojw28
Copy link
Contributor

ojw28 commented Aug 13, 2015

The new plan will likely be:

  • Complete work on Ability to switch audio track during playback #514. This will remove several hundred lines from the demo app by moving multi-track logic inside of the core player library.
  • Possibly move the renderer builders inside the library.
  • Possibly move the async renderer build step inside the core ExoPlayer.

Details to be determined.

@ojw28
Copy link
Contributor

ojw28 commented Sep 1, 2015

The first bullet point above has been completed, and ~10% of the demo app code has been removed as a result. The second and third points are still open for investigation.

ojw28 added a commit that referenced this issue Jun 15, 2016
DemoPlayer moves into core library as SimpleExoPlayer, which
implements ExoPlayer.

Issue: #383
Issue: #592
-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=123090184
@ojw28
Copy link
Contributor

ojw28 commented Aug 31, 2016

The demo app has been significantly reduced in size in ExoPlayer V2. For V1 we had:

$ find v1/demo/src/main/java/ -name '*.java' | xargs wc -l
   207 v1/demo/src/main/java/com/google/android/exoplayer/demo/SampleChooserActivity.java
   268 v1/demo/src/main/java/com/google/android/exoplayer/demo/Samples.java
    65 v1/demo/src/main/java/com/google/android/exoplayer/demo/SmoothStreamingTestMediaDrmCallback.java
   213 v1/demo/src/main/java/com/google/android/exoplayer/demo/EventLogger.java
   199 v1/demo/src/main/java/com/google/android/exoplayer/demo/player/HlsRendererBuilder.java
   204 v1/demo/src/main/java/com/google/android/exoplayer/demo/player/SmoothStreamingRendererBuilder.java
   600 v1/demo/src/main/java/com/google/android/exoplayer/demo/player/DemoPlayer.java
    88 v1/demo/src/main/java/com/google/android/exoplayer/demo/player/ExtractorRendererBuilder.java
   266 v1/demo/src/main/java/com/google/android/exoplayer/demo/player/DashRendererBuilder.java
   762 v1/demo/src/main/java/com/google/android/exoplayer/demo/PlayerActivity.java
    62 v1/demo/src/main/java/com/google/android/exoplayer/demo/WidevineTestMediaDrmCallback.java
  2934 total

in V2 we have:

$ find v2/demo/src/main/java/ -name '*.java' | xargs wc -l
  419 v2/demo/src/main/java/com/google/android/exoplayer2/demo/SampleChooserActivity.java
  336 v2/demo/src/main/java/com/google/android/exoplayer2/demo/TrackSelectionHelper.java
  439 v2/demo/src/main/java/com/google/android/exoplayer2/demo/EventLogger.java
   24 v2/demo/src/main/java/com/google/android/exoplayer2/demo/DemoApplication.java
  574 v2/demo/src/main/java/com/google/android/exoplayer2/demo/PlayerActivity.java
 1792 total

If you ignore the files that are essentially just scaffolding (i.e. not interesting), the lines of code goes from 2246 to 910.

@ojw28 ojw28 closed this as completed Aug 31, 2016
@google google locked and limited conversation to collaborators Jun 28, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants