Hello,
I find that, playing the same audio file with VLC and with a Xojo.moviePlayer with volume set at max (256), the sound gotten in VLC is much higher (I guess double) than in Xojo.movieplayer.
Any hint how to gar better volume? Thanks,
Carlo
VLC is probably setting the volume outside the usual 0-1 range (off-100%). That’s what I do below to set the volume 2, 3 or 4 times louder than it should go (but this code only works on Mac with an older version of Xojo where MoviePlayer is based on QuickTime).
What OSes are you targeting?
[code]Private Sub setOverMaxVolume(v As single)
declare function getMovie lib “QTKit” selector “movie” (id As Ptr) As Ptr
declare sub setVol lib “QTKit” selector “setVolume:” (id As Ptr, vol As single)
dim id As Ptr = Ptr(player.Handle)
dim mov As Ptr = getMovie(id)
setVol(mov, v)
End Sub[/code]
Using Yosemite and Xojo 15.3. Therefore, as you said, your snippet wont work.
Xojo uses AVPlayer for playing.
You can get it via MoviePlayer.AVPlayerMBS with MBS AVFoundation player.
And than set volume.
My app is a cheap shareware…
MBS may be the only way; at least I can’t find a way to get at the AVPlayer through declares.
Or you could use the movie player in MacOSLib.
This should not stop you from buying good tools to make a better application.
Same low output-level. On the other end, I notice that Apple QT Player app too reproduces a lower sound.
I thought MacOSLib had a AVPlayer but I only see QTMovieView. And it has get volume but no set volume. So I added the set volume declare and it gets louder than 100%.
Set your computers volume to its lowest level before trying this out (unless you have a really quiet movie). The volume gets set to 10 times maximum, 1000%. Haven’t measured that it’s actually 10x louder but it’s definitely louder.
[code]Sub Action()
dim f As FolderItem = GetOpenFolderItem("")
if f = nil then return
QTMovieView1.Movie = QTKit.QTMovie.LoadFromFolderItem(f)
End Sub
Sub Action()
declare sub setVol lib “QTKit” selector “setVolume:” (id As Ptr, vol As single)
setVol(QTMovieView1.Movie.id, 10)
End Sub[/code]
Yes, the volume is definetly higher.
Just a question: is QTKit accepted by MAS?
Thnaks.
Pretty sure it’s not; that’s why Xojo switched to AV. You’ll have to use MBS (unless there is a way to get at the AVPlayer with declares).
I suspect the MBS plugins walk the view hierarchy to find the AVPlayerLayer, which isn’t officially supported. This can be done easily enough with declares.
I’ve walked the hierarchy but not finding anything AV
NSThemeFrame (NSTitledFrame, NSFrameView, NSView, NSResponder, NSObject)
_NSThemeCloseWidget (_NSThemeWidget, NSButton, NSControl, NSView, NSResponder, NSObject)
_NSThemeWidget (NSButton, NSControl, NSView, NSResponder, NSObject)
_NSThemeWidget (NSButton, NSControl, NSView, NSResponder, NSObject)
XOJContentView (NSView, NSResponder, NSObject)
XOJButton (NSButton, NSControl, NSView, NSResponder, NSObject)
XOJMovieView (NSView, NSResponder, NSObject) <<<<============ MoviePlayer
NSView (NSResponder, NSObject)
XOJMovieControlsBackgroundView (NSView, NSResponder, NSObject)
NSButton (NSControl, NSView, NSResponder, NSObject)
XOJMovieScrubber (NSSlider, NSControl, NSView, NSResponder, NSObject)
NSButton (NSControl, NSView, NSResponder, NSObject)
NSButton (NSControl, NSView, NSResponder, NSObject)
NSButton (NSControl, NSView, NSResponder, NSObject)
XOJScrollView (NSScrollView, NSView, NSResponder, NSObject)
NSClipView (NSView, NSResponder, NSObject)
XOJTextView (NSTextView, NSText, NSView, NSResponder, NSObject)
NSScroller (NSControl, NSView, NSResponder, NSObject)
NSContentLayoutView (NSView, NSResponder, NSObject)
Oh, it’s a Layer. OK then I’ll find that later. Thanks Joe.
Thanks again Joe for mentioning the Layer, never thought to look in there. This code ups the volume for modern Xojo MoviePlayers but it should be noted it’s not the most robust, as in it’s assuming the first subview of the MoviePlayer is where the layer of interest is. Plus no nil checks. It’d be better I think to loop over the subviews looking for the one with a layer that’s a subclass of AVPlayerLayer.
[code]Sub setOverMaxVolumeAV(vol As single)
//NSView
declare function getLayer lib “AppKit” selector “layer” (id As Ptr) As Ptr
declare function subviews lib “AppKit” selector “subviews” (id As Ptr) As Ptr
//AVPlayerLayer and AVPlayer
declare function getPlayer lib “AVFoundation” selector “player” (id As Ptr) As Ptr
declare sub setVolume lib “AVFoundation” selector “setVolume:” (id As Ptr, vol As Single)
//NSArray
declare function objAtIdx lib “Foundation” selector “objectAtIndex:” (id As Ptr, idx As UInt32) As Ptr
declare function count lib “Foundation” selector “count” (id As Ptr) As integer
dim sva As Ptr = subviews(Ptr(player.Handle))
dim obj As Ptr = objAtIdx(sva, 0) //assume first subview has our layer
dim pl As Ptr = getLayer(obj) //NSKVONotifying_AVPlayerLayer
dim p As Ptr = getPlayer(pl) //NSKVONotifying_AVPlayer
setVolume(p, vol)
End Sub[/code]
Thanks Will, works fine
Thanks also from me. Carlo.