2016/9/28 ã« ExoPlayer r2.0.0 ããªãªã¼ã¹ããã¾ããã
ã¾ãã ExoPlayer 㯠medium ã«éçºããã°ãæ¸ãããã«ãªã£ãããã§ãã r2.0.0 ããªãªã¼ã¹ãããã®ã¯çµæ§åã ãã©ãæªã ã«è¿½ãã¦ããªãã£ãã®ã§ medium ã®è¨äºãåèã«ãã¤ã¤èª¿ã¹ãå 容ãã¡ã¢ã£ã¦ããã¾ãã
ã¡ãªã¿ã« ExoPlayer 1.x ã®è©±ã¯éå»ã«æ¸ãããã®ãããã®ã§ãèå³ãããæ¹ã¯ãã¡ããåç §ããã¨è¯ãã§ãããã
Q: ãªãã¡ã¸ã£ã¼ãã¼ã¸ã§ã³ã¢ããããã®?
A: å¾æ¹äºææ§ãç ´å£ãããã£ããã
- ExoPlayer 2.x - Why, what and when?
- å ã ExoPlayer 㯠YouTube ã GooglePlay ã ã¼ãã¼ã®ããã«ä½ã£ã¦ãã
- MPEG-DASH åçã«ç¹åãã¦ãããã©ããªã¼ãã³ã½ã¼ã¹å以å¾ã©ãã©ãé²åãã¦æ§ã ãªãã©ã¼ããããå©ç¨ã§ããããã«ãªã£ã
- åºæ¥ãã ã API ãå®å®ããããããã®ä¸æ¹ã§æ°ãããã©ã¼ããããæ±ãããã®å¹çã¯æªããªã£ã¦ãã
- ããã解æ¶ããããã«ã¯ API äºææ§ãç ´å£ãã¦ã§ããä½ãç´ãå¿ è¦ããã£ã
ExoPlayer 2.x ã§å¤ãã£ãã¯ã©ã¹
ExoPlayer 2.x - New package and class names
åè¨è¨ããã«ããã£ã¦ãè¤éãªã¯ã©ã¹ãå解ãããããªãã¼ã ãããã®ãã¾ã¨ãããã¦ããã
- 1.x 㨠2.x ã§ããã±ã¼ã¸åå¤ãã
com.google.android.exoplayer2
ã¨ããããã±ã¼ã¸åã«ãªã£ã- äºã¤ã®ãã¬ã¤ã¤ã¼ãå ¥ãã¦å¾ã ã«ç§»è¡ãã¦ãããã¨ãã§ãã
- æ§ TrackRenderer 㯠Interface ã«ã㦠Renderer ã¨ããååã§å®ç¾©ããªããã
- TrackRenderer ç¸å½ã®ãã®ã¯ BaseRenderer (implements Renderer) ã«ãã
- æ§ SampleSource ã¯è¤éã ã£ãã®ã§ MediaSource, MediaPeriod, SampleStream ã¨ãã 3 ã¤ã«ãªã£ã
- util.extensions 㯠decoder ã«ãªã£ã
- MediaCodecRenderer 㯠mediacodec é
ä¸ã«ãªã£ã
- MediaCodecAudioRenderer 㯠audio é ä¸ã«ãªã£ã
- MediaCodecVideoRenderer 㯠video é ä¸ã«ãªã£ã
- FrameworkSampleSource ã¯å»æ¢ããã
- MediaFormat 㯠Format ã«ãªã£ã
MediaSource Composition
ExoPlayer 2.x - MediaSource composition
- ExoPlayer 2 ã§ã¯ SampleSource ã®ä»£ããã« MediaSource ãä½ãå¿
è¦ããã
- ExtractorMediaSrouce ã¨ã HlsMediaSource ã®ããã«åä¸ã®ã¡ãã£ã¢ãã¡ã¤ã«ãåçããã¯ã©ã¹
- MergingMediaSource, LoopingMediaSource, ConcatenatingMediaSource ã¨ããã®ãåºæ¥ã
MergingMediaSource
å¥ã ã® MediaSource ãåæãã¦åçããã以ä¸ã®å ´åã ã¨ãåç»ã«å¥ãã¡ã¤ã«ã®åå¹ãã¼ã¿ããã¼ã¸ãã¦ããã
MediaSource videoSource = new ExtractorMediaSource(videoUri, ...); MediaSource subtitleSource = new SingleSampleMediaSource(subtitleUri, ...); // Plays the video with the sideloaded subtitle. MergingMediaSource mergedSource = new MergingMediaSource(videoSource, subtitleSource);
LoopingMediaSource
- ã·ã¼ã ã¬ã¹ãªã«ã¼ãåçãã§ãã
- åç»ãã«ã¼ãåçããã¨ãã«
onFinished()
âseekTo(0)
âplay()
ã¿ããã«ããªãã¦ãããªã£ã- ãã®æ¹æ³ã 㨠position = 0 ã®ä½ç½®ãå度ãããã¡ãªã³ã°ããå ´åããã
- LoopingMediaSource ã使ãã°ãåç»ã®çµãã preload ãè¡ãªããã¦ã·ã¼ã ã¬ã¹ã«åçãããã¨ãåºæ¥ã
ConcatenatingMediaSource
- è¤æ°ã®åç»ãç¹ãã¦ã·ã¼ã ã¬ã¹ã«åçãããã¨ãã§ãã
- ãã¬ã¤ãªã¹ãã¿ãããªæãã«ãªã
- ç°ãªããã©ã¼ãããã§ã concat ã§ãã
- e.g.) 480p ã® H.264 ã®å¾ã« 720p ã® VP9 ãåçããã¨ã
- ConcatenatingMediaSource ããåç»ã LoopingMediaSource ã«è¨å®ããã¨ããåºæ¥ã
New audio features
ExoPlayer 2.x - New audio features
- åç»ã ãã§ç¡ãé³å£°ãè¯ãæãã«ãªã£ã
- é³æ¥½ãã¬ã¤ã¤ã¼ãä½ãã¨ãã«ã使ãã
- ç°¡åã«ã®ã£ããã¬ã¹åçãã§ããããã«ãªã£ã
- mp3 ã aac ãã¡ã¤ã«ã®ã¡ã¿ãã¼ã¿ãè¦ã¦ã次ã®æ²ãäºããããã¡ãªã³ã°ãã¦ã·ã¼ã ã¬ã¹ã«åçããæ©è½
- MediaCodec 以å¤ã®ãã³ã¼ãã NativeLibrary çµç±ã§å©ç¨ãã¦é³å£°ãåçã§ããããã«ãªã£ã
- FFmpeg
- libopus
- libflac
Track Selection
ExoPlayer 2.x - Track selection
- Track selector ãå®è£ ã§ããããã«ãªã£ã
- æ ç»ã®ãããªè¤æ°ã®é³å£°ãã©ãã¯ãåå¹ãã©ãã¯ãå ¥ã£ã¦ããã¡ãã£ã¢ãåãæ¿ããã§ãã
- HLS ã®ãã㪠AdaptiveStreaming ã® Track selection ãåºæ¥ã
- ã¢ããªã®è¦ä»¶ (ã¢ãã¤ã«åç·ã§ã¯ä½ç»è³ªã«ãã¦ããããã¨ã) ã§åå¥ã« m3u8 ãã¡ã¤ã«ãä½ããªãã¦ãæè»ã«åãæ¿ãããã¨ãã§ãã
-
- ExoPlayer2 ã® DemoApp ã§ã¯ HLS ã® Track selection ã試ããã¨ãã§ãã
- Track selector ãå®è£
ã§ããããã«ãªã£ãã®ã§è¤é㪠select ãã¸ãã¯ãå®ç¾ã§ããããã«ãªã£ã
- 端æ«ã®è¨å®è¨èªãããªãæ åãã¡ã¤ã«ã®å ´åã¯åå¹ãåºãã¨ã
SimpleExoPlayer/SimpleExoPlayerView
- ç°¡åã«ã¤ããããã®ä¾¿å©ã¯ã©ã¹ãã§ãã
- ExoPlayer 1.x ã¯ãã¬ã¤ã¤ã¼ã®ä¸æºåãå¤ãã DemoPlayer ã¨ããã¯ã©ã¹ãåèã«ãã¦å©ç¨ãã¦ãã
- ã¡ãªã¿ã« VideoView ã»ã©ã³ã¼ãã¯çãããªããªããã©ãæåãã View ã®ãªãµã¤ãºããã³ã³ããã¼ã©ãã¤ãã¦ãã
// TrackSelector, LoadControl ãæå®ã㦠SimpleExoPlayer ãä½ã Handler mainHandler = new Handler(); DefaultBandwidthMeter bandwidthMeter = new DefaultBandwidthMeter(); TrackSelection.Factory videoTrackSelectionFactory = new AdaptiveVideoTrackSelection.Factory(bandwidthMeter); TrackSelector trackSelector = new DefaultTrackSelector(mainHandler, videoTrackSelectionFactory); LoadControl loadControl = new DefaultLoadControl(); SimpleExoPlayer player = ExoPlayerFactory.newSimpleInstance(this, trackSelector, loadControl); // HLS ã® URL ãæå®ã㦠MediaSource ãä½ã DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(this, Util.getUserAgent(this, "TestApp/0.1"), bandwidthMeter); MediaSource videoSource = new HlsMediaSource( Uri.parse(url), dataSourceFactory, 5, null, null); // åçãã player.prepare(videoSource); player.setPlayWhenReady(true);
<com.google.android.exoplayer2.ui.SimpleExoPlayerView android:id="@+id/video" android:layout_width="match_parent" android:layout_height="match_parent" app:use_texture_view="true" />
ææ
- ExoPlayer 2 ã®å¤§ããªé¨åã¨ãã¦ãã¬ã¤ãªã¹ããæ±ããããã«ãªã£ãã¨è¨ãã®å¤§ããããªã¨æã£ã
- ãã®ãé°ã§ LoopingMediaSource, ConcatenatingMediaSource, audio ã®ã®ã£ããã¬ã¹åçã®ãããªãã·ã¼ã ã¬ã¹ã«æ¬¡ã®ã¡ãã£ã¢ãã¡ã¤ã«ãåçããã¨ããæ©è½ãå®ç¾ããã¦ããããã«æãã
- å®è£ ã¯ã¾ã 追ãæãããã¦ããªãã®ã§æ¬å½ã«ãããªã®ãã¯ä¸æ
- ãã®ãé°ã§ LoopingMediaSource, ConcatenatingMediaSource, audio ã®ã®ã£ããã¬ã¹åçã®ãããªãã·ã¼ã ã¬ã¹ã«æ¬¡ã®ã¡ãã£ã¢ãã¡ã¤ã«ãåçããã¨ããæ©è½ãå®ç¾ããã¦ããããã«æãã
- ã㨠Track selector ãå®è£
ã§ããããã«ãªã£ãã®ã¯åã
- ç»è³ªãã¨ã« m3u8 ãã¡ã¤ã«ãç¨æããå¿ è¦ã¯ãªããªã£ã¦ä¾¿å©