Baseflow / XamarinMediaManager

Cross platform Xamarin plugin to play and control Audio and Video
https://baseflow.com
MIT License
769 stars 306 forks source link

Working with remote files. #475

Closed siwaphatpg closed 5 years ago

siwaphatpg commented 5 years ago

Mr.Martijn. I need some description. I'm new at Xamarim development and I'm developing a Xamarin project to work with media files. I have tried to play media file (Both of .mp3 and .mp4) with the sample file url in your site project it works well. But when I come back to work with my project and play with given file URL from local web site look like this ("http://127.0.0.1:1111/Files/xxxx.mp3") but it doesn't work.

I tired 2 ways to give file URL to the CrossMediaManager.Current.Play method. 1.Giving direct URL to that method like this "CrossMediaManager.Current.Play("http://127.0.0.1:1111/Files/xxxx.mp3")".

  1. Create a MediaItem object and give their attribute. MediaItem mediaItem = new MediaItem("http://127.0.0.1:1111/Files/xxxx.mp3") { MediaType = MediaType.Audio, MediaLocation = MediaLocation.Remote };

Both of these approaches don't work with my project. Can you let me know how to use your project properly?

siwaphatpg commented 5 years ago

I tested a lot of file URLs it works well. "https://sec.ch9.ms/ch9/84bf/d74cd12c-419b-4333-b74f-1c5e22f284bf/azfr-Malhotra.mp3" "https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_20mb.mp4" But for my URL it doesn't work (such as an URL from my local machine). Please let me know what I have to know before go next.

martijn00 commented 5 years ago

Do you even have access to the file on the phone or emulator? 127.0.0.1 is not accessible normally. If you want a local file you need to add it as embedded resource, or in a folder in the app project.

siwaphatpg commented 5 years ago

Sorry for my bad explanation. I know I can't access the 127.0.0.1 IP from the emulator. What I mean is I give binding port to a local website and I can access it from the emulator by using xxx.xxx.xxx.xxx:1111. That web site has media files that I want to display with your component my code look like this "xxx.xxx.xxx.xxx:1111/Files/xxx.mp3".

Thanks for your response.

martijn00 commented 5 years ago

I can't say without any details. You should be able to stream any normal mp3 file. Maybe you need to add headers or something?

siwaphatpg commented 5 years ago

Thanks I will check it tomorrow. Is the problem I’m facing just only relating with file header or it is relating with web site configuration too?

martijn00 commented 5 years ago

As said, you don't give any details, so i can't tell. All my tests work so i suspect there is something wrong in your code.

siwaphatpg commented 5 years ago

CrossMediaManager.Current.Play("http://192.168.220.110:1113/SampleVideo_1280x720_1mb.mp4"); CrossMediaManager.Current.Play("https://archive.org/download/BigBuckBunny_328/BigBuckBunny_512kb.mp4");

I give 2 lines of code that I use to test. First line doesn't work but second work as I expect. I still don't know the problem why I can't use my URL.

siwaphatpg commented 5 years ago

It seems I can play media files only when I use the URL that has https. http://clips.vorwaerts-gmbh.de/big_buck_bunny.mp4 <<< This can't play. https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_1mb.mp4 <<< This can. As you can see both of URL are public.

martijn00 commented 5 years ago

Both url's play fine for me. Maybe your device is not working?

siwaphatpg commented 5 years ago

Do I have to config something? Is it relating that I use .NET standard project?

siwaphatpg commented 5 years ago

https://github.com/siwaphatpg/XamMediaTest this is a sample project that I'm testing. It would be good if you help me determine. It think I must do something wrong.

ihassantariq commented 5 years ago

@martijn00 I am having the same problem with my url which looks like this. http://devfra.dev.vms.me:1337/api/files/vms/d4c1b50887315fc2319800da4acdd469_8OJ06GZUT0DGSDSG.mp3

ihassantariq commented 5 years ago

@martijn00 can you give me insight on how I can fix this. Every other urls are working.

ihassantariq commented 5 years ago

@martijn00 I think issue is related to giving port number.

martijn00 commented 5 years ago

Can you look at: https://github.com/martijn00/XamarinMediaManager#important under the iOS section? You probably have to take care of ATS. Let me know if that works.

ihassantariq commented 5 years ago

Right now, I am not using http, I am using https

Get Outlook for iOShttps://aka.ms/o0ukef


