Skip to content
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

Doesn't work for Arabic locale #87

Closed
saeed74 opened this issue Sep 5, 2016 · 2 comments
Closed

Doesn't work for Arabic locale #87

saeed74 opened this issue Sep 5, 2016 · 2 comments
Labels

Comments

@saeed74
Copy link

saeed74 commented Sep 5, 2016

if user has been selected persian or arabic language from settings of the device, the video cache will not work because of arabic/persian digits in pingUrl:

Logcat:

Open connection  to http://127.0.0.1:۴۲۵۸۹/ping
Error reading ping response
com.danikula.videocache.ProxyCacheException: Error opening connection for http://127.0.0.1:۴۲۵۸۹/ping with offset 0

i just solved the problem by adding a method in HttpProxyCacheServer.java:

Here is Codes:

String pingUrl = appendToProxyUrl(PING_REQUEST);
String CorrectpingUrl = convertToEnglishDigits(pingUrl);
HttpUrlSource source = new HttpUrlSource(CorrectpingUrl);

and here is the convertToEnglishDigits method code:

public static String convertToEnglishDigits(String value)
{
    String newValue = value.replace("١", "1").replace("٢", "2").replace("٣", "3").replace("٤", "4").replace("٥", "5")
            .replace("٦", "6").replace( "٧","7").replace("٨", "8").replace("٩", "9").replace("٠", "0")
            .replace("۱", "1").replace("۲", "2").replace("۳", "3").replace("۴", "4").replace("۵", "5")
            .replace("۶", "6").replace("۷", "7").replace("۸", "8").replace("۹", "9").replace("۰", "0");
    return newValue;
}
@saeed74
Copy link
Author

saeed74 commented Sep 5, 2016

Oh And Another Problem When Language is Persian/Arabic:
When Useing this code:

HttpProxyCacheServer proxy = App.getProxy(context);
String proxyUrl = proxy.getProxyUrl(data);
mPlayer.setDataSource(ProxyUrl);

the proxyUrl will be like below:

http://127.0.0.1:۵۷۹۷۱/https%3A%2F%2Fdl.dropboxusercontent.com%2Fs%2Fb0pbv3c1y6ssw16%2Fmardome_shahr.mp3

that is obvious will not work and it respond with MediaPlayer Error (1, -1004).
I used convertToEnglishDigits method again for handle this:

HttpProxyCacheServer proxy = App.getProxy(context);
String proxyUrl = proxy.getProxyUrl(data);
String correctProxyUrl = App.convertToEnglishDigits(proxyUrl);
mPlayer.setDataSource(correctProxyUrl);

btw Thank You for Your Library<3

EDIT 1:
still getting some errors like MediaPlayer: error (100, 0) or MediaPlayer: error (-38, 0) ONLY if language is persian/arabic.

I will wait for your solution. thanks again

EDIT 2:
setting app language in Application Class is another solution that I found:

public class App extends Application {
@Override
    public void onCreate() {
        super.onCreate();

        Configuration newConfig  = new Configuration();
        newConfig.locale = Locale.ENGLISH;
        super.onConfigurationChanged(newConfig);
        Locale.setDefault(newConfig.locale);
        getBaseContext().getResources().updateConfiguration(newConfig, getResources().getDisplayMetrics());

    }

working good but i dont know why i feel bad about it!

@danikula danikula added the bug label Sep 5, 2016
@danikula danikula changed the title VideoCache Not Working When Language of Phone is Arabic/Persian Doesn't work for Arabic locale Sep 5, 2016
@danikula
Copy link
Owner

danikula commented Sep 5, 2016

@saeed74 fixed in 2.6.1. Thanks for your contribution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants