Comments (32)
_audioPlayer.icyMetadataStream.listen(
(icyEvent) { ... }
); works well for android, but how to get the audio title on iOS?
from just_audio.
Hey @pblinux !
Yes, it's definitely the way to do it. I was working on a solution yesterday using onTracksChanged, however, I was only checking the first TrackGroup of the trackGroups
array. It worked for my specific case, but your idea of iterating over the entire trackGroups
array is probably safer. I'll commit the changes and work on the PR.
from just_audio.
I feel I can increase my personal priority for this issue now. I would still at least like to get the visualizer feature published first and make the one-isolate
branch of audio_service stable, but following that I'd like to get the iOS implementation of this feature implemented for completeness.
from just_audio.
I will have a go at it tonight.
Note to self:
https://developer.apple.com/documentation/avfoundation/avplayeritemmetadataoutput?language=objc
from just_audio.
Thx for your work :)
You can test with this streams :
http://str0.creacast.com/classique1
http://icecast.skyrock.net/s/natio_aac_64k?tvr_name=tunein16&tvr_section1=32aac
http://kissfm.ice.infomaniak.ch/kissfm-128.mp3
from just_audio.
I've implemented iOS/macOS support in the latest commit. Note that all of the streams I tested only provided "title" metadata, and because I reverse engineered the keys from the metadata in those test URLs above, the title is the only metadata it is coded for. I will try to support other metadata keys if anyone provides a URL that exhibits them.
Let me know how it goes. One thing I wanted to be careful about was introducing a retain cycle. I don't think I've done that, but if you notice any memory leak (e.g. memory retained after player item or player itself is disposed), please let me know.
from just_audio.
I've opened an issue in the ExoPlayer repository to ask for clarifications on how to retrieve IcyHeaders: google/ExoPlayer#7266
from just_audio.
I was able to get current playing title on iOS. It worked well in simulator.
from just_audio.
Just ran into this issue and updating to latest version solved it.
Tested it on a real iOS device.
Thanks a lot for your great work.
from just_audio.
Thanks, Jei. I'd certainly be happy to accept a PR once you finish it as I think this could be useful to others. If you're only adding some more fields and a stream, I don't think that should break anything.
from just_audio.
Hello @Jei @ryanheise.
About the IcyInfo that's not retrieving, I think or it's a ExoPlayer issue or it's the DataSource, I'm not sure.
This are the things I tried so far:
- Creating a DefaultHttpDataSourceFactory and adding a property Icy-MetaData", "1". Nothing changes.
DefaultHttpDataSourceFactory httpDataSource = new
DefaultHttpDataSourceFactory(Util.getUserAgent(context, "just_audio"), null);
httpDataSource.getDefaultRequestProperties().set("Icy-MetaData", "1");
DataSource.Factory dataSourceFactory = new DefaultDataSourceFactory(context, httpDataSource);
- Adding a audioAttribute to the player, nothing changes.
player.setAudioAttributes(new AudioAttributes.Builder().setContentType(C.CONTENT_TYPE_MUSIC).setUsage(C.USAGE_MEDIA).build());
- Using an external library: I found this metadata retriever and it works, this retrieves the icy-headers correctly:
https://github.com/vsmaks/audiostream-metadata-retriever- The problem here, I think, that this makes an additional request for the data.
- Also, it's outdated so I had to add tools:replace="android:label" to my project AndroidManifest
from just_audio.
Thank you for the pointers @pblinux.
I've tried to add the ExoPlayer's OkHttp extension to use OkHttpDataSourceFactory instead of DefaultHttpDataSourceFactory, but it doesn't make any difference. However by logging the HTTP calls I was able to confirm that the Icy headers are being received correctly:
D/OkHttp (22180): --> GET http://stream2.mpegradio.com:8070/tormented.mp3
D/OkHttp (22180): Icy-MetaData: 1
D/OkHttp (22180): User-Agent: just_audio/1.0.0 (Linux;Android 9) ExoPlayerLib/2.11.1
D/OkHttp (22180): Accept-Encoding: identity
D/OkHttp (22180): --> END GET
D/OkHttp (22180): <-- 200 OK http://stream2.mpegradio.com:8070/tormented.mp3 (605ms)
D/OkHttp (22180): icy-notice1: <BR>This stream requires <a href="http://www.winamp.com">Winamp</a><BR>
D/OkHttp (22180): icy-notice2: SHOUTcast DNAS/posix(linux x64) v2.5.5.733<BR>
D/OkHttp (22180): Accept-Ranges: none
D/OkHttp (22180): Access-Control-Allow-Origin: *
D/OkHttp (22180): Cache-Control: no-cache,no-store,must-revalidate,max-age=0
D/OkHttp (22180): Connection: close
D/OkHttp (22180): icy-name: -=- tormented radio -=- streaming since 1998
D/OkHttp (22180): icy-genre: Industrial
D/OkHttp (22180): icy-br: 128
D/OkHttp (22180): icy-sr: 44100
D/OkHttp (22180): icy-url: http://www.tormentedradio.com
D/OkHttp (22180): icy-pub: 1
D/OkHttp (22180): content-type: audio/mpeg
D/OkHttp (22180): icy-metaint: 16384
D/OkHttp (22180): X-Clacks-Overhead: GNU Terry Pratchett
Note that I didn't have to set the Icy-MetaData
header manually, it's part of the request sent by ExoPlayer.
I'll keep looking.
from just_audio.
Hello @Jei
I just tested what they said, it works.
onTracksChanged it's the way that exoplayer expose those headers.
@Override
public void onTracksChanged(TrackGroupArray trackGroups, TrackSelectionArray trackSelections) {
for (int i = 0; i < trackGroups.length; i++) {
TrackGroup trackGroup = trackGroups.get(i);
for (int j = 0; j < trackGroup.length; j++) {
Metadata trackMetadata = trackGroup.getFormat(j).metadata;
if (trackMetadata != null) {
Log.d("just-audio:", trackMetadata.toString());
}
}
}
}
from just_audio.
Thank, @Jei ! I've merged your PR and added a stub for iOS/macOS.
from just_audio.
It is not implemented on iOS yet. I've reopened this issue, and I'll note below a useful reference example for how I might be able to implement it:
https://stackoverflow.com/questions/27955125/timed-metadata-with-avplayer
from just_audio.
@Jei Can you add this option also for iOS too? I'm not that expert yet. LOL I really need this in my project!
from just_audio.
Hey @oseiasmribeiro! Unfortunately, I don't own any Apple device at the moment, so I don't think I'll be able to write and test the iOS version of these changes. It's also the reason why I released my current project only on the Play Store.
from just_audio.
@Jei Ok. Thanks!
from just_audio.
for iOS, not yet? If somebody helps, very very thanks.
from just_audio.
This is a very egregious question !!! And there are still no solutions (((
I spent 3 days on the Internet looking for a solution, but I did not achieve my goal.
Dear Developer please help us. Metadata is a very important part of any music file.
In the modern world without the name of the composition - no one needs you!
I will attach the results of my searches. I really hope that this will help you to improve the plugin)
1
2
There are also 2 interesting codes here
1
2
I translated it all into swift
let playerItem = AVPlayerItem(url: url)
let metadataList = playerItem.asset.commonMetadata
for metaItem in metadataList {
if let common = metaItem.commonKey {
print("\(common)")
}
}
let titleIndex = (avItem.asset.commonMetadata as NSArray).indexOfObject(passingTest: { obj, idx, stop in
let metaItem = obj as? AVMutableMetadataItem
if metaItem?.commonKey?.isEqual(toString: AVMetadataKey.commonKeyTitle) != nil {
return true
}
return false
})
let item = avItem.asset.commonMetadata[titleIndex] as? AVMutableMetadataItem
let title = item?.value as? String
3
This is similar to the first link, but more expanded
4
Quite an interesting tip
Вот что у меня из этого получилось, но не сработало:
let url = URL(fileURLWithPath: st)
let asset = AVAsset(url: url)
let formatsKey = "playable"
asset.loadValuesAsynchronously(forKeys: [formatsKey]) {
var error: NSError? = nil
let status = asset.statusOfValue(forKey: formatsKey, error: &error)
if status == .loaded {
for format in asset.availableMetadataFormats {
let metadata = asset.metadata(forFormat: format)
// process format-specific metadata collection
print("\(metadata)")
}
}
}
let metadataItems = asset.commonMetadata
let metadataItem = AVMetadataItem.metadataItems(from: metadataItems, filteredByIdentifier: AVMetadataIdentifier.commonIdentifierArtwork)
print(metadataItem);
let playerItem = AVPlayerItem(url: url)
let metadataList = playerItem.asset.commonMetadata
for metaItem in metadataList {
if let common = metaItem.commonKey {
print("\(common)")
}
}
5
from just_audio.
@Jei
Please help us. tell me at least what needs to be changed at:
Project \ ios \ Runner \ AppDelegate.swift
some kind of temporary solution.
I hope my searches, in the previous post, will help you
from just_audio.
I agree that this would be a very worthwhile feature to have on iOS, although please do keep in mind this is a collaborative effort. I will have my own priorities for which feature I will implement next (e.g. a visualiser and equaliser, or gapless looping), but other contributors may also have their own priorities, so if you can't wait for me alone to implement every single feature, it will just take the right contributor who is sufficiently motivated and wants this feature urgently enough to become a project contributor, and help out the project in the same way that @Jei graciously contributed the Android implementation.
Contributions are definitely welcome, even from those who are completely new to iOS and the Objective C programming language (several people have contributed Objective C code without having any prior experience with Objective C, so that is possible.)
from just_audio.
Hi, I don't have a deep knowledge about audio metadata or icy-metadata and difference between two but I am wonder to know that
is it possible to have audio thumbnail image (cover art) and description fields in metadata?
from just_audio.
Still no one for added this functionnalty on IOS ? :)
from just_audio.
@blackraven96 I am currently working on the visualiser feature, followed by nnbd (maybe this will come first), then maybe web assets/files, alongside bugs that crop up.
I have posted a link above on how this could be implemented, but it will just take someone sufficiently motivated to submit a pull request and jump the queue (otherwise if I implement it, it will happen after completing other items which are a higher priority for me personally).
Would you be interested in trying your hand at some Objective C code?
from just_audio.
We are waiting for your decision ...
from just_audio.
Also waiting for this feature. Hope it gets implemented in the next few days :)
Thanks for your amaizing work
from just_audio.
I'll hopefully make time for it this week. In the meantime, please post below some URLs of audio you would like me to use as this cases.
from just_audio.
Fingers crossed. Currently building a radio app for iOS and metadata are missing.
https://www.radioking.com/play/note-radio
from just_audio.
I'm testing https://www.radioking.com/play/note-radio and am picking up the title.
Does anyone have more URLs to test, with more metadata?
from just_audio.
Any feedback/reports so far?
from just_audio.
Just to update, I've added support for the URL metadata on iOS. It's implemented in the fix/ios_livestream
branch.
Will anyone be able to test this on their streams to confirm whether it works for you before I publish?
from just_audio.
Related Issues (20)
- set pitch not working on IOS HOT 3
- Export the native platform instance for more access (especially with plugins) HOT 2
- Does not play .m4a audio files ( (4) Failed to load URL) HOT 2
- Commandline / terminal sound playback HOT 2
- Audio play error in http url and m3u8 format
- often music item doesn't loop well if I am using multiple instances HOT 2
- often music item doesn't loop well if I am using multiple instances HOT 2
- ConcatinatingAudioSource.clear() sets currentIndex to zero HOT 7
- Local Streaming audio is not working in the ios device HOT 2
- Local Streaming audio is not working in the ios device HOT 2
- Local Streaming audio is not working in the ios device HOT 3
- Background audio play in Android 14 HOT 2
- Player controls not working in system tray ( Notification ) Android 10. HOT 1
- Android OutOfMemoryError When Using setAudioSource with Large Audio File (3GB, 56 Hours) HOT 4
- Unable to play song from background notification in android 14 HOT 2
- Path not provided. Stream is not supported. HOT 2
- just_audio + AirPlay - plays as a video (full screen saver) - how to fix? HOT 2
- Bug Report: setUrl or setAudioSource Error on Android 6 HOT 2
- MissingPluginException (MissingPluginException(No implementation found for method init on channel com.ryanheise.just_audio.methods)) HOT 2
- MissingPluginException(No implementation found for method init on channel com.ryanheise.just_audio.methods) HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from just_audio.