Comments (10)
I'll test it and let you know
from unitynativegallery.
I'm guessing that you are trying to play the video on a RawImage using a VideoPlayer component. In that case, try setting the url of the video player like this:
// This assumes that RawImage is already assigned to the VideoPlayer (either from the Inspector or by code)
videoPlayer.url = videoPath;
//videoPlayer.url = "file://" + videoPath; // try this if it doesn't work with just videoPath
videoPlayer.source = VideoSource.Url;
videoPlayer.Play();
Otherwise, if you are trying to play the video using the NativeGallery.LoadImageAtPath function, it won't work because it supports images only.
P.S. You can check if something is indeed wrong by first trying to play the video via Handheld.PlayFullScreenMovie( "file://" + videoPath );
. If this works, then it should be an issue with VideoPlayer.
from unitynativegallery.
Thanks for quick reply,
I tried handheld.PlayFullScreenMovie, but I want to do something similar to the way you displayed images on cube, I want to display videos on cube.
from unitynativegallery.
Try this one:
NativeGallery.GetVideoFromGallery( ( path ) =>
{
Debug.Log( "Video path: " + path );
if( path != null )
{
// Play the video on a cube
GameObject cube = GameObject.CreatePrimitive( PrimitiveType.Cube );
cube.transform.position = Camera.main.transform.position + Camera.main.transform.forward * 5f;
cube.transform.forward = -Camera.main.transform.forward;
Material material = cube.GetComponent<Renderer>().material;
if( !material.shader.isSupported ) // happens when Standard shader is not included in the build
material.shader = Shader.Find( "Legacy Shaders/Diffuse" );
AudioSource audioSouce = cube.AddComponent<AudioSource>();
VideoPlayer videoPlayer = cube.AddComponent<VideoPlayer>();
videoPlayer.renderMode = VideoRenderMode.MaterialOverride;
videoPlayer.targetMaterialRenderer = cube.GetComponent<Renderer>();
videoPlayer.targetMaterialProperty = "_MainTex";
videoPlayer.audioOutputMode = VideoAudioOutputMode.AudioSource;
videoPlayer.EnableAudioTrack( 0, true );
videoPlayer.SetTargetAudioSource( 0, audioSouce );
videoPlayer.url = path;
videoPlayer.source = VideoSource.Url;
videoPlayer.Play();
audioSouce.Play();
}
}, "Select a video" );
from unitynativegallery.
Thanks its working now. Just want to ask, After selecting the video it shows me this window:
which I don't need. is it possible to remove the above window. So that as soon as I select the video it is displayed on the cube.
from unitynativegallery.
It doesn't seem possible, at least prior to iOS 11:
https://stackoverflow.com/a/5893066/2373034
https://stackoverflow.com/a/48643954/2373034
from unitynativegallery.
It says:
With iOS 11 you can set the property videoExportPreset to AVAssetExportPresetPassthrough to get the original:
if #available(iOS 11.0, *) {
picker.videoExportPreset = AVAssetExportPresetPassthrough
}
The "Video compression..." label just flashes for a few milliseconds and then the export is done.
@diego Renau almost had the correct answer
from unitynativegallery.
To skip the video processing on iOS 11 and later, you can add the following code to line 307 of NativeGallery.mm:
if (@available(iOS 11.0, *)) {
imagePicker.videoExportPreset = AVAssetExportPresetPassthrough;
}
But it won't work on earlier iOS versions (there will still be a video preview/processing step). I haven't tested it myself.
from unitynativegallery.
I am developing a ar app, therefore I do not want the user to see this "Choose screen", the code I shared with u speed up the compression process but its of no use to me. I will look out for ways if I found one I will let you know, If u figured out a way Kindly update the asset.
Thank you, It is a great asset and u are a great guy. It was nice talking with you.
from unitynativegallery.
It's nice talking with you, too. I'm closing this issue now but feel free to reopen it if you find something new.
from unitynativegallery.
Related Issues (20)
- LoadImageAtPathAsync crash HOT 3
- IOS 17 - WhatsApp videos HOT 7
- Undefined symbols for architecture arm64 HOT 2
- NativeGallery.GetImageFromGallery Not working on Windows HOT 1
- Is there any way for me to display a dialog box asking for permission to access the album? HOT 1
- Unity Android Playform Build 'UnauthorizedAccessException' cant read file path is denied HOT 2
- v1.7.9 ERROR com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable HOT 2
- VisionOS Support for VisionOSVideoComponent HOT 30
- Where does the screenshot go when using the editor?
- Unity 2023 support HOT 5
- When the Android phone pops up to confirm the authorization, click Allow and get stuck. HOT 10
- iOS Ad Privacy Manifest HOT 1
- Can't open *.heic files HOT 8
- DirectoryNotFoundException: Could not find a part of the path "/storage/emulated/0/Android/data HOT 2
- SaveAudioToGallery method is private HOT 1
- iOS GetImageFromGallery show all photos event if PHAuthorizationStatusLimited HOT 2
- Unable to Save Images/Videos (IOS) HOT 2
- How to disable permission request on launch and instead use Runtime permissions HOT 2
- Plugin is not working for android 13 and above HOT 4
- When I use the AR camera I can't use the method "GetImageFromGallery" to select the picture, and call back is null HOT 12
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 unitynativegallery.