It is currently Wed Nov 20, 2019 11:56 pm

All times are UTC + 1 hour




Post new topic Reply to topic  [ 24 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: QuickTime video player for Cocoa
PostPosted: Thu Jun 29, 2017 2:43 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Apr 29, 2003 9:18 pm
Posts: 1459
Location: North by Northwest
The TouchBar shouldn't matter as the TouchBar items are automatically invoked if a TouchBar is available. If a TouchBar is not available it's not invoked.
Apparently a program with custom TouchBar items should even work on computers without TouchBar as long as macOS 10.12 is used.
Got a custom TouchBar coded with Objective C. It's pretty similar to the StatusBar.
Works nicely.

Thank you for all your input.

_________________

I am to provide the public with beneficial shocks.
Alfred Hitshock


Top
 Profile  
Reply with quote  
 Post subject: Re: QuickTime video player for Cocoa
PostPosted: Sat Jul 01, 2017 9:46 pm 
Offline
Addict
Addict
User avatar

Joined: Tue Apr 29, 2003 9:18 pm
Posts: 1459
Location: North by Northwest
Found out that it also works with NSApplicationMain; at least with local files.
Not sure why it doesn't work with remote files as:
Code:
   <key>NSAppTransportSecurity</key>
   <dict>
      <key>NSAllowsArbitraryLoads</key>
      <true/>
      <key>NSAllowsArbitraryLoadsInWebContent</key>
      <true/>
   </dict>

is inside the plist file...

Really strange.

_________________

I am to provide the public with beneficial shocks.
Alfred Hitshock


Top
 Profile  
Reply with quote  
 Post subject: Re: QuickTime video player for Cocoa
PostPosted: Sun Jul 02, 2017 12:21 am 
Offline
Addict
Addict
User avatar

Joined: Tue Apr 29, 2003 9:18 pm
Posts: 1459
Location: North by Northwest
It works now :!:

The solution is to only add:
Code:
   <key>NSAppTransportSecurity</key>
   <dict>
      <key>NSAllowsArbitraryLoads</key>
      <true/>
   </dict>

and leave NSAllowsArbitraryLoadsInWebContent out :!:
Now remote videos are played.
Finally :!:
:mrgreen:

BTW: NSApplicationMain works beautifully without a NIB :D

_________________

I am to provide the public with beneficial shocks.
Alfred Hitshock


Top
 Profile  
Reply with quote  
 Post subject: Re: QuickTime video player for Cocoa
PostPosted: Wed Nov 06, 2019 3:38 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Tue Jan 31, 2006 9:43 am
Posts: 490
Location: France
Hi Wilbert and Fsw,

Since QTKit/QTMovie (based on Quicktime 7, wich is 32 bits) is no more supported in MacOS 10.15 Catalina, i am trying to update my custom movie library with AVKit/AVFoundation.
I started using your code Wilbert, but i need to implement more functions like seeking into the video file.
I tryed with "seekToTime" like that but it does nothing :
Code:
   Structure CMTime ;{
      value.q ; Int64_t
      timeScale.l ; Int32_t
      flags.l ; UInt32_t
      CMTimeEpoch.q ; Int64_t
   EndStructure ;}

   Define.CMTime time
   Define.CMTime duration

   CocoaMessage(@duration, CocoaMessage(0, CocoaMessage(0, *p\Player, "currentItem"), "asset"), "duration")
Debug "Duration = " + Int(duration\value * 1000 / duration\timeScale) ; Works OK !

   time\timeScale = duration\timeScale
   time\value = Value * time\timeScale / 1000
   CocoaMessage(0, *p\Player, "seekToTime:@", @time)


Any idea ?

_________________
Niffo


Top
 Profile  
Reply with quote  
 Post subject: Re: QuickTime video player for Cocoa
PostPosted: Wed Nov 06, 2019 6:42 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Aug 08, 2004 5:21 am
Posts: 3519
Location: Netherlands
Niffo wrote:
Any idea ?

Code:
#kCMTimeFlags_Valid = 1
 
Structure CMTime
  value.q
  timeScale.l
  flags.l
  CMTimeEpoch.q
EndStructure
 
; Move to 30 sec
time.CMTime
time\value = 30000
time\timeScale = 1000
time\flags = #kCMTimeFlags_Valid
CocoaMessage(0, Player, "seekToTime:@", @time)

You forgot to set the flag that the time is valid.

_________________
macOS 10.15 Catalina, PB 5.71 x64


Top
 Profile  
Reply with quote  
 Post subject: Re: QuickTime video player for Cocoa
PostPosted: Thu Nov 07, 2019 4:11 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Tue Jan 31, 2006 9:43 am
Posts: 490
Location: France
Wilbert ... I love you ! <3

_________________
Niffo


Top
 Profile  
Reply with quote  
 Post subject: Re: QuickTime video player for Cocoa
PostPosted: Fri Nov 08, 2019 6:28 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Tue Jan 31, 2006 9:43 am
Posts: 490
Location: France
For those who would be interested, here is how to :

- Play the media :
Code:
CocoaMessage(0, Player, "play")

- Pause the media :
Code:
CocoaMessage(0, Player, "pause")

- Seek the media
Code:
Structure CMTime ;{
   value.q ; Int64_t
   timeScale.l ; Int32_t
   flags.l ; UInt32_t
   CMTimeEpoch.q ; Int64_t
EndStructure ;}
Define.CMTime time
CocoaMessage(@time, Player, "currentTime")
time\value = Value * time\timeScale / 1000
CocoaMessage(0, Player, "seekToTime:@", @time) ; To be knowed : seekToTime : parameters "toleranceBefore" and "toleranceAfter" can be set to "CMTimeZero" for higher accuracy

- Get the original size of the media
Code:
Define.CGSize size
CocoaMessage(@size, CocoaMessage(0, CocoaMessage(0, Player, "currentItem"), "asset"), "naturalSize") ; Noted as deprecated in Apple docs, should use : CGSize size = [[[movieAsset tracksWithMediaType:AVMediaTypeVideo] objectAtIndex:0] naturalSize];
debug size\width
debug size\height

- Change the media volume
Code:
Define.f Volume = Value / 100
CocoaMessage(0, Player, "setVolume:@", @Volume)

- Get the media duration
Code:
Structure CMTime ;{
   value.q ; Int64_t
   timeScale.l ; Int32_t
   flags.l ; UInt32_t
   CMTimeEpoch.q ; Int64_t
EndStructure ;}
Define.CMTime duration
CocoaMessage(@duration, CocoaMessage(0, CocoaMessage(0, Player, "currentItem"), "asset"), "duration")
debug Int(duration\value * 1000 / duration\timeScale)

- Free the media :
Code:
CocoaMessage(0, PlayerView, "setPlayer:", #Null)
CocoaMessage(0, PlayerView, "release")
CocoaMessage(0, Player, "replaceCurrentItemWithPlayerItem:", #Null)
CocoaMessage(0, Player, "release")

_________________
Niffo


Top
 Profile  
Reply with quote  
 Post subject: Re: QuickTime video player for Cocoa
PostPosted: Fri Nov 08, 2019 6:47 pm 
Offline
PureBasic Expert
PureBasic Expert

Joined: Sun Aug 08, 2004 5:21 am
Posts: 3519
Location: Netherlands
It would be nice if PureBasic itself would be updated to use AVPlayer instead of QuickTime for the Movie library.

_________________
macOS 10.15 Catalina, PB 5.71 x64


Top
 Profile  
Reply with quote  
 Post subject: Re: QuickTime video player for Cocoa
PostPosted: Fri Nov 08, 2019 6:51 pm 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Tue Jan 31, 2006 9:43 am
Posts: 490
Location: France
+1
viewtopic.php?f=24&t=73941

... but not the time to wait and before that (few years), PB Movie library was not complete/stable. Do not know if it is stable now.

_________________
Niffo


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 24 posts ]  Go to page Previous  1, 2

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye