wang-bin / fvp

Flutter video player plugin for all desktop+mobile platforms. download prebuilt examples from github actions. https://pub.dev/packages/fvp
BSD 3-Clause "New" or "Revised" License
126 stars 20 forks source link

A small unimportant wish #70

Closed DovgopolsSerj closed 4 months ago

DovgopolsSerj commented 4 months ago

The first is a wonderful package. I don't use it as a video player, but as a SHOUTcast player. It would be great to add the ability to get ICY metadata. FFMpeg provides such an opportunity through the parameters icy, icy_metadata_headers, icy_metadata_packet. Now we have to add a separate isolate that periodically makes a request and extracts this data.

wang-bin commented 4 months ago

What about adding a line after https://github.com/wang-bin/fvp/blob/v0.14.0/lib/src/video_player_mdk.dart#L213

player.setProperty('avio.icy_metadata_headers', ...);

I don't know what the value of icy_metadata_headers should be. If it works, you can create a pull request

DovgopolsSerj commented 4 months ago

This is not a protocol. This is the format of icecast streams. Example: When accessing this address, you need to specify the header Icy-MetaData: 1 Then the response will contain the header: icy-metaint This is the length of the audio data followed by one byte containing the length of the metadata. If it is not equal to zero, the following length * 16 is read. This is a string that usually contains the artist-title representation. Then the audio data is read again, etc. Inside your package, this is taken into account somewhere. Otherwise, there would be stuttering on such streams in the places where the metadata goes. icy_metadata_headers - these are the response headers that contain the name of the station, the address of the playlist, etc.

DovgopolsSerj commented 4 months ago

Sorry, example of stream: https://radiorecord.hostingradio.ru/ibiza96.aacp

wang-bin commented 4 months ago

I know how to get icy metadata, and will add new MediaEvent and update MediaInfo. But if with video_player api, there is no way to notify user about metadata update.

wang-bin commented 4 months ago

the latest build add a new MediaEvent for icy metadata, you can download and replace manually, or run flutter clean to cleanup cached dependencies. video_player can't access the metadata, you have to use backend api in mdk.dart:

  player.onEvent((ev) {
      _log.fine(
          '$hashCode player$nativeHandle onEvent: ${ev.category} - ${ev.detail} - ${ev.error}');
      if (ev.category == 'metadata') {
        mediaInfo.metadata.forEach((key, value) {
          _log.fine('metadata: $key: $value');
        });
      }
    });

and the log will be

flutter: fvp.FINE: 13:40:41.100: 372425887 player5469513328 onEvent: metadata - icy - 0
flutter: fvp.FINE: 13:40:41.110: metadata: icy-name: ibiza
flutter: fvp.FINE: 13:40:41.110: metadata: icy-genre: various
flutter: fvp.FINE: 13:40:41.110: metadata: icy-br: 96
flutter: fvp.FINE: 13:40:41.110: metadata: icy-description: Stream transcoder based on liquidsoap
flutter: fvp.FINE: 13:40:41.110: metadata: StreamTitle: HAL STUCKER/JARDIN - Empire!
flutter: fvp.FINE: 13:40:41.110: metadata: icy-pub: 1
DovgopolsSerj commented 4 months ago

Thanks! It's really very cool. Now there is actually one Package to rule them all :) Audio/video from local files, network, radio and TV from providers.