This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* turf docs: | |
* - https://turfjs.org/docs/#nearestPoint | |
* - https://turfjs.org/docs/#feature | |
* | |
* mapbox sample w/ turf: | |
* - https://docs.mapbox.com/help/tutorials/analysis-with-turf/ | |
*/ | |
import { MapboxGeoJSONFeature } from "mapbox-gl" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun onPictureInPictureModeChanged( | |
isInPIPMode: Boolean, newConfig: Configuration?) { | |
exoplayerview_activity_video.useController = !isInPictureInPictureMode | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun onUserLeaveHint() { | |
enterPictureInPictureMode( | |
with(PictureInPictureParams.Builder()) { | |
val width = 16 | |
val height = 9 | |
setAspectRatio(Rational(width, height)) | |
build() | |
}) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<application> | |
<activity | |
android:name="com.example.android.videoplayersample.VideoActivity" | |
android:supportsPictureInPicture="true" | |
...> | |
</activity> | |
... | |
</application> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class AudioFocusWrapper(private val audioAttributes: AudioAttributesCompat, | |
private val audioManager: AudioManager, | |
private val player: SimpleExoPlayer) : ExoPlayer by player, AnkoLogger { | |
private var shouldPlayWhenReady = false | |
private val audioFocusListener = | |
AudioManager.OnAudioFocusChangeListener { focusChange -> | |
when (focusChange) { | |
AudioManager.AUDIOFOCUS_GAIN -> { | |
if (shouldPlayWhenReady || player.playWhenReady) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
val audioManager = context.getSystemService(Context.AUDIO_SERVICE) as AudioManager | |
val audioAttributes = AudioAttributesCompat.Builder() | |
.setContentType(AudioAttributesCompat.CONTENT_TYPE_MUSIC) | |
.setUsage(AudioAttributesCompat.USAGE_MEDIA) | |
.build() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
player = ExoPlayerFactory.newSimpleInstance(context, DefaultTrackSelector()) | |
.apply { | |
... | |
} | |
fun buildMediaSource(): MediaSource { | |
val uriList = mutableListOf<MediaSource>() | |
MediaCatalog.list.forEach { | |
uriList.add(createExtractorMediaSource(it.mediaUri!!)) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun onCreate(savedInstanceState: Bundle?) { | |
... | |
mediaSession = MediaSessionCompat(this, packageName) | |
connector = MediaSessionConnector(mediaSession) | |
// If QueueNavigator isn't set, then mediaSessionConnector won’t handle | |
// MediaSession actions (they won't show up in the minimized PIP activity): | |
// [ACTION_SKIP_PREVIOUS], [ACTION_SKIP_NEXT], [ACTION_SKIP_TO_QUEUE_ITEM] | |
connector.setQueueNavigator(object : TimelineQueueNavigator(mMediaSession) { | |
override fun getMediaDescription(idx: Int): MediaDescriptionCompat { | |
return MediaCatalog.list.get(idx) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
override fun onCreate(savedInstanceState: Bundle?) { | |
... | |
playerHolder = PlayerHolder(this, exoplayerview_activity_video, state) | |
mediaSession = MediaSessionCompat(this, packageName) | |
connector = MediaSessionConnector(mediaSession) | |
} | |
override fun onStart() { | |
... | |
playerHolder.start() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<LinearLayout | |
... | |
xmlns:app="http://schemas.android.com/apk/res-auto" | |
android:layout_gravity="center" | |
android:background="@#CC000000" | |
android:orientation="vertical"> | |
<LinearLayout | |
android:layout_width="match_parent" | |
android:layout_height="wrap_content" |