From 7180476b4ba163c6441fdf579648c2a732c5b1a5 Mon Sep 17 00:00:00 2001 From: badetitou Date: Sun, 4 Aug 2019 14:42:16 +0200 Subject: [PATCH] add arguments add media from web --- src/VLC/VLCLibrary.class.st | 41 ++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/src/VLC/VLCLibrary.class.st b/src/VLC/VLCLibrary.class.st index a9ddf31..f30837a 100644 --- a/src/VLC/VLCLibrary.class.st +++ b/src/VLC/VLCLibrary.class.st @@ -123,6 +123,28 @@ VLCLibrary >> initializeVLC [ ^ self ffiCall: 'void * libvlc_new();' ] +{ #category : #initialization } +VLCLibrary >> initializeVLCWithArguments: aCollectionOfString [ + "colArguments := OrderedCollection new. + colArguments add: '--novideo'. + vlc := VLCLibrary uniqueInstance initializeVLCWithArguments: colArguments. + media := vlc mediaFileFromStringLocation: 'https://s6.onlinevideoconverter.com/download?file=d3a0d3e4a0c2f5'. + player := vlc createPlayerForMedia: media. + vlc playMediaPlayer: player. + vlc pauseMediaPlayer: player. + vlc isMediaPlayerPlaying: player" + + | externalArray | + externalArray := (FFIExternalArray externalNewType: 'void*' size: aCollectionOfString size) autoRelease. + aCollectionOfString withIndexDo: [ :string :index | externalArray at: index put: (ExternalAddress fromString: string) autoRelease ]. + libVLCInstance := self initializeVLCWithArguments: externalArray getHandle andNumberOfArgs: aCollectionOfString size. +] + +{ #category : #initialization } +VLCLibrary >> initializeVLCWithArguments: aCollectionOfString andNumberOfArgs: sizeOfCollectionOfString [ + ^ self ffiCall: 'void * libvlc_new(int sizeOfCollectionOfString, void * aCollectionOfString);' +] + { #category : #'media list' } VLCLibrary >> insertInMediaList: aMediaList media: aMedia atIndex: anIndex [ ^ self ffiCall: 'int libvlc_media_list_insert_media (void * aMediaList, void * aMedia, int anIndex)' @@ -150,6 +172,18 @@ VLCLibrary >> libraryName [ ^ 'libvlc.so' ] +{ #category : #media } +VLCLibrary >> mediaFileFromFileDescriptor: fileDescriptor [ + "ex self mediaFileFromStringPath: '/home/badetitou/Musique/Coda.mp3'" + ^ self ffiCall: 'void* libvlc_media_new_fd(void* libVLCInstance, int fileDescriptor);' +] + +{ #category : #media } +VLCLibrary >> mediaFileFromStringLocation: aLocation [ + "ex self mediaFileFromStringPath: '/home/badetitou/Musique/Coda.mp3'" + ^ self ffiCall: 'void* libvlc_media_new_location (void * libVLCInstance, String aLocation);' +] + { #category : #media } VLCLibrary >> mediaFileFromStringPath: aStringPath [ "ex self mediaFileFromStringPath: '/home/badetitou/Musique/Coda.mp3'" @@ -202,7 +236,7 @@ VLCLibrary >> playMediaPlayer: aMediaPlayer [ player := vlc createPlayerForMedia: media. vlc playMediaPlayer: player " - ^ self ffiCall: 'void * libvlc_media_player_play(void* aMediaPlayer);' + ^ self ffiCall: 'int libvlc_media_player_play(void* aMediaPlayer);' ] { #category : #'media player' } @@ -239,6 +273,11 @@ VLCLibrary >> setMediaList: aMediaList forListPlayer: aListPlayer [ ^ self ffiCall: 'void* libvlc_media_list_player_set_media_list (void* aListPlayer, void* aMediaList)' ] +{ #category : #'media player' } +VLCLibrary >> setXWindows: indentifier forMediaPlayer: aMediaPlayer [ + ^ self ffiCall: 'void libvlc_media_player_set_xwindow(void* aMediaPlayer, int indentifier);' +] + { #category : #'accessing platform' } VLCLibrary >> unix32ModuleName [ #('/usr/lib/i386-linux-gnu' '/usr/lib32' '/usr/lib') , ((OSEnvironment current at: 'LD_LIBRARY_PATH' ifAbsent: [ '' ]) substrings: ':')