procedure TForm1.PlayButtonClick(Sender: TObject);
begin
//
// 1. Create a URL
//
URL := NSURL.URLWithString(NSSTR(PAnsiChar('https://devstreaming-cdn.apple.com/videos/streaming/examples/img_bipbop_adv_example_ts/master.m3u8')));
if(Url = Nil) then
ShowMessage('NSURL.URLWithString failed!');
//
// 2. Create AVPlayer object
//
myAsset := AVAsset.alloc.assetWithURL(URL);
myPlayerItem := AVPlayerItem.alloc.initWithAsset(myAsset);
myPlayer := AVPlayer.alloc.initWithPlayerItem(myPlayerItem);
while(myPlayer.Status = AVPlayerStatusUnknown)
do
application.processmessages;
if(myPlayer.Status = AVPlayerStatusFailed) then
ShowMessage('AVplayer status: failed')
else if(myPlayer.Status = AVPlayerStatusReadyToPlay) then
ShowMessage('AVplayer status: ready to play');
//
// 3. Creete playerView object to display video
//
myPlayerView.alloc.setPlayer(myPlayer);
myPlayerView.setControlsStyle(1); // inline
if(myPlayerView.isReadyForDisplay) then
ShowMessage('AVPlayerView ready for display')
else
ShowMessage('AVPlayerView not ready for display');
//
// 4. Play
//
myPlayer.play;
end;
I thought this ws going to be simple but I was only half right - I have sound, but no video.
* AVplayer status: ready to play - yes
* AVPlayerView ready for display - no (delay before makes no difference)
Obviously there's something wrong with my AVPlayerView setup. Any ideas?