Skip to content

Commit

Permalink
Merge branch 'release/2.0.0-RC2'
Browse files Browse the repository at this point in the history
  • Loading branch information
stefanmedack committed Dec 26, 2017
2 parents 4cd51fa + 21ad433 commit 37cc848
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 22 deletions.
4 changes: 2 additions & 2 deletions app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ android {
applicationId "de.stefanmedack.ccctv"
minSdkVersion 21
targetSdkVersion 26
versionCode 4
versionName "2.0.0-RC1"
versionCode 5
versionName "2.0.0-RC2"
resConfigs "en", "de"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ class DetailActivity : BaseInjectableActivity() {
return (fragment?.onKeyDown(keyCode) == true) || super.onKeyDown(keyCode, event)
}

// TODO workaround for amazon - move to new implementation
override fun onVisibleBehindCanceled() {
mediaController?.transportControls?.pause()
super.onVisibleBehindCanceled()
}

companion object {
fun start(activity: Activity, event: Event, sharedImage: ImageView? = null) {
val intent = Intent(activity, DetailActivity::class.java)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class MainFragment : BrowseSupportFragment() {
when (mainUiModel.conferenceGroupResource) {
is Resource.Success -> {
adapter = ArrayObjectAdapter(ListRowPresenter())
(adapter as ArrayObjectAdapter).let {
(adapter as? ArrayObjectAdapter)?.let {
if(mainUiModel.offersResource is Resource.Success && mainUiModel.offersResource.data.isNotEmpty()) {
it += SectionRow(HeaderItem(1L, getString(R.string.main_streams_header)))
it += mainUiModel.offersResource.data.map { PageRow(HeaderItem(2L, it.conference)) }
Expand All @@ -97,7 +97,7 @@ class MainFragment : BrowseSupportFragment() {
}

private fun shouldScrollToHeadersOnKeyDown(keyCode: Int): Boolean {
return selectedPosition == adapter.size() - 1 // is last main menu item selected (AboutFragment)
return adapter != null && selectedPosition == adapter.size() - 1 // is last main menu item selected (AboutFragment)
&& !isShowingHeaders // is left side bar not shown?
&& (checkLeftKey(keyCode) || checkUpKey(keyCode))
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
package de.stefanmedack.ccctv.ui.playback

import android.content.Context
import android.content.Intent
import android.content.pm.PackageManager
import android.os.Bundle
import android.support.v4.app.FragmentActivity
import android.support.v4.os.BuildCompat
import de.stefanmedack.ccctv.R
import de.stefanmedack.ccctv.util.STREAM_URL
import info.metadude.java.library.brockman.models.Stream
Expand All @@ -18,10 +15,23 @@ class ExoPlayerActivity : FragmentActivity() {
setContentView(R.layout.activity_video_example)

val ft = supportFragmentManager.beginTransaction()
ft.add(R.id.videoFragment, ExoPlayerFragment(), ExoPlayerFragment.TAG)
ft.add(
R.id.videoFragment,
ExoPlayerFragment().apply {
arguments = Bundle(1).also {
it.putString(STREAM_URL, intent.getStringExtra(STREAM_URL))
}
},
ExoPlayerFragment.TAG)
ft.commit()
}

override fun onVisibleBehindCanceled() {
mediaController?.transportControls?.pause()
super.onVisibleBehindCanceled()
}

// TODO workaround for amazon - move to new implementation
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
// This part is necessary to ensure that getIntent returns the latest intent when
Expand All @@ -33,15 +43,10 @@ class ExoPlayerActivity : FragmentActivity() {
}

companion object {
fun supportsPictureInPicture(context: Context): Boolean {
return BuildCompat.isAtLeastN() && context.packageManager.hasSystemFeature(
PackageManager.FEATURE_PICTURE_IN_PICTURE)
}

fun start(activity: FragmentActivity, item: Stream) {
val intent = Intent(activity, ExoPlayerActivity::class.java)
val url = item.urls.find { it.type == TYPE.HLS }?.url ?: item.urls[0].url
// Timber.d(url)
// val url = "http://cdn.c3voc.de/hls/sX_native_hd.m3u8"
intent.putExtra(STREAM_URL, url)
activity.startActivity(intent)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@ import android.support.v17.leanback.media.SurfaceHolderGlueHost
import android.view.SurfaceHolder
import com.google.android.exoplayer2.*
import com.google.android.exoplayer2.C.StreamType
import com.google.android.exoplayer2.extractor.DefaultExtractorsFactory
import com.google.android.exoplayer2.source.ExtractorMediaSource
import com.google.android.exoplayer2.source.MediaSource
import com.google.android.exoplayer2.source.TrackGroupArray
import com.google.android.exoplayer2.source.hls.HlsMediaSource
import com.google.android.exoplayer2.trackselection.DefaultTrackSelector
import com.google.android.exoplayer2.trackselection.TrackSelectionArray
import com.google.android.exoplayer2.upstream.DefaultHttpDataSource
Expand Down Expand Up @@ -207,10 +206,17 @@ class ExoPlayerAdapter(context: Context) : PlayerAdapter(), Player.EventListener
*/
fun onCreateMediaSource(uri: Uri): MediaSource {
val userAgent = Util.getUserAgent(context, "ExoPlayerAdapter")
return ExtractorMediaSource(uri,
DefaultHttpDataSourceFactory(userAgent, null, DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS,
DefaultHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS, true),
DefaultExtractorsFactory(), null, null)

return HlsMediaSource(
uri,
DefaultHttpDataSourceFactory(
userAgent,
null,
DefaultHttpDataSource.DEFAULT_CONNECT_TIMEOUT_MILLIS,
DefaultHttpDataSource.DEFAULT_READ_TIMEOUT_MILLIS,
true),
null,
null)
}

private fun prepareMediaForPlaying() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,12 @@ class ExoPlayerFragment : VideoSupportFragment() {
Log.w(TAG, "video player cannot obtain audio focus!")
}

val streamUrl = activity.intent.getStringExtra(STREAM_URL)
playVideo(streamUrl)
val streamUrl = arguments.getString(STREAM_URL)
if (streamUrl != null) {
playVideo(streamUrl)
} else {
activity?.finish()
}
}

override fun onPause() {
Expand Down

0 comments on commit 37cc848

Please sign in to comment.