I have seen many similar questions, seems like a lot of people trying to figure it out, I couldn't find any answer that would help me. I am making a simple app for Android using Unity.
I want to have a folder in android internal storage root, on my pc it looks like: huaweiP30\internal storage\videos\
I don't need to write anything to that folder, I want my app to list all the mp4 videos from that folder and be able to play them using unity video player, I want the user to be able to easily add more videos to it by just dropping them into that folder. I tested it on windows and the app is completed working as expected, all I need to do now is to give it the correct path to the internal storage.
Alternatively I could have the app list all .mp4 files on the whole storage if that's easier to do.
I I tried all the answers that I was able to find online, some of which worked for other people. Nothing has worked for me so far.
used this for testing on windows and works exactly how I want it. I just don't know what should I replace the path with to make it read from internal storage\videos\
string videosPath = "C:\Users\Admin\Downloads\";
string [] filePaths = Directory.GetFiles(videosPath,"*.mp4");
Please help me either solve it or find an alternative resolution, I appreciate any help.
Thanks in advance.
This was easier than I thought! I was researching for so long and already going crazy when all I had to do is - in my phone settings I went to permissions, memory and allowed my app to access the memory.
Then it's as simple as
string path = Application.persistentDataPath.Substring(0, Application.persistentDataPath.IndexOf("Android", StringComparison.Ordinal));
videosPath = path +"/videos/";
to get the path. without the last bit I was able to read every single video on my internal storage when I added
SearchOption.AllDirectories
here is how to make your app ask for permissions so you don't have to manually allow it.
https://docs.unity3d.com/Manual/android-RequestingPermissions.html
The sample code is about microphone but all you need to do is just change it to ExternalStorageRead/Write, don't worry about 'External', it works for internal memory too.
Related
I am trying to recreate some features of Spotify in C# using the PostgreSQL database.
The reason is simple, I want to gain more knowledge, and I think this is a good challenge.
But I ran into an obstacle that I've been standing for days. Spotify he doesn't download the music, he does her streaming, plays the music while it's downloaded.
However, I can't do this in C#, I'm using the PostgreSQL database.
I'm well locked in this part, I tried several implementations, but I think I'm not on the right track, and on the internet I imagine I'm looking wrong, otherwise I would have found it.
Do you have any guidance for this streaming process in C#? I've tried to read the large_object bytes from PostgreSQL, but couldn't.
Any suggestions or guides about the process are welcome.
You start by getting the file into the database or its network location into the database, whichever gives you better performance; Then start with creating an implementation of a bytestream. You want to be transmitting raw data to c#.
you then build a real time interpreter that takes in using your file format, one byte at a time, and plays the value associated with that section. does that make sense? this is simple to do with many libraries and the brunt of it is just figuring those out.
You seem like you've PROBABLY got that first part down, and are instead having issues with the database. A lot of things we did at my last company involved saving file network locations and indexing files on disk. You might be able to instead point your streamer to a file locally using a server, and instead transmit data from one point to another in that manner instead.
You seem more than capable of doing this just judging by your speech. I hope this comment was helpful, and if it was not I apologize as well. I would be interested in seeing your finished result.
for clarification here would be that workflow:
request for a song listed in table dbo.Songs
matches that song onto dbo.songlocation
streams from dbo.songlocation.location from the filename dbo.songlocation.songname = dbo.song.name and verified directory returns true
enjoyment of that music
in my uwp app I am getting video files from KnownFolder.VideoLibrary and I am using QueryOptions to get them, so taking advantage of that I am trying to use AdvancedQuerySyntax so that I only get video files, but I am actually getting subtitle files like srt as well. what am I doing wrong here? is the AQS syntax I wrote wrong? I think subs files are also considered as video files according to this syntax, is there a way I can narrow it down to getting only video files excluding subtitle files? or can I get a link to docs where I can know what is the list of extension types, this syntax actually will return? So I can manage it accordingly?
CODE
videoFileOptions = new QueryOptions()
{
IndexerOption = IndexerOption.OnlyUseIndexerAndOptimizeForIndexedProperties//check sort order later
};
string videoFilter = "System.Kind:=System.Kind#Video";
videoFileOptions.ApplicationSearchFilter += videoFilter;
videoFileOptions.SetPropertyPrefetch(PropertyPrefetchOptions.VideoProperties, RequiredVideoProperties);
videoFileOptions.SetThumbnailPrefetch(ThumbnailMode.VideosView, thumbnailRequestedSize, ThumbnailOptions.UseCurrentScale);
This is the line where I am providing the filter.
string videoFilter = "System.Kind:=System.Kind#Video";
Short answer: .srt and other subtitle files are classified as video files since any app supporting playback might want access to srt files.
You can add an application search filter ext:<>.srt to remove srt files from your results.
Long Answer: The inevitable question is why not have another type for Kind:Subtitles or something? Why include them for with Kind:Video?
Well there is another pressure that goes on the Kind mappings beyond just "does this extension make sense as a video"? It all comes back to the SD card access on Windows Phone.
See for Windows 8 an modern app accessing the SD card had to declare a file launch experience for any file type they wanted to see on the SD card. For example that meant that a video app would need a file launch experience for mp4, avi, ect. However, on Windows Phone this wouldn't work because there was no way for an app to override the default system app for mp4 or avi (there is another story here for another day). So we needed another way to give apps access to mp4 files on the SD card.
The solution was that since the UI already said "Grant this app access to Videos and your SD card" then any app with both the video library capability and SD card access should have access to all files of Kind.Video on your SD card. Thus Kind.Video not only meant "Video files" but also "Files a video app would want access to".
With this slightly changed definition, it meant that any files the built in video player needed were suddenly included in the Kinds.Video mapping. Which is where .srt files come from in the mapping.
And as one of the people responsible for making the kind mapping decisions, I'd like to take this opportunity to apologize my mess and promise I'm not nearly as brain dead as you'd think looking at this design. Probably
I am making a simple UWP app that takes user input and stores it in an XML file. Eventually I'm going make that into an Open-XML esque file format which I can distribute to different people. I would like an easy way to write to the Documents folder like a normal C# application does. What would be the easiest way to do this. I considered using a sort of 'runner' application that would take command line arguments and write them to the requested folder, but that seems like a bit too much. Is there any other way?
EDIT: LOL after a ton of Googling, I couldn't find it. 5 minutes after I posted this, I found it. You can give this access in the package manifest by adding the following line of code:
<Capabilities><uap:Capability Name="documentsLibrary"/></Capabilities>
EDIT #2: Alternatively you can just use the FileOpenPicker and FileSavePicker
Your app will get rejected by the Windows Store if you include this capability in your manifest:
<Capabilities><uap:Capability Name="documentsLibrary"/></Capabilities>
You must use a FileSavePicker to ask permission from the user to access a certain file on disk. UWP does not allow you to freely roam the user's machine. The only full access you have, is the applications local/temp/roaming storage.
I've been trying to learn how to handle saving normal .txt files in UWP, and have realized that it's quite locked down compared to WPF, especially in the sense of what folders you can access without requesting the user to select a location. I have searched for various ways this might be possible but found no working answer.
Question Description:
I basically would love to know if this is possible, and preferably a point in the direction where I can learn how exactly to do this.
Application settings page requires user to select folder where files are saved.
Application remembers this between launches (unsure if this is possible, but I can't require the user to select the folder on every launch)
Application saves files to the specified folder.
In my understanding, this should be possible, as the user is the one specifying the location via filepicker, but is it possible to have this work between launches so that the user wont be required to re-select the save folder?
I need to figure this out, as I would like my application to support selecting attached network drives, cloud storage folders, etc.
Any help is very much appreciated, and if there are any questions I will answer them to the best of my ability.
Fow this purpose there are two access lists designed: FutureAccessList and MostRecentlyUsedList. Once the user has picked up the folder with the picker, you add it to such list and receive a token, which you save for future purpose in LocalSettings:
ApplicationData.Current.LocalSettings.Values["MyFolder"] = StorageApplicationPermissions.FutureAccessList.Add(pickedFolder);
Then later, once you want to access that folder, you can do it like this:
StorageFolder folder = await StorageApplicationPermissions.FutureAccessList.GetFolderAsync(ApplicationData.Current.LocalSettings.Values["MyFolder"].ToString());
You can't save a StorageFolder or a path to it in settings, hence the UWP app needs permissions to access the folder. Using above access lists solves this problem.
I believe you want to save user settings and keep it somewhere so that next time when they launch the application, they can use the same settings.
Please check out this tutorial from Microsoft, which describes how to do exactly that.
https://msdn.microsoft.com/en-us/library/bb397750(v=vs.110).aspx
I have recently been assigned a task which sounded relatively simple!
Upon attempting it became clear it wasn't as straight forward as i first imagined!!!
I am trying to download multiple files to one location on the users machine. They select these files from lists within a custom share-point web part. Thats the bit i have managed to get working! The downloading is done via WebClient (System.Net.WebClient)
I now want to allow the user to select a location on their local machine to download the files to.
I thought i would be able to use but after attempting this i realized i can only pick files :( in order to get the desired location which will confuse the user
I want something similar to the above but i only need it to return a path location like c:\Temp or any other location the user prefers on their local machine.
Could anyone suggest a control that could provide this functionality. It can also be a share-point control.
In the meantime I will be attempting Tree view as i have never used these before and these may have the power to do this from what i have read
Cheers
Truez
Clarity on language ASP.NET
Unfortunately, you can't do this without some kind of active content, like a Flash control or spit activeX /spit.
It seems strange at first, but you have to consider that this kind of functionality would let a site discover the structure of anyones storage devices; this is not 'a good thing'™
However, perhaps a different approach might solve the problem?
Why are you using WebClient, can't you provide the link to the client and let them choose their own download folder ?
I ended up zipping the files in to one folder and passed the file to be downloaded through the browser! Thanks for your comments!