-
-
Notifications
You must be signed in to change notification settings - Fork 303
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cant play file thats stored locally? #840
Comments
Hi @jimdog1001, were you able to fix this issue? I am having the same problem. This line properly downloads and plays the file (and the IMediaItem mediaItem = await CrossMediaManager.Current.Play("https://ia800806.us.archive.org/15/items/Mp3Playlist_555/AaronNeville-CrazyLove.mp3"); But the line below does nothing and the resulting IMediaItem mediaItem = await CrossMediaManager.Current.PlayFromResource("assets:///long-test.mp3"); If I change the filename to a non-existing resource, I get a |
Hows it going,
I did end up finding the solution, for Android anyways, I haven't tried ios.
1) make sure your file build action is set as AndroidAsset, if you need
help with this let me know
2) even tho this isn't what the instructions say, don't use
playfromresource(). You need to use crossMediaManage.currebt.Play(file)
3) you might already have this but file name needs to be
"file:///android_asset/"filename".mp3
Hope this helps, lmk if you have questions
Thanks,
James
…On Tue, Nov 30, 2021, 6:23 PM 4or5trees ***@***.***> wrote:
Hi @jimdog1001 <https://github.com/jimdog1001>, were you able to fix this
issue?
I am having the same problem.
This line properly downloads and plays the file (and the mediaItem
variable has valid metadata):
IMediaItem mediaItem = await CrossMediaManager.Current.Play("https://ia800806.us.archive.org/15/items/Mp3Playlist_555/AaronNeville-CrazyLove.mp3");
But the line below does nothing and the resulting mediaItem variable has
no valid metadata and the Duration property is zero across the board. The
long-test MP3 file itself is valid (duration is 1 min 44 secs)
IMediaItem mediaItem = await CrossMediaManager.Current.PlayFromResource("assets:///long-test.mp3");
If I change the filename to a non-existing resource, I get a
NullReferenceException. So it does seem to be able to find the
long-test.mp3 file
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#840 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AVURRKVUAR36P5DWZFTUDELUOVMHLANCNFSM5FJQIHKQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
@jimdog1001 Thank you so much! You have resolved my issue. (and so quickly too!) The full working line is now: IMediaItem mediaItem = await CrossMediaManager.Current.Play("file:///android_asset/long-test.mp3"); |
Fantastic. No problem! That problem bugged me for a bit haha. Cause they
say to use playfromresource but it jjst doesn't work for some reason. Glad
you got it working.
James
…On Tue, Nov 30, 2021, 6:53 PM 4or5trees ***@***.***> wrote:
@jimdog1001 <https://github.com/jimdog1001> Thank you so much! You have
resolved my issue. (and so quickly too!)
The full working line is now:
IMediaItem mediaItem = await CrossMediaManager.Current.Play("file:///android_asset/long-test.mp3");
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#840 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AVURRKSIQ4ERHDCWA7QROXTUOVPXVANCNFSM5FJQIHKQ>
.
Triage notifications on the go with GitHub Mobile for iOS
<https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675>
or Android
<https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub>.
|
Do you have a solution for iOS as well? Duration doesn't work in iOS either, but the file plays normally |
Is it possible you can go more in-depth with whats the point of this? -> |
@DaLegacy The line you quoted is the line that plays the audio file. In my case I do not use the Important to note is that I only worked with short sound files and not video files. That being said, here is the setup I used to get it working:
<ItemGroup>
<AndroidAsset Include="Assets\sound-files.json" />
</ItemGroup>
<!-- Example of sound file: -->
<ItemGroup>
<AndroidAsset Include="Assets\sound-files\Example\Here\There\my-sound-file.ogg" />
</ItemGroup>
string jsonFileName = "sound-files.json";
string content;
AssetManager assets = this.Assets;
using (StreamReader sr = new StreamReader(assets.Open(jsonFileName)))
{
content = sr.ReadToEnd();
}
// deserialize as desired
|
I am trying to use this package to play mp3 files that are stored locally. I am using await CrossMediaManager.Current.PlayFromResource("assets:///SaintsVsDemons.mp3"). The file is stored under android in the assets folder and the build action is AndroidAsset. No matter what I try, however, it will not play the local file. Is this a bug? Please help.
The text was updated successfully, but these errors were encountered: