Alcinoe icon indicating copy to clipboard operation
Alcinoe copied to clipboard

TALMacOSVideoPlayer implementation

Open TetrisSQC opened this issue 4 years ago • 7 comments

Hi, I added a TALMacOSVideoPlayer implementation based on the OpenGLES implementation for IOS. This was quite straight forward, but I did not got the OpenGL renderer working. What I did is adding the metal video framework for the OS X playback.

macos.txt Bildschirmfoto 2021-01-24 um 11 27 41

TetrisSQC avatar Jan 23 '21 13:01 TetrisSQC

Hi TetrisSQC, I m really sorry but the TALMacOSVideoPlayer is not yet implemented, it's just a virtual class :( the VideoPlayer work only on mobile (Ios/Android) yet. I don't have any plan to make it working on desktop.

Zeus64 avatar Mar 31 '21 22:03 Zeus64

You probably misunderstood my post above. It contains the complete implementation for the MacOS video player. I also made one for Windows which uses ffmpeg and also runs on all other platforms.

TetrisSQC avatar Apr 01 '21 11:04 TetrisSQC

TetrisSQC That is great news can you merge it with the main brance

azrael11 avatar Apr 01 '21 12:04 azrael11

@TetrisSQC yes I didn't understand this ! that a great news ! I will try to merge it asap

Zeus64 avatar Apr 01 '21 13:04 Zeus64

Sure, the attached zip contains the patched code for your alvideoplayer.pas. I think I kept your coding style intact. The demo is an example which should play a stream under MacOS, iOS and Android.

osxplayer.zip

Christian

TetrisSQC avatar Apr 01 '21 17:04 TetrisSQC

Sure, the attached zip contains the patched code for your alvideoplayer.pas. I think I kept your coding style intact. The demo is an example which should play a stream under MacOS, iOS and Android.

osxplayer.zip

Christian

Please make an example with windows ffmpeg video player.

azrael11 avatar Apr 01 '21 18:04 azrael11

Oh this one is missing, it will require some time to add since I used parts of a commercial code project. You could also use this project https://github.com/TetrisSQC/StreamPlayer.

The implementation then looked like this:

`constructor TALWinVideoPlayer.Create; begin inherited; fOnFrameAvailableEvent := nil; fOnCompletionEvent := nil; fOnErrorEvent := nil; FOnPreparedEvent := nil; fonVideoSizeChangedEvent := nil;

FPlayer := TAVPlayer.create(nil); FPlayer.HardwareAccelerated := true; FPlayer.ForceYV12 := true; fbitmap := TAVBitmap.create(nil); fbitmap.Player := FPlayer; fBitmap.OnUpdate := doOnFrameRefresh; fbitmap.onResize := doOnVideoSizeChanged; end;

{ *********************************** } destructor TALWinVideoPlayer.Destroy; begin alFreeandNil(fbitmap); alFreeandNil(FPlayer); inherited; end;

{ *************************************************** } function TALWinVideoPlayer.getCurrentPosition: int64; begin result := Trunc(FPlayer.Position*1000); end;

{ ******************************************** } function TALWinVideoPlayer.getDuration: int64; begin result := Trunc(FPlayer.Duration*1000); end;

{ ************************************************* } function TALWinVideoPlayer.getVideoHeight: Integer; begin result := FPlayer.VideoHeight; end;

{ ************************************************ } function TALWinVideoPlayer.getVideoWidth: Integer; begin result := FPlayer.VideoWidth; end;

{ ******************************************** } function TALWinVideoPlayer.isPlaying: Boolean; begin result := FPlayer.Playing; end;

{ ******************************** } procedure TALWinVideoPlayer.pause; begin FPlayer.Pause; end;

{ ************************************************************* } procedure TALWinVideoPlayer.prepare(Const aDataSource: String); begin FPlayer.OpenMovie(aDataSource); end;

{ ******************************** } procedure TALWinVideoPlayer.Start; begin FPlayer.Play; end;

{ ******************************* } procedure TALWinVideoPlayer.Stop; begin FPlayer.CloseMovie; end;

{ **************************************************** } procedure TALWinVideoPlayer.doOnFrameRefresh(Sender: TObject); begin if assigned(fOnFrameAvailableEvent) then fOnFrameAvailableEvent(Self); end;

procedure TALWinVideoPlayer.doOnVideoSizeChanged(Sender: TObject); begin if assigned(fonVideoSizeChangedEvent) then fonVideoSizeChangedEvent(self, FBitmap.Bitmap.Width, FBitmap.Bitmap.Height); end;

{ **************************************************** } procedure TALWinVideoPlayer.seekTo(const msec: int64); begin FPlayer.Position := msec/1000; end;

{ ************************************************************* } procedure TALWinVideoPlayer.setLooping(const looping: Boolean); begin end;

{ ********************************************************* } procedure TALWinVideoPlayer.setVolume(const Value: Single); begin FPlayer.Volume := Value; end;

{ **************************************************************** } procedure TALWinVideoPlayer.setPlaybackSpeed(const Value: Single); begin // not implemented end;

{ ******************************************* } function TALWinVideoPlayer.getState: Integer; begin result := vpsIdle; end;

`

I might try to assemble this after easter.

TetrisSQC avatar Apr 01 '21 18:04 TetrisSQC