Skip to content

audio/subtitles #187

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

Open
yaroslavlvov opened this issue Nov 21, 2020 · 5 comments
Open

audio/subtitles #187

yaroslavlvov opened this issue Nov 21, 2020 · 5 comments
Labels
enhancement New feature or request

Comments

@yaroslavlvov
Copy link

yaroslavlvov commented Nov 21, 2020

I want to simplify audiotracks/subtitles selection

image

  • Want to provide something like this

Subtitles
var currentSelectedSubtitle: ModernSubtitle { get }
getAvailableSubtitles() -> [ModernSubtitle]
selectSubtitle(ModernSubtitle)

AudioTacks
var currentSelectedAudioTrack: ModernAudioTrack { get }
getAvailableAudioTracks() -> [ModernAudioTrack]
selectAudioTrack(ModernAudioTrack)

Where is the best place to implement this according to the current implementation
Guessing as part of PlayerMediaItem Protocol and cast it when getting currentMedia from ModerAVPlayer instance

@raphrel
Copy link
Member

raphrel commented Nov 21, 2020

As I think you did, I read apple article:
https://developer.apple.com/documentation/avfoundation/media_playback_and_selection/selecting_subtitles_and_alternative_audio_tracks

I think we could work with ModernAVPlayer Plugin System (PlayerPlugin):

  • Media is loaded, plugin system call: func didLoad(media: PlayerMedia, duration: Double?)
  • I can add a AVPlayerItem (from custom protocol) param to this method
  • Then in the plugin, you can download group and options
  • Then use the AVPlayerItem to select group and options previously download

In this case, I just have to provide in didLoad player plugin method the AVPlayerItem previously loaded.

For information, add PlayerPlugin is done on ModernAVPlayer init

what do you think ?

@raphrel raphrel added the enhancement New feature or request label Nov 21, 2020
@yaroslavlvov
Copy link
Author

As I understand I can cast PlayerMedia to PlayerMediaItem in this method, right? Not quite get why there are two separate, however, plugin system will work for me, I was just thinking that this feature could be useful for others potentially and worth implementing internally

@raphrel
Copy link
Member

raphrel commented Nov 22, 2020

ok, I just created a new branch -> you can now use it to access AVPlayerItem and AVAsset when item is loaded and call all methods suggested by Apple

I suggest you create a new GitHub open source repository to create a swift package for the plugin. (can be access by anybody, to use or update it)

  • Create a new Swift Package Project
  • Create your plugin code
  • Use ModernAVPlayer repo or another one to create iOS example to test it
    ** Inject your plugin in ModernAVPlayer init
    ** Access to AVPlayerItem from didLoaded delegate method
    ** Start async task to download group and options
    ** Choose options you need (you will have iOS example in the project)
    ** Apply from AVPlayerItem select method

If you have any question, please ask !

PS: do not pay attention to unit tests, I had to adjust them...

@raphrel
Copy link
Member

raphrel commented Nov 29, 2020

HI @yaroslavlvov ,

can you share a url of a media with subtitle or alternative audio tracks ?

I may try to help if I have some time

@yaroslavlvov
Copy link
Author

@raphrel the one that you used for demo should have both

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Development

No branches or pull requests

2 participants