Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

first parameter of Clippingmediasource can only accept Mediasource type and not Concatenatingmediasource type? #8289

Closed
PeOS-China opened this issue Nov 27, 2020 · 6 comments
Assignees

Comments

@PeOS-China
Copy link

PeOS-China commented Nov 27, 2020

I use clipping media source (mediasource, 0, 3_ 000_ 000) create a clippingmediasource object. Mediasource is of mediasource type. Exoplayer can play normally, but use clippingmediasource (concatenatingmediasource, 0,3)_ 000_ 000), concatenatingmediasource is of concatenatingmediasource type, exoplayer cannot play. Whether the first parameter of clippingmediasource can only accept Mediasource type and not Concatenatingmediasource type
The code is as follows:
`
val application: BarbellApplication = requireActivity().application as BarbellApplication

    val dataSourceFactory = CacheDataSourceFactory(application.getDownloadCache(), upstreamSourceFactory)
    val playlist = ConcatenatingMediaSource(true)
    var m : MediaSource? = null
    
    lesson.Exercises.forEach {
        if(it.PlaybackURLs.isNotEmpty()) {
            it.PlaybackURLs.forEach { url ->
                if(url.isNotEmpty()) {
                    val uri = Uri.parse(url)
                    val mediaSource = ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(uri)
                    playlist.addMediaSource(mediaSource)
                    if(null == m) {
                        m = mediaSource
                    }
                }
            }
        }
    }

    mediaSource = playlist

  val clippingMediaSource1 = ClippingMediaSource(playlist, 0, 3_000_000)
    val clippingMediaSource2 = ClippingMediaSource(m, 0, 3_000_000)
    
    player.addListener(getPlayerListener())
    player.repeatMode = Player.REPEAT_MODE_ONE
    player.prepare(clippingMediaSource1)
    player.playWhenReady = true

`

@PeOS-China PeOS-China changed the title Is ClippingMediaSource Only parameters can be passed in MediaSource, not ConcatenatingMediaSource? first parameter of Clippingmediasource can only accept Mediasource type and not Concatenatingmediasource type? Nov 27, 2020
@AquilesCanta
Copy link
Contributor

first parameter of Clippingmediasource cannot accept Concatenatingmediasource

This is correct. You can only pass a "leaf" media source (DashMS, HlsMS, ProgressiveMs, etc).

Can you explain what the expected behavior of ClippingMediaSource(ConcatenatingMediaSource, ...) is? Perhaps we can find an alternative way of achieving the same?

@PeOS-China
Copy link
Author

first parameter of Clippingmediasource cannot accept Concatenatingmediasource

This is correct. You can only pass a "leaf" media source (DashMS, HlsMS, ProgressiveMs, etc).

Can you explain what the expected behavior of ClippingMediaSource(ConcatenatingMediaSource, ...) is? Perhaps we can find an alternative way of achieving the same?

I need to link multiple videos into a video that can be played seamlessly. This video is a two-dimensional array composed of concatenatingmediasource. Multiple videos in the first dimension are played circularly and called player.next The second dimension video will be played when () player.next (), there will be a one second stuck delay. These videos are all local videos. The code is as follows:
`
val upstreamSourceFactory = DefaultDataSourceFactory(activity, Util.getUserAgent(requireActivity(), "dongmi-device"))
val application: BarbellApplication = requireActivity().application as BarbellApplication
val dataSourceFactory = CacheDataSourceFactory(application.getDownloadCache(), upstreamSourceFactory)

    val playlist = ConcatenatingMediaSource()
    lesson.Exercises.forEach {
        val exerciseVideoList = ConcatenatingMediaSource(true)
        if(it.PlaybackURLs.isNotEmpty()) {
            it.PlaybackURLs.forEach { url ->
                if(url.isNotEmpty()) {
                    val uri = Uri.parse(url)
                    val mediaSource = ProgressiveMediaSource.Factory(dataSourceFactory).createMediaSource(uri)
                    exerciseVideoList.addMediaSource(mediaSource)
                }
            }

            if(exerciseVideoList.size > 0) {
                playlist.addMediaSource(exerciseVideoList)
            }
        }
    }
   player.repeatMode = Player.REPEAT_MODE_ONE
   player.prepare(playlist)

`

@AquilesCanta
Copy link
Contributor

AquilesCanta commented Nov 30, 2020

@tonihei, mind looking at this? I'm under the impression that it looks similar to [Internal ref: b/174093168]?

@AquilesCanta AquilesCanta assigned tonihei and unassigned AquilesCanta Nov 30, 2020
@tonihei
Copy link
Collaborator

tonihei commented Nov 30, 2020

@PeOS-China Am I right in assuming that you want to merge all video of one lesson together as if they were one single video?

  • They will be played together seamlessly.
  • The total duration as shown in our default time bar UI will show the total duration all videos in one lesson.
  • When calling player.next() the player will start playing the next lesson.
  • Setting REPEAT_MODE_ONE will loop the entire lesson.

If these are your requirements, then this is duplicate of #4868. Please follow this issue for updates.

If you have different requirements to the above, please clarify again. In particular, your second post above no longer mentions ClippingMediaSource and I'm not sure where the clipping requirement comes into play :)

@PeOS-China
Copy link
Author

PeOS-China commented Dec 1, 2020

@PeOS-China Am I right in assuming that you want to merge all video of one lesson together as if they were one single video?

  • They will be played together seamlessly.
  • The total duration as shown in our default time bar UI will show the total duration all videos in one lesson.
  • When calling player.next() the player will start playing the next lesson.
  • Setting REPEAT_MODE_ONE will loop the entire lesson.

If these are your requirements, then this is duplicate of #4868. Please follow this issue for updates.

If you have different requirements to the above, please clarify again. In particular, your second post above no longer mentions ClippingMediaSource and I'm not sure where the clipping requirement comes into play :)

When calling player.next (), there will be one second stuck.The data structure I set for the player is as follows:
image

@tonihei
Copy link
Collaborator

tonihei commented Dec 1, 2020

When calling player.next (), there will be one second stuck.

This is probably related to the fact that the player needs to load and decode the next media first. There is also #3327 that tracks improving this use case.

So in summary, I think you mentioned multiple work in progress enhancements that are tracked elsewhere:

  1. Support clipping of multi-period content (for example a ConcatenatingMediaSource): Support clipping of multi-period content #6234
  2. Support merging multiple items to one playlist item in all regards: Extend isAtomic flag in ConcatanatingMediaSource to actually merge timelines #4868
  3. Preload next playlist item so that calling player.next() is almost instant: Support pre-buffering of next concatenated item. #3327

Unless there is something else I'm missing, I'm closing the issue as duplicate now because these separate issues are tracked elsewhere. If there is something else I'm missing, please let me know :)

@tonihei tonihei closed this as completed Dec 1, 2020
@google google locked and limited conversation to collaborators Jan 31, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants