Skip to content

Instantly share code, notes, and snippets.

@Frankdroid7
Last active April 4, 2019 20:30
Show Gist options
  • Save Frankdroid7/eb0fa65a0ada714a70b1a4b00adbc5be to your computer and use it in GitHub Desktop.
Save Frankdroid7/eb0fa65a0ada714a70b1a4b00adbc5be to your computer and use it in GitHub Desktop.
class MainFragment : Fragment() {
private lateinit var exoPlayer: SimpleExoPlayer
private lateinit var playerView: PlayerView
private lateinit var videoSource: MediaSource
private lateinit var videoSource2: MediaSource
private lateinit var dataSourceFactory: DataSource.Factory
private lateinit var concatenate: ConcatenatingMediaSource
private val videoURL =
"https://vodcmssec-a.akamaihd.net/omnisport/ready/HD/transferscript/287/240219-EN-PERFORM-KLOPP-SALAH-RV-2_1551036339725_287.mp4"
private val videoURL2 =
"https://vodcmssec-a.akamaihd.net/omnisport/ready/HD/ptv_omni_ready/287/020319-EN-PERFORM-ROONEY-SURPRISESFAN-VL-2_1551533220348_287.mp4"
override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {
val view = inflater.inflate(R.layout.activity_main2, container!!, false)
exoPlayer = ExoPlayerFactory.newSimpleInstance(context)
playerView = view.findViewById(R.id.playerView)
playerView.player = exoPlayer
dataSourceFactory = DefaultDataSourceFactory(context, Util.getUserAgent(context, getString(R.string.app_name)))
videoSource = ExtractorMediaSource.Factory(dataSourceFactory).createMediaSource(Uri.parse(videoURL))
videoSource2 = ExtractorMediaSource.Factory(dataSourceFactory).createMediaSource(Uri.parse(videoURL2))
concatenate = ConcatenatingMediaSource(videoSource,videoSource2)
exoPlayer.prepare(concatenate)
return view
}
override fun onDestroy() {
super.onDestroy()
exoPlayer.release()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment