Impostare le notifiche

Il lettore può ascoltare una serie di eventi che indicano lo stato del lettore.

Supponendo che PTMediaPlayer è una proprietà del lettore client, self.player nell'esempio seguente rappresenta PTMediaPlayer dell'istanza. L'esempio seguente implementa addObservers metodo visualizzato nelle istruzioni di configurazione di PTMediaPlayer e che include la maggior parte delle notifiche:

[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onMediaPlayerStatusChange:)
      name:PTMediaPlayerStatusNotification object:self.player];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onMediaPlayerNotification:)
      name:PTMediaPlayerNewNotificationEntryAddedNotification object:self.player];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onMediaPlayerTimeChange:)
      name:PTMediaPlayerTimeChangeNotification object:self.player];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onMediaPlayerItemPlayStarted:)
      name:PTMediaPlayerPlayStartedNotification object:self.player];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onMediaPlayerItemPlayCompleted:)
      name:PTMediaPlayerPlayCompletedNotification object:self.player];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onMediaPlayerItemTimelineChanged:)
      name:PTMediaPlayerTimelineChangedNotification object:self.player];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onMediaPlayerItemMediaSelectionOptionsAvailable:)
      name:PTMediaPlayerMediaSelectionOptionsAvailableNotification object:self.player];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onMediaPlayerAdBreakStarted:)
      name:PTMediaPlayerAdBreakStartedNotification object:self.player];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onMediaPlayerAdBreakCompleted:)
      name:PTMediaPlayerAdBreakCompletedNotification object:self.player];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onMediaPlayerAdPlayStarted:)
      name:PTMediaPlayerAdStartedNotification object:self.player];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onMediaPlayerAdPlayProgress:)
      name:PTMediaPlayerAdProgressNotification object:self.player];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(onMediaPlayerAdPlayCompleted:)
      name:PTMediaPlayerAdCompletedNotification object:self.player];

Notifiche iOS

ThePTMediaPlayerNotifications La classe elenca le notifiche che TVSDK invia al lettore.

Notifica Significato
PTMediaPlayerAdBreakCompletedNotification Interruzione pubblicitaria terminata.
PTMediaPlayerAdBreakStartedNotification È iniziata un’interruzione pubblicitaria.
PTMediaPlayerAdClickNotification Un utente ha fatto clic su un banner pubblicitario.
PTMediaPlayerAdCompletedNotification Un singolo annuncio è terminato.
PTMediaPlayerAdProgressNotification Un annuncio è progredito; inviato costantemente durante la riproduzione di un annuncio.
PTMediaPlayerAdStartedNotification È stato avviato un singolo annuncio.
PTBackgroundManifestErrorNotification Download del manifesto in background non riuscito.
PTMediaPlayerBufferingCompletedNotification Buffering completato.
PTMediaPlayerBufferingStartedNotification Il lettore multimediale entra in uno stato di buffering.
PTAudioTrackChangeCompleted È stata completata una modifica nella traccia audio del contenuto multimediale attualmente in riproduzione.
PTAudioTrackChangeStarted È stata avviata una modifica alla traccia audio del contenuto multimediale attualmente in riproduzione.
PTMediaPlayerItemChangedNotification Un altro PTMediaPlayerItem del PTMediaPlayer è stato impostato.
PTMediaPlayerItemDRMMetadataChanged Metadati DRM modificati.
PTMediaPlayerMediaSelectionOptionsAvailableNotification Sono disponibili nuovi sottotitoli e tracce audio alternative ( PTMediaSelectionOption ).
PTMediaPlayerNewNotificationEntryAddedNotification Una nuova PTNotification è stato aggiunto al PTNotificationHistoryItem dell'attuale PTMediaPlayerItem , ovvero quando un evento di notifica viene aggiunto alla cronologia delle notifiche.
PTMediaPlayerPlayCompletedNotification Riproduzione dei contenuti multimediali terminata.
PTMediaPlayerSeekCompletedNotification Ricerca completata.
PTMediaPlayerSeekErrorNotification Operazione di ricerca corrente non riuscita.
PTMediaPlayerSeekStartedNotification Inizio della ricerca.
PTMediaPlayerPlayStartedNotification Riproduzione avviata.
PTMediaPlayerStatusNotification Lo stato del lettore è cambiato. I valori di stato possibili sono:
  • PTMediaPlayerStatusCreated

  • PTMediaPlayerStatusInitializing

  • PTMediaPlayerStatusInitialized

  • PTMediaPlayerStatusReady

  • PTMediaPlayerStatusPlaying

  • PTMediaPlayerStatusPaused

  • PTMediaPlayerStatusStopped

  • PTMediaPlayerStatusCompleted

  • PTMediaPlayerStatusError

PTMediaPlayerTimeChangeNotification L'ora corrente della riproduzione è cambiata.
PTMediaPlayerTimelineChangedNotification La timeline corrente del lettore è stata modificata.
PTTimedMetadataChangedNotification TVSDK: rilevata la prima occorrenza di un tag sottoscritto.
PTTimedMetadataChangedInBackgroundNotification

Un tag sottoscritto viene identificato nel manifesto in background e un nuovo PTTimedMetadata L'istanza viene preparata da essa.

Gestori di esempio per le notifiche

I seguenti snippet di codice illustrano alcuni modi in cui è possibile utilizzare le notifiche.

Recupera il PTAdBreak istanza che utilizza PTMediaPlayerAdBreakKey:

 - (void) onMediaPlayerAdBreakStarted:(NSNotification *) notification {
   // Fetch the PTAdBreak instance using PTMediaPlayerAdBreakKey
   PTAdBreak *adBreak = [notification.userInfo objectForKey:PTMediaPlayerAdBreakKey];
   ...
   ...
}

Imposta subtitlesOptions e audioOptions:

 - (void) onMediaPlayerItemMediaSelectionOptionsAvailable:(NSNotification \*) notification {
   //SubtitlesOptions and audioOptions are set and accessible now.
   NSArray* subtitlesOptions = self.player.currentItem.subtitlesOptions;
   NSArray* audioOp tions = self.player.currentItem.audioOptions;
   ...
   ...
}

Recupera il PTAd istanza che utilizza PTMediaPlayerAdKey:

 - (void) onMediaPlayerAdPlayStarted:(NSNotification \*)  notification {
   // Fetch the PTAdinstance using PTMediaPlayerAdKey
   PTAd *ad = [notification.userInfo objectForKey:PTMediaPlayerAdKey];
   ...
   ...
}

In questa pagina