Giter VIP home page Giter VIP logo

audioplayermanager's People

Contributors

kevindelord avatar mtet88 avatar tschob avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

audioplayermanager's Issues

play song at index

hi,

after adding songs with AudioPlayerManager.shared.play(urlStrings: urls, at: index) how can i play a song at an index without passing urls again ?

Play downloaded audio

I have successfully downloaded the audio and saved it to application documents directory. But can't find any method to play it.

How do I download images from url to set as album artwork?

First of all thanks for this amazing library, it has been really helpful so far. I was trying find a way to set images from url as album artwork but could not find anything. Any help would be appreciated.

  • Also there is a minor issue when I try to forward a song it takes 4-5 seconds after the press then changes the song.

seek resets song

hi,

using following code, i'm not able to seek the song to my progress. it just restarts the song

    AudioPlayerManager.shared.seek(toProgress: songSlider.value)

songslider.value returns a correct float

am i doing something wrong?

BPM, how to get BPM ?

Unable to get BPM, doing the following in viewDidLoad

let tempData = MPMediaQuery.songs().items ?? []
self.data = []
for mediaItem in tempData {
  if (mediaItem.isCloudItem == false && mediaItem.assetURL != nil) {
    self.data.append(mediaItem)
    if (self.data.count >= 20) {
      var bpm: Int? = mediaItem.value(forProperty: MPMediaItemPropertyBeatsPerMinute) as? Int
      print(bpm)
      break
    }
  }
}

Thoughts on iOS 10 .playImmediately

I was looking for a decently solid library to start streaming MP3s from and your wrapper around AVPlayer has been awesome and saved a lot of time so far.

I've noticed with iOS 10 devices, when streaming through AVPlayer, it tends to buffer and create a noticeable lag from the time "play" is commanded and when it actually starts playing audio.

Any thoughts on adding a check for iOS 10 in the open func play(updateNowPlayingInfo: Bool = false) and then adding a playImmediately(atRate: 1.0) in there?

How to get playerstate?

Hi,
Is it possible to get player state? Like Buffering, Error, Playing and Pause. I can get playing and pause by AudioPlayerManager.shared.isPlaying(). But would like to know if there is build in function to get other states.

Play takes too long time in first time

Play doesn't work immediately on ios 10+. It works quite well below ios 10.

guard let url = URL(string: (self?.mMediaItem.media!)!) else { return }

let audioUrlTrack = AudioURLTrack(url: url)
AudioPlayerManager.shared.play(audioUrlTrack!)

Loading song in background

hi,

AudioPlayerManager.shared.play(urlStrings: urls, at: 0) method actually blocks the UI,
how about doing it in background?

actually using this snippet this can be achieved for now, but I think it may be better if it was embedded in library

DispatchQueue.global().async {
            
            DispatchQueue.main.async(execute: {
                AudioPlayerManager.shared.play(urlStrings: urls, at: 0)
            })
        }

loadDuration in AVAsset+Metadata returns nil in xcode 11 ios 13

Hello! Wie geht es dit? this is a really awesome repo by the way!

I have noticed a problem when trying my app that uses your repo which is that the seek bar is not shown in control center. Please note that i am not sure if the problem is only in my use case or the loadDuration func is bugged. The problem was in the function "updateNowPlayingInfoPlaybackDuration" of AudioTrack.swift it returned nil duration and i was able to solve it by changing it to

open func updateNowPlayingInfoPlaybackDuration() {

	self.playerItem?.asset.loadDuration(completion: { [weak self] (duration: NSNumber?) in
        if duration != nil {
            self?.nowPlayingInfo?[MPMediaItemPropertyPlaybackDuration] = duration
        } else {
            if let durationShit = self?.playerItem?.asset.duration, durationShit != CMTime.indefinite {
                self?.nowPlayingInfo?[MPMediaItemPropertyPlaybackDuration] = NSNumber(value: CMTimeGetSeconds(durationShit))
                print("did set duration = \(NSNumber(value: CMTimeGetSeconds(durationShit)))")
            }
        }
	})
    
}

Have a nice day.

Custom metadata

Hi, Is there any way to set custom metadata like title and albumart while playing from url?

Hi Sir I faced some issue need your help

Sorry for creating issue here.

i want to use FolioReaderKit in my app, pod installed but i got an following error while opening book.

Assertion failure in -[MPSkipTrackCommand addTarget:action:], /Library/Caches/com.apple.xbs/Sources/MediaPlayer/MobileMusicPlayer-4017.700.3/SDK/MPRemoteCommand.m:134
2020-09-15 13:48:56.405087+0500 ShelfDemo[1743:367467]

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Unsupported action method signature. Must return MPRemoteCommandHandlerStatus or take a completion handler as the second argument.

Could you please help me what is wrong my side ?

append and prepend are unusable

The AudioPlayerManager class has two public functions that take a queue number/generation as a parameter.

open func prepend(_ audioTracks: [AudioTrack], toQueue generation: Int)
open func append(_ audioTracks: [AudioTrack], toQueue generation: Int)

Inside those two methods a test is made against the current generation or the operation fails. There is no way to determine what a valid value for that might be. The current generation for the manager is a private variable, and none of the methods ever returns the value of that variable.

This makes the prepend and append functions unusable.

There are two, three, enumerable ways to fix this. Here are a few.

The Easy Way

to make the queueGeneration variable public,

open var queueGeneration

plus: simple fix
minus: it doesn't provide whatever protection that check is trying to help in the first place, except to scrupulous programmers
plus: it still allows some provided functionality to programmers that want that check to occur

The Hard Way

update every function that touches/changes the generation to return the new generation, the code that called the function that causes the new generation is the code that is allowed to modify the queue

this code that modifies the queue generation value includes:

private func clearQueue()
open func replace(with audioTracks: [AudioTrack], at startIndex: Int)

and indirectly, all other replace and play calls, as well as stop

The Middle Way

add new, additional API for those interested in later calling prepend or (more likely) append, which provides the generation value they need

minus: this is at least 7 different calls currently

Yet More Choice

you could add two additional append/prepend functions that ignore the queue generation, this would allow the same bypass as "The Easy Way" but would not expose the internal value.

open func prepend(_ audioTracks: [AudioTrack])
open func append(_ audioTracks: [AudioTrack])

My Vote

✅ The Easy Way

Swift 4

Add support for building with Swift 4

Provide functions which seeks a playing track by a given timer diference

The bahvior can be already implemented with the following snippet, but a little bit of syntx suggar would be nice. Improves #20

guard let _currentTimeInSeconds = AudioPlayerManager.shared.currentTrack?.currentTimeInSeconds() else {
	return
}

var newTimeInSeconds = _currentTimeInSeconds - 10
if (newTimeInSeconds < 0) {
	newTimeInSeconds = 0
}
let time = CMTimeMake(Int64(newTimeInSeconds), 1)
AudioPlayerManager.shared.seek(toTime: time)

fatal error: Double value cannot be converted to Int because it is either infinite or NaN

I'm getting this error when i run the code

    player.setup()
    
    player.play(url: URL(string: "url/media/podcast/z3f1fi18.mp3"))

Error at class: AudioTrack
method: updateNowPlayingInfoPlaybackDuration

open func updateNowPlayingInfoPlaybackDuration() {
if let _playerItem = self.playerItem {
let duration = NSNumber(value: Int(CMTimeGetSeconds(_playerItem.asset.duration)) as Int)
self.nowPlayingInfo?[MPMediaItemPropertyPlaybackDuration] = duration

any solution?

Main thread freezes when playing next track in playlist

I am using the framework for playing URL with index.
whenever there is a change of track Main thread completely freezes.

[AudioPlayerManager].restartCurrentTrack()[397]: restartCurrentTrack is debug console print at the time of freeze

do you have a better way to achieve shuffle/single loop/List loop playing mode ?

I'm learning swift and try to make a simple music player by using MPMediaQuery. But I find it hard to get currentItemIndex to update the UI with it's data(cover, title and so on). Without index , it's hard to achieve single circle mode or shuffle mode. Do u have a better way to make it ? Sorry for my poor English, looking forawrd to your reply.

Add headers

Hi,

thanks for the great job

is there any way that I can add headers to the url(s) so I can satisfy some security protocols of the server ?

verbose: default incorrect

I'm not sure if the documentation is lying to me, or the code is wrong.

AudioPlayerManager.swift v.1.2.3

	/// Set this to true if the `AudioPlayerManager` log should be enabled. The default is `false`.
	open static var verbose						= true

No music player in Notification Center/Lockscreen after playing video

My app plays video and audio.
I start fullscreen videos like this:

    func startFullscreenVideo(videoURL:URL) {
        
        let player = AVPlayer(url: videoURL)
        
        let controller = AVPlayerViewController()
        controller.player = player
        
        present(controller, animated: true) {
            player.play()
            
        }
    }

and the Audio with your library.

Problem: After playing Audio, then playing a Video, and then playing Audio again the App stops to show a Music Player in Background/Lock Screen/Control Center (https://i.stack.imgur.com/zXRw2.jpg this one starts missing).

This is a weird bug and I hope you can help me.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.