From 6ef75979dfe09cade1f2fb8b223e65aae7db44b8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaquim=20St=C3=A4hli?= Date: Tue, 21 Aug 2018 14:26:52 +0200 Subject: [PATCH 1/3] Add Test prepare with start position --- .../java/ch/srg/mediaplayer/PlaybackTest.java | 41 +++++++++++++++---- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/srgmediaplayer/src/androidTest/java/ch/srg/mediaplayer/PlaybackTest.java b/srgmediaplayer/src/androidTest/java/ch/srg/mediaplayer/PlaybackTest.java index be3045b..d99c787 100644 --- a/srgmediaplayer/src/androidTest/java/ch/srg/mediaplayer/PlaybackTest.java +++ b/srgmediaplayer/src/androidTest/java/ch/srg/mediaplayer/PlaybackTest.java @@ -13,8 +13,11 @@ import org.junit.Test; import org.junit.runner.RunWith; +import java.util.Arrays; +import java.util.List; import java.util.Random; +import ch.srg.mediaplayer.segment.model.Segment; import ch.srg.mediaplayer.utils.SRGMediaPlayerControllerQueueListener; /** @@ -226,7 +229,7 @@ public void testOnDemandAudioPlaythrough() throws Exception { } @Test - public void testPlayAtPosition() throws Exception { + public void testPlayAndSeekToPosition() throws Exception { controller.play(AUDIO_ON_DEMAND_URI, SRGMediaPlayerController.STREAM_HTTP_PROGRESSIVE); waitForState(SRGMediaPlayerController.State.READY); controller.seekTo((long) 30000); @@ -235,6 +238,30 @@ public void testPlayAtPosition() throws Exception { assertEquals(30, controller.getMediaPosition() / 1000); } + @Test + public void testPlayAtStartingPosition() throws Exception { + Long position = 3000L; + controller.play(AUDIO_ON_DEMAND_URI, position, SRGMediaPlayerController.STREAM_HTTP_PROGRESSIVE); + waitForState(SRGMediaPlayerController.State.READY); + assertTrue(controller.isPlaying()); + assertEquals(3, controller.getMediaPosition() / 1000); + } + + @Test + public void testPlayAtStartingPositionWitSegment() throws Exception { + Segment segment0 = new Segment("segmentId0", "Segment0", null, null, null, + 3000L, 10000L, 7000L, 0L, true, false, false); + Segment segment1 = new Segment("segmentId1", "Segment1", null, null, null, + 12000L, 15000L, 3000L, 0L, true, false, false); + List listSegment = Arrays.asList(segment0, segment1); + + controller.prepare(AUDIO_ON_DEMAND_URI, 0L, SRGMediaPlayerController.STREAM_HTTP_PROGRESSIVE, listSegment, segment1); + controller.start(); + waitForState(SRGMediaPlayerController.State.READY); + assertTrue(controller.isPlaying()); + assertEquals(12, controller.getMediaPosition() / 1000); + } + @Test public void testPlayAfterStreamEnd() throws Exception { controller.play(AUDIO_ON_DEMAND_URI, SRGMediaPlayerController.STREAM_HTTP_PROGRESSIVE); @@ -263,7 +290,7 @@ public void testSeek() throws Exception { controller.seekTo(60 * 1000); waitForState(SRGMediaPlayerController.State.BUFFERING); waitForState(SRGMediaPlayerController.State.READY); - assertEquals(60,controller.getMediaPosition() / 1000); + assertEquals(60, controller.getMediaPosition() / 1000); assertTrue(controller.isPlaying()); } @@ -307,7 +334,7 @@ public void testSeekWhilePreparing() throws Exception { controller.seekTo(60 * 1000); assertTrue(controller.isLoading() || controller.isPlaying()); waitForState(SRGMediaPlayerController.State.READY); - assertEquals(60,controller.getMediaPosition() / 1000); + assertEquals(60, controller.getMediaPosition() / 1000); while (!controller.isPlaying()) { Thread.sleep(100); } @@ -333,13 +360,13 @@ public void testSeekWhilePaused() throws Exception { controller.pause(); Thread.sleep(100); // Need to wait assertFalse(controller.isPlaying()); - assertEquals(0,controller.getMediaPosition() / 1000); + assertEquals(0, controller.getMediaPosition() / 1000); controller.seekTo(60 * 1000); // TODO: No BUFFERING? waitForState(SRGMediaPlayerController.State.READY); waitForEvent(SRGMediaPlayerController.Event.Type.DID_SEEK); - assertEquals(60,controller.getMediaPosition() / 1000); + assertEquals(60, controller.getMediaPosition() / 1000); assertFalse(controller.isPlaying()); } @@ -353,13 +380,13 @@ public void testPauseStartPositionKept() throws Exception { controller.pause(); Thread.sleep(100); // Need to wait assertFalse(controller.isPlaying()); - assertEquals(60,controller.getMediaPosition() / 1000); + assertEquals(60, controller.getMediaPosition() / 1000); controller.start(); waitForState(SRGMediaPlayerController.State.READY); waitForEvent(SRGMediaPlayerController.Event.Type.PLAYING_STATE_CHANGE); - assertEquals(60,controller.getMediaPosition() / 1000); + assertEquals(60, controller.getMediaPosition() / 1000); assertTrue(controller.isPlaying()); } From 88c2c692d7ad58f5c1e9179a1ef1c98c615d2bf0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Joaquim=20St=C3=A4hli?= Date: Tue, 21 Aug 2018 14:53:34 +0200 Subject: [PATCH 2/3] Add test with starting position to null --- .../java/ch/srg/mediaplayer/PlaybackTest.java | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/srgmediaplayer/src/androidTest/java/ch/srg/mediaplayer/PlaybackTest.java b/srgmediaplayer/src/androidTest/java/ch/srg/mediaplayer/PlaybackTest.java index d99c787..efa861b 100644 --- a/srgmediaplayer/src/androidTest/java/ch/srg/mediaplayer/PlaybackTest.java +++ b/srgmediaplayer/src/androidTest/java/ch/srg/mediaplayer/PlaybackTest.java @@ -247,6 +247,15 @@ public void testPlayAtStartingPosition() throws Exception { assertEquals(3, controller.getMediaPosition() / 1000); } + @Test + public void testPlayAtStartingPositionNull() throws Exception { + Long position = null; + controller.play(AUDIO_ON_DEMAND_URI, position, SRGMediaPlayerController.STREAM_HTTP_PROGRESSIVE); + waitForState(SRGMediaPlayerController.State.READY); + assertTrue(controller.isPlaying()); + assertEquals(0, controller.getMediaPosition() / 1000); + } + @Test public void testPlayAtStartingPositionWitSegment() throws Exception { Segment segment0 = new Segment("segmentId0", "Segment0", null, null, null, From 9914aa083be4dff26774e338d9ac8991c8e801fd Mon Sep 17 00:00:00 2001 From: Sebastien Chauvin Date: Tue, 11 Sep 2018 10:09:49 +0200 Subject: [PATCH 3/3] Tidying up --- .../main/java/ch/srg/mediaplayer/SRGMediaPlayerController.java | 1 - 1 file changed, 1 deletion(-) diff --git a/srgmediaplayer/src/main/java/ch/srg/mediaplayer/SRGMediaPlayerController.java b/srgmediaplayer/src/main/java/ch/srg/mediaplayer/SRGMediaPlayerController.java index c386213..80cf561 100644 --- a/srgmediaplayer/src/main/java/ch/srg/mediaplayer/SRGMediaPlayerController.java +++ b/srgmediaplayer/src/main/java/ch/srg/mediaplayer/SRGMediaPlayerController.java @@ -460,7 +460,6 @@ public interface Listener { @Nullable private AkamaiMediaAnalyticsConfiguration akamaiMediaAnalyticsConfiguration; - // FIXME : why userAgent letterbox is set here? private static final String userAgent = "curl/Letterbox_2.0"; // temporarily using curl/ user agent to force subtitles with Akamai beta @Nullable private DrmConfig drmConfig;