From: Martijn van Dijk notifications@github.com Sent: Tuesday, May 28, 2019 6:42:44 PM To: martijn00/XamarinMediaManager Cc: Hassan; Comment Subject: Re: [martijn00/XamarinMediaManager] Working with remote files. (#475)

Can you look at: https://github.com/martijn00/XamarinMediaManager#important under the iOS section? You probably have to take care of ATS. Let me know if that works.

— You are receiving this because you commented. Reply to this email directly, view it on GitHubhttps://github.com/martijn00/XamarinMediaManager/issues/475?email_source=notifications&email_token=ACRFLFYCPXXB2IGDJXIVQFTPXVOIJA5CNFSM4HM7K7YKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODWMXGFA#issuecomment-496595732, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ACRFLF6LJGJTHNUZ3EYIIX3PXVOIJANCNFSM4HM7K7YA.

siwaphatpg commented 5 years ago

@ihassantariq Did you solve your problem? I'm still having the same problem a few day ago I moved to another part of my project. I will comeback to this issue soon. Please let me know if someone found the solution for my issue. This is the most important part of my project.

ihassantariq commented 5 years ago

@siwaphatpg No, I have opened an issue. I don't exactly know why it is not working on IOS. Although, its working perfectly in Android.

ihassantariq commented 5 years ago

@siwaphatpg here is an issue link. https://github.com/martijn00/XamarinMediaManager/issues/486

siwaphatpg commented 5 years ago

@ihassantariq What kind of web server you are using? I'm using IIS I don't know that I have to config something additionally?

ihassantariq commented 5 years ago

@siwaphatpg mine is based on Node.js. As it is Parse server. Also, I don't have any idea whether do I have to configure additional parameters to file or not.

siwaphatpg commented 5 years ago

I have tried to add handle event Current_MediaItemFailed to see what happens on my code. And after I added handle it It see that after I execute this code. var mediaItem = await CrossMediaManager.Current.Play("http://dev.testsite.nat.go.th/SampleVideo_1280x720_1mb.mp4"); mediaItem.MetadataUpdated += (sender, args) => { var title = args.MediaItem.Title; }; It goes to the event I have handled. ` private void Current_MediaItemFailed(object sender, MediaManager.Media.MediaItemFailedEventArgs e) {

    }`

I have to figure out what is clause of problem. In debug mode I get {Com.Google.Android.Exoplayer2.ExoPlaybackException}.

ihassantariq commented 5 years ago

@siwaphatpg you defined url is not working for me. Also, I don't get any failure events other than I have described in my issue.

siwaphatpg commented 5 years ago

It is local url only working in my PC. Thank for your spending time to describe me. If I have something to ask I will come again.

siwaphatpg commented 5 years ago

I get error that shows Java.IO.IOException: Cleartext HTTP traffic to 192.168.220.102 not permitted

siwaphatpg commented 5 years ago

But after I searched how to fix this issue. Follow this cleartext-http-traffic-not-permitted. I got an error while I'm executing CrossMediaManager.Current.Play(xxxxxxx) method. {System.NullReferenceException: Object reference not set to an instance of an object. at MediaManager.MediaManagerImplementation+<Play>d__45.MoveNext () [0x000f7] in C:\Users\mhvdi\Documents\OpenSource\XamarinMediaManager\MediaManager\Platforms\Android\MediaManagerImplementation.cs:159 --- End of stack trace from previous location where exception was thrown ---

siwaphatpg commented 5 years ago

Thanks for all response from both of you. My project works as my expectation. It is my faults that I didn't read enough before doing.

thanoue commented 3 years ago

@martijn00 Hi can't play any media files on the IOS app. I got an HTTPS link that stores an mp4 file on it. It can play on Android, but on IOS it can't. I tried to download the song to file storage and play from the local file path, but it still had no luck. It always returns an IMediaItem with duration = 0:00:00. I also followed all steps on the Important part of the document. It can play when I call the Play method directly with the URL, but when I create an IMediaItem, it failed.

It logs these messages on output:

2021-08-02 13:25:30.865 MusicApp.iOS[3601:1467786] -[AVAsset loadValuesAsynchronouslyForKeys:completionHandler:] invoked with unrecognized keys ( albumName, author, title, artist ). 2021-08-02 13:25:32.158 MusicApp.iOS[3601:1467812] -[AVAsset loadValuesAsynchronouslyForKeys:completionHandler:] invoked with unrecognized keys ( artwork ).

Thanks.

dawitalemu commented 3 years ago

I am having the last problem that @thanoue is having and I am pulling my hair out here. It used to work just fine few weeks ago, and I am stuck here one day before production release. Works on Android just fine, but iOS gives the above error. @martijn00, please help